开发者

Why Aren't Django Static Generator & Nginx Giving Me Boss Speed?

So there have been lots of articles like this one recently, extolling the virtues of Django Static Generator when used in combination with a light front-end Web server. It makes a whole lot of sense to me.

However, I get nothing like the results that other people are reporting -- thousands of requests per second -- and I don't know why that is.

I'm getting ready to launch a redesign of my newspaper's Web site. I've got it using Static Generator on a test server right now. And when I run Apache Bench on a particular static page, I get pretty miserable results:

ab -c 10 -n 1000 http://journal.streamlister.com/news/

Concurrency Level:      10
Time taken for tests:   53.011 seconds
Complete requests:      1000
Failed requests:        0
Write errors:           0
Total transferred:      21281212 bytes
HTML transferred:       21067360 bytes
Requests per second:    18.86 [#/sec] (mean)
Time per request:       530.107 [ms] (mean)
Time per request:       53.011 [ms] (mean, across all concurrent requests)
Transfer rate:          392.04 [Kbytes/sec] received

I'm watching top on the server while the siege is on, and I can see that it's not hitting Apache or the database server at all. So it is, in fact, serving the cached page. Nginx is running, but it never gets above 2% memory usage. CPU remains about 95 percent idle.

What am I doing wrong? Could I have misconfigured nginx somehow? My main config file is pasted below; the include specific to this site is pretty much a carbon copy of the sample config on the Static Generator home page. I'm running Ubuntu 9.10 on a Slicehost 256k slice.

user not_my_real_username;
worker_processes  4;
error_log  /var/log/nginx/error.log;
pid        /var/run/nginx.pid;
events {
    worker_connections  8开发者_JAVA百科192;
}
http {
    include       /etc/nginx/mime.types;
    default_type  application/octet-stream;
    access_log  /var/log/nginx/access.log;
    sendfile        on;
    #tcp_nopush     on;
    keepalive_timeout  0;
    #keepalive_timeout  65;
    tcp_nodelay        on;
    gzip  on;
    include /etc/nginx/conf.d/*.conf;
    include /etc/nginx/sites-enabled/*;
}


I'm not an expert in this case. But if CPU is idle and also Memory isn't the bottleneck then the harddrive comes to my mind. Maybe its very slow and the bad speed is a hint of a broken harddisk.

You should run some simple benchmarks.


Where are you doing the test from? Another server in the same datacenter, or your home/work internet connection? It's going to be hard to reliably test the performance of your site from your home connection. For one, you internet connection may be too slow, and secondly, many personal routers can't handle that many concurrent connections.

Also... try running the benchmark without the images.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜