Thursday, July 21, 2011

Simulating a Site + CDN

‹prev | My Chain | next›

Thanks to my work last night, I have two VMs. One to hold my main web server (www.local) and the other to simulate a content distribution network (cdn.local).

I am going to try to serve up the following page:

It includes 12 images, jQuery (minified) and some CSS. The various sizes are:
cstrom@debian:/var/www$ ls -lh
total 196K
-rw-r--r-- 1 cstrom cstrom 8.0K Jul 21 21:34 00-h.jpg
-rw-r--r-- 1 cstrom cstrom 6.5K Jul 21 21:34 01-e.jpg
-rw-r--r-- 1 cstrom cstrom 4.2K Jul 21 21:34 02-l.jpg
-rw-r--r-- 1 cstrom cstrom 5.4K Jul 21 21:34 03-l.jpg
-rw-r--r-- 1 cstrom cstrom 6.4K Jul 21 21:34 04-o.jpg
-rw-r--r-- 1 cstrom cstrom 624 Jul 21 21:34 05-space.jpg
-rw-r--r-- 1 cstrom cstrom 13K Jul 21 21:34 06-w.jpg
-rw-r--r-- 1 cstrom cstrom 6.1K Jul 21 21:34 07-o.jpg
-rw-r--r-- 1 cstrom cstrom 3.6K Jul 21 21:34 08-r.jpg
-rw-r--r-- 1 cstrom cstrom 5.0K Jul 21 21:34 09-l.jpg
-rw-r--r-- 1 cstrom cstrom 7.9K Jul 21 21:34 10-d.jpg
-rw-r--r-- 1 cstrom cstrom 6.9K Jul 21 21:34 11-bang.jpg
-rw-r--r-- 1 cstrom cstrom 90K Jul 21 21:51 jquery-1.6.2.min.js
-rw-r--r-- 1 cstrom cstrom 221 Jul 21 21:52 style.css
I will serve up Javascript and CSS gzip'd from the CDN. In the nginx configuration:
    gzip  on;
gzip_disable "MSIE [1-6]\.(?!.*SV1)";
gzip_types text/plain text/html text/css application/json application/x-javascript text/xml application/xml application/xml+rss text/javascript;
Now, all of this isn't exactly real world. The average site uses 13 domains (not 2), 53 images, 4 CSS files, 14 Javascript files for a grand total of 800kb. By the way, you people are insane.

But I am not going to set up that many servers to test things out. I hope to see useful results with just simple tests.

Anyhow, following along with the idea of making this "real world" like, I add a minimal RTT to the CDN:
cstrom@debian:/var/www$ sudo tc qdisc add dev eth0 root netem delay 30ms
And an somewhat substantial one to the web server:
cstrom@debian:/var/www$ sudo tc qdisc add dev eth0 root netem delay 100ms
Loading up the site, I find the following in the network tab of Chrome's Developer Tools:

14 requests. 112kb transferred. 669ms (onload: 708ms, DOMContentLoaded: 521ms)

Not too shabby. Lost a little bit of time connecting to the main site due to the 100ms round trip time, but the images and other static content did not have to wait too long because they are served up from my awesome CDN!

Let's see how SPDY fares. Tomorrow.

(How's that for a teaser?)

Day #81

No comments:

Post a Comment