Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm running a Django app, using uWsgi behind Nginx. I've been doing some performance tuning and load testing using ApacheBench and have discovered something unexpected which I wonder if someone could explain for me. In my Nginx config I have a rewrite directive which catches lots of different URL permutations and then forwards them to the canonical URL I wish to use, eg, it traps, and forwards them all to

If I load test against any of the URLs listed with a redirect (ie, NOT the canonical URL which it is eventually forwarded to), it can serve 15000 concurrent connections without breaking a sweat.

If I load test against the canonical URL, which the above test I would have expected got forwarded to anyway, it can't handle nearly as much. It will drop about 4000 of the 15000 requests, and can only handle about 9000 reliably.

This is the command line I'm using to test:

ab -c15000 -n15000


ab -c15000 -n15000

I've tried several different types - it makes no different which order I do them in. This doesn't make sense to me - I can understand why the requests involving a redirect may not handle quite so many concurrent connections, but it's happening the other way round. Can anyone explain? I'd really prefer it if the canonical URL was the one which could handle more traffic.

I'll post my Nginx config below.

Thanks loads for any help!

server {
    rewrite ^(.*)$1 permanent;

server {
    root   /home/django/domains/;


    access_log  /home/django/domains/;

    location / {
        uwsgi_pass unix:////tmp/somesite-live.sock;
        include    uwsgi_params;

    location /media {
        try_files $uri $uri/ /index.html;

    location /site_media {
        try_files $uri $uri/ /index.html;

    location = /favicon.ico {
share|improve this question
up vote 4 down vote accepted

The answer is pretty simple, actually. In your first test (the redirect) ab is only benchmarking a "301 Moved Permanently" request. The second test is testing your actual content.

To illustrate what I mean, curl your redirect URL. You'll get something like:

<head><title>301 Moved Permanently</title></head>
<body bgcolor="white">
<center><h1>301 Moved Permanently</h1></center>

It's not hard to handle 15000 concurrent requests for just that! ;)

share|improve this answer
You are truly a king among men. Thank you :) – Ludo Feb 10 '11 at 16:49

Have you presented this to the dev mailing list? Very interesting for sure. Have you tried enabling full debugging; you might have had to enable it during compile. Once enabled do one request to the canonical and one to another. Perhaps the debug logs will shed some light. Have you tried removing the second server_name domain(somesite-live..)? Good luck, let us know if you figure it out!

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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