views:

980

answers:

2

I want to benchmark PHP vs Pylons. I want my comparison of both to be as even as possible, so here is what I came up with:

  • PHP 5.1.6 with APC, using a smarty template connecting to a MySQL database
  • Python 2.6.1, using Pylons with a mako template connecting the the same MySQL database

Is there anything that I should change in that setup to make it a more fair comparison?

I'm going to run it on a spare server that has almost no activity, 2G of ram and 4 cores.

Any suggestions of how I should or shouldn't benchmark them? I plan on using ab to do the actual benchmarking.

Related

+3  A: 

If you're not using an ORM in PHP you should not use the SQLAlchemy ORM or SQL-Expression language either but use raw SQL commands. If you're using APC you should make sure that Python has write privileges to the folder your application is in, or that the .py files are precompiled.

Also if you're using the smarty cache consider enabling the Mako cache as well for fairness sake.

However there is a catch: the Python MySQL adapter is incredible bad. For the database connections you will probably notice either slow performance (if SQLAlchemy performs the unicode decoding for itself) or it leaks memory (if the MySQL adapter does that).

Both issues you don't have with PHP because there is no unicode support. So for total fairness you would have to disable unicode in the database connection (which however is an incredible bad idea).

So: there doesn't seem to be a fair way to compare PHP and Pylons :)

Armin Ronacher
Can you provide a reference to what you consider ‘incredibly bad’ about python-mysql (MySQLdb)? I've never had any issues with it (although I'm not usually using the built-in unicode support).
bobince
I briefly blogged about it and there are some comments on the page acknowledging the problems and one of the sun guys proposing a solution: http://lucumr.pocoo.org/2009/1/8/the-sad-state-of-mysql-python
Armin Ronacher
+2  A: 
  1. your PHP version is out of date, PHP has been in the 5.2.x area for awhile and while there are not massive improvements, there are enough changes that I would say to test anything older is an unfair comparison.

  2. PHP 5.3 is on the verge of becomming final and you should include that in your benchmarks as there are massive improvements to PHP 5.x as well as being the last version of 5.x, if you really want to split hairs PHP 6 is also in alpha/beta and that's a heavy overhaul also.

  3. Comparing totally different languages can be interesting but don't forget you are comparing apples to oranges, and the biggest bottleneck in any 2/3/N-Tier app is waiting on I/O. So the biggest factor is your database speed, comparing PHP vs Python VS ASP.Net purely on speed is pointless as all 3 of them will execute in less than 1 second but yet you can easily wait 2-3 seconds on your database query, depending on your hardware and what you are doing.

  4. If you are worried what is faster, you're taking the absolute wrong approach to choosing a platform. There are more important issues, such as (not in order):

    a. How easily can I find skilled devs in that platform

    b. How much do those skilled devs cost

    c. How much ROI does the language offer

    d. How feature rich is the language

TravisO
1-2: I really don't want to upgrade PHP, its running CentOS 4. But I will look into it. 4: This is more of a I'm just wondering.
Echo