First request too slow even if I have a load balancer in the back

Posted by adrian7 on Server Fault See other posts from Server Fault or by adrian7
Published on 2012-06-01T10:15:46Z Indexed on 2012/06/01 10:43 UTC
Read the original article Hit count: 253

Filed under:
|
|

I have an Apache 2 on Centos + bind with a wordpress website on it (e.g example.com). I have also set up, on another server in a different contry a load balancer (varnish:80 + nginx 127.0.0.1:8080) for it - which task is to server all static content under /wp-content/.

Using Simple DNS editor I added an A entry to cdn.example.com pointing to the server's IP. So no extra work from a 2nd dns server.

Then using htaccess I redirect all requests to jpg|gif|css|js files to cdn.example.com. That works and all files are saved on the "cdn" server and served right away.

My problem is that for the first time I enter on example.com (e.g after restarting the computer or closing the browser) the load time is 1 up to 3 seconds, while any subsequent page loads take only 300 to 600 miliseconds.

I know it might be a DNS issue, but I have done a cache check on several websites and cdn.example.com indicates the right IP.

Do you have any ideas where I should dig to solve this first-time slowness?

© Server Fault or respective owner

Related posts about nginx

Related posts about load-balancing