2
votes

I don't actually have any problem, just a bit curious of things. I make a python web framework based on bottle (http://bottlepy.org/). Today I try to do a bit comparison to compare bottle WSGI server and apache server performance. I work on lubuntu 12.04, using apache 2, python 2.7, bottle development version (0.12) and get this surprising result:

Left: Apache, Right: Bottle WSGI

As stated in the bottle documentation, the included WSGI Server is only intended for development purpose. The question is, why the development server is faster than the deployment one (apache)?

As far as I know, development server is usually slower, since it provide some "debugging" features.

Also, I never has any response in less than 100 ms when developing PHP application. But look, it is just 13 ms in bottle. Bottle serve a very fast response

Can anybody please explain this? This is just doesn't make sense for me. A deployment server should be faster than the development one.

2

2 Answers

1
votes

Development servers are not necessarily faster than production grade servers, so such an answer is a bit misleading.

The real reason in this case is likely going to be due to lazy loading of your web application on the first request that hits a process. Especially if you don't configure Apache correctly, you could hit this lazy loading quite a bit if your site doesn't get much traffic.

I would suggest you go watch my PyCon talk which deals with some of these issues.

Especially make sure you aren't using prefork MPM. Use mod_wsgi daemon mode in preference.

0
votes

A deployment server should be faster than the development one.

True. And it generally is faster... in a "typical" web server environment. To test this, try spinning up 20 concurrent clients and have them make continuous requests to each version of your server. You see, you've only tested 1 request at a time--certainly not a typical web environment. I suspect you'll see different results (we're thinking of both latency AND throughput here) with tens or hundreds of concurrent requests per second.

To put it another way: At 10, 20, 100 requests per second, you might still see ~200ms latency from Apache, but you'd see much worse latency from Bottle's server.

Incidentally, the Bottle docs do refer to concurrency:

The built-in default server is based on wsgiref WSGIServer. This non-threading HTTP server is perfectly fine for development and early production, but may become a performance bottleneck when server load increases.

It's also worth noting that Apache is doing a lot more than the Bottle reference server is (checking .htaccess files, dispatching to child process/thread, robust logging, etc.) and all those features necessarily add to request latency.

Finally, I'd ask whether you tuned the Apache installation. It's possible that you could configure it to be faster than it is now, e.g. by tuning the MPM, simplifying logging, disabling .htaccess checks.

Hope this helps. And if you do run a concurrent benchmark, please do share the results with us.