4

I am currently receiving a lot of traffic (1+ million page views a day). I have four 16GB RAM 8 CPU nginx servers setup behind Digital Ocean's load balancer (it is a new feature that they have added). When I go to each server directly, via the IP, the site loads quickly. However, if I go to the domain name, there seems to be a 1-3 second delay. Is this the load balancer not working correctly? Or is this a domain name issue? Note that I am using Round Robin and Sticky Sessions. Is there anything here that I need to check for in regards to my domain name setup?

  • dns queries are usually quick (except if your dns servers are very far or something similar), i suppose it's the load balancer itself that adds this latency, but 3 seconds is a lot, you should ask the webhosting company about that – olivierg Mar 24 '17 at 22:24
  • Is there an AAAA record as well? If so, it's possible that the device is trying to connect over IPv6 transport, timing out, and retrying over IPv4. – Andrew B Mar 27 '17 at 22:28
7

There are likely a number of things playing a part here. Here's the approximate steps when a load balancer is used

  1. DNS lookup for the load balancer
  2. Connect time to the load balancer. If this is https it's usually a few round trips, so latency plays a part
  3. Load balancer processing time
  4. Load balancer DNS looking time for the server (probably cached)
  5. LB open a connection to the server (possibly reusing an existing connection)
  6. LB transmit the request to the server
  7. LB wait for the server to process the request
  8. LB receive the response
  9. LB Send the response back to the client

Here's the steps without the load balancer

  1. Connect to the server. If this is https it's usually a few round trips, so latency plays a part
  2. Transmit the request to the server
  3. Wait for the server to process the request
  4. Receive the response

That's 9 steps instead of 4, a significant difference.

You can compare the two using Web Page Test, which will give you a lot more information. Do the tests then if you need help interpreting the results, edit your post and then tag anyone you want to see the update in a comment.

As Rowan points out below, latency is at least as important than bandwidth. Latency in the data center is very low, almost negligible, but every round trip to the server takes time. TLS 1.3 helps with this, and using a Content Distribution Network (CDN) that puts content closer to the user helps in many cases as well.

  • the reply will be traversing the load balancer as well. Even if it's not acted on by the balancer, if the device has a large latency between when it receives a packet and when it passes it on. then that could cause a sizable delay as each packet was handled twice – Rowan Hawkins Mar 25 '17 at 1:29
  • Yep that's included in the steps above, but I'll edit to make it a bit more obvious – Tim Mar 25 '17 at 2:55
  • With everybody pushing the bandwidth of something the latency of an object has been almost completely lost and that is where most of the Slowdown to occur. Also most of those bandwidth claims are for the first few blocks of data and not for a long-term transmission. Latency is what causes most of the delays. – Rowan Hawkins Mar 25 '17 at 6:28
  • I agree Rowan. I mentioned it in step 2, but it's important in all steps. I live in New Zealand, we're quite aware of latency here, it slows everything down - approx 150ms ping to the USA. – Tim Mar 25 '17 at 8:19

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.