Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Low Apache/mod_wsgi throughput

I have a trivial WSGI app running on pesto, mod_wsgi and Apache:

def viewData(request):
    return Response("aaaaaaaaaa" * 120000) # return 1,2MB of data

On my test machine, I get about 100kb/s of throughput, meaning the request takes about 12 seconds to complete. Downloading static files from the same Apache instance gives me about 20MB/s. Why is there such a huge difference, and how can I speed up the WSGI app?

Software versions: Ubuntu 10.04, Apache 2.2.14, Python 2.6.5, mod_wsgi 2.6 (all Ubuntu's default packages), pesto-18

edit: The real app represented by this example does not try to send static files, but dynamically produces a large amount of HTML. HTML generation happens fast (I ran it through cProfile and timeit), but the transmission is slow, and I'd like to fix that particular problem.

edit 2: I tested current versions of pesto (21) and mod_wsgi (3.3) on the same stack, throughput did not change significantly. I also replaced mod_wsgi with spawning 0.9.5 behind apache's mod_proxy - this increased throughput by a factor of four, but it's still miles away from what I'd like it to be.

like image 432
Simon Avatar asked Oct 12 '22 16:10

Simon


1 Answers

In WSGI the application or the framework should return an iterable. Don't know if that is what Pesto does.

Change your code to:

def viewData(request):
    return Response(["aaaaaaaaaa" * 120000])

And try again.

like image 162
Clodoaldo Neto Avatar answered Oct 18 '22 02:10

Clodoaldo Neto