Dear all,
I would like to discuss a high latency issue that my domain is facing.
We experience much higher end-to-end latency when calling HTTPS endpoint (we are connecting through Cloudflare).
Command: * curl -s -w “Time to connect: %{time_connect} Time to first byte: %{time_starttransfer}\n” -o /dev/null [address] -o /dev/null [address]
Time to connect: 0.404773 Time to first byte: 0.714566
Time to connect: 0.000023 Time to first byte: 0.304737
HTTPS example (using [address] = https://hive.space)(hive.space is mapped to 3.12.187.2 through Cloudflare):
Time to connect: 0.033559 Time to first byte: 0.995849
Time to connect: 0.000036 Time to first byte: 0.688093
Based on the direct connection to node’s IP above, the expected latency to HTTPS endpoint via Cloudflare should be somewhere around ~350ms (same as http connection) for the second time (due to keep alive), but in reality is much slower and can go above > 1s. We noticed that other websites using HTTPS with Cloudflare have significantly lower latency.
Is my expectation correct? What do you think causes this issue and do you have suggestions where to look?
This test in my opinion does not make sense, as you want to compare SSL vs nonSSL but the nonSSL is getting redirected to SSL anyway, so on this “nonSSL” you are again resolving a SSL Cert. Just not on the first connection.
Also if you do this please keep the factor of “variables” as low as possible. You have not done this.
As both sites are requesting a HTML site which is different! and have to be generated dynamically (on the first call) you are actually meassuring your Server-Performance and not Cloudflare. Because Cloudflare is the only variable in this test which is fixed and did not change between the testcases.
What I would recommend:
Go put the same file “testfile.txt” with the same input on both domains (domain.tld/testfile.txt)
prevent your plain IP from being redirected to a domain, or directly use the domain.
prevent changes/redirects to another protocoll (HTTP ==> HTTPS)
prevent redirects in general.
Then run your test again on a static file. As this excludes the Server-Performance and dynamic parts in this test!
Not run your test on these URLs:
https://hive.space/testfile.txt
http://dev.hive.space/testfile.txt (make sure there is no redirection to HTTPS!!!)
Now compare them.
Result:
Yes you will notice that HTTPS is slower as it has to resolve and validate the SSL Cert. This is normal. This just happens once and should not take longer then 50ms (for me it takes 37ms which is awesome!)
Also: to compare the TTFB or nonSSL vs SSL you can easily do this in a new (anonym) Tab in Chrome and just see how long your SSL Cert takes to resolve. Thats exactly the time of difference between SSL vs nonSSL. Simple as this.
See:
Thanks for the reply and tips. In the end, we decided to use a temporary workaround by increasing the keep alive connection duration for the time being.