I have a .NET Core microservice (API) that is a apart of an Azure Service Fabric application. The Service Fabric consists of 3 nodes. I have made the service run both on HTTP and HTTPS with a valid certificate. The problem is in the performance difference between the HTTP and HTTPS connections.
I am using a Let's Encrypt certificate. (I have also tried other free trial SSL certificates just to see if it makes a difference.) I am exposing the endpoints with Kestrel, defining them in the Service Fabric ServiceManifest and ApplicationManifest, and opening the ports via Azure Load Balancer. This is how I setup the endpoints using Kestrel:
.UseKestrel(options =>
{
options.Listen(IPAddress.IPv6Any, 80);
options.Listen(IPAddress.IPv6Any, 443, listenOptions =>
{
listenOptions.UseHttps("ssl.pfx", "password");
listenOptions.NoDelay = true;
});
})
When I hit the endpoint of my API from HTTP, the response time is consistently 0.06-0.2sec. However, when I hit it from HTTPS, it is not consistent and a lot slower (generally 10-30 times); the response time bounces from 0.5 (rarely) - 3-4 seconds. This inconsistency is unacceptable. My suspicion is that the TLS handshake is taking very long. Unfortunately, I have no idea why.
EDIT: The previously linked duplicate question explains the general behavior for HTTPS and I knew that before. However, my case is specific to the described environment, so the given answer doesn't fully satisfy my question. I have a running .NET web app using HTTPS on Azure that hasn't got this huge performance difference.