mod_perl vs php performance when accessing Oracle under loadby amasidlover (Sexton)
|on Aug 27, 2012 at 08:15 UTC||Need Help??|
amasidlover has asked for the
wisdom of the Perl Monks concerning the following question:
We have a large (77,000 lines inc POD and comments) application written in Perl and our client has asked us to 'make it faster' we already have a number of strategies for doing this and are tackling performance from multiple angles. However, in a meeting last week they showed us some stats of a PHP app they use along side our app and showed it doing 2,000 concurrent requests on the same hardware that our app only manages 200 concurrent requests on.
Obviously comparing two apps doing different jobs is nonsense, but the scale of difference was so dramatic I decided to see what we would need to do to get our app to that kind of performance. Our assumption, based on timings from debugs, is that talking to the DB (Oracle) is the most time consuming part of our app, so I decided to write a quick test script that did an INSERT and SELECT and then call it lots of times to see how fast it will go on their hardware.
So I wrote the test handler (will paste code and set-up details at end) and ran it on our hardware (not the client's yet), it performed badly... As its a bank holiday and I don't have access to test on their hardware I decided to knock together a PHP script for comparison, the results were quite shocking when loaded with 300 concurrent requests the average response time from the mod_perl handler is 1900ms and from the PHP it is 400ms.
So bearing in mind rewriting our app in PHP is not likely to be cost effective, my questions are:
1) Is my test valid?
2) Can I make the mod_perl version faster (and how)?
3) How much faster?
Server details:- The hardware node is a Quad Core Xeon L5630 @ 2.13GHz with 24Gb RAM, the OS for the Apache virtual machine is Gentoo, the OS for Oracle is Centos 5,.
Versions: OSes both updated within last 2 weeks, Apache version 2.2.22, mod_perl version 2.0.4, DBI Version 1.622, DBD::Oracle version 1.50, Oracle instant client version 10.2.0.3, Oracle Database 10g Express Edition Release 10.2.0.1.0, PHP version 5.3
Things I checked: during the testing the only load was from the test app/oracle, neither virtual machine hit any of its bean counter limits, e.g., memory, Oracle showed 1 session per Apache child at all times, inserts had been done after each run.
Apache config - the mod_perl module was not loaded for the PHP tests and PHP not loaded for the perl tests
The Perl code
The PHP code
I'm happy to answer more questions about the set-up and try any suggestions. I've done some searching myself and what I've found via Google seems to say a) mod_perl should be faster than mod_php and b) PHP has 'native' DB access code so 'can' be faster for DB access - I've got a fairly big problem though if its going to be 5 times worse under load...
Subsequent edit: SOLVED! Had done the PHP test without https on...