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?
There are likely a number of things playing a part here. Here's the approximate steps when a load balancer is used
- DNS lookup for the load balancer
- Connect time to the load balancer. If this is https it's usually a few round trips, so latency plays a part
- Load balancer processing time
- Load balancer DNS looking time for the server (probably cached)
- LB open a connection to the server (possibly reusing an existing connection)
- LB transmit the request to the server
- LB wait for the server to process the request
- LB receive the response
- LB Send the response back to the client
Here's the steps without the load balancer
- Connect to the server. If this is https it's usually a few round trips, so latency plays a part
- Transmit the request to the server
- Wait for the server to process the request
- 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.