From: Philip J. <pj...@un...> - 2011-12-28 02:14:37
|
On Dec 21, 2011, at 4:28 AM, Tobia Conforto wrote: > Hello > > I did some benchmarks comparing the performance of a Django project when deployed as a Jython webapp on Tomcat, as compared to a CPython daemon called through FastCGI. > > Based on Leo Soto's slides at http://slidesha.re/cdbGWr I expected a good if not better performance for the Jython webapp on Tomcat: he does mention performance in the third slide, and the Java runtime is well-known for having a good JIT compiler and concurrency implementation. > > Instead, on average I got half the throughput for Jython and Tomcat: > > http://img820.imageshack.us/img820/1408/jythonvspython.png > > I would like to share my setup ask if this is the expected result, or if anybody thinks I am missing something. > > Here is my configuration: > > Python: > - Python 2.5.5 (Debian package) > - manage.py runfcgi socket=django.sock daemonize=true method=prefork > - FastCGI run through Nginx > > Jython: > - Jython 2.5.2 > - Java OpenJDK 1.6.0_18 64bit (Debian package) > - Tomcat 6.0.28 (Debian package) > - webapp created via: manage.py war > > The benchmarks were done with the ab command, run with an increasing concurrency option and a high number of requests (eg. ab -c50 -n10000 http:...), checking for any errors (there were none) and recording the throughput result into a spreadsheet. > > The Django app being benchmarked is a clean new project with two simple views. The first view returns a fixed OK response: it is meant to measure the request overhead and scalability curve of the whole setup (Nginx + FastCGI on one hand, Tomcat + Modjy on the other). The second view computes fibonacci(25) using the naive recursive method: it is meant to measure a pure Python load that is big enough to shadow the request overhead, without introducing any DB access into the picture. > > What do you think? > > Is Jython + Modjy actually expected to be more or less half as fast as CPython + FastCGI? Are there any parameters I could tweak to try and get a better performance out of it? (I tried increasing the JVM heap memory, to no avail.) I haven't personally benchmarked Django on Jython but I would expect an empty response benchmark to be closer than your results, particular compared against CPython 2.5 (CPython 2.6/2.7 are generally faster than CPython 2.5). Ensure that you have warmed up the JVM JIT enough; hit the Jython app with around 10k requests *then* record the benchmark. Double check that you're using the server VM too (which is probably likely on your 64bit JVM). Also ensure the JVM has enough allowed memory, if it doesn't the GC could be a bottleneck. -- Philip Jenvey |