Rasmus Lerdorf at OSCON: Getting Rich with PHP 5
Rasmus Lerdorf gave a great talk at OSCON titled Getting Rich with PHP 5. From the title, I was expecting yet another session on how to build the next great “social networking, tagging, photo sharing, podcasting, blogging, insert-latest-fad-here”. Not that there’s anything wrong with those type sessions but honestly, I like sessions with a bit of depth to them. I was presently surprised when Rasmus threw us into the deep end.
Rasmus’ 3 point plan to get rich?
- Build tagged, socially networked, Web 2.0ish, Ajaxy thing
- Get 500,000 users quickly (and have it actually work)
- Profit
First, the sample application. He showed us a simple news site that pulls stories from a database and displays them. Rasmus showed that for this simple application, 500,00 users translated into ~1,700 requests per second. Using http_load, he shows that the code actually execute 17 requests per second and that it will take approximately 100 servers to service your 500,000 users.
From there he showed several tweaks to speed things up. Using callgrind to map out what is going on and KCachegrind he is able to identify bottlenecks and display exactly what is going on in the process of displaying a page. Turning off ssl connections in the PostgreSQL 8.1 database as well as persistent connections make a huge difference. Switching to MySQL and turning on PDO::ATTR_EMULATE_PREPARES brings us even closer to our goal of 1,700 requests per second. Dropping in APC and properly tweaking it gives further performance gains. Finally, taking a look at the include files and making sure they are all needed gives the final boost.
All told, Rasmus was able to take his small application from 17 requests per second to an astounding 1,100 requests per second while reducing the latency dramatically.
It was one of the best sessions I attended at OSCON. If you are currently struggling with optimizing a PHP application This is a great session for you to review. Rasums published the slides on php.net. Niall Kennedy has also posted a great review of the session on his blog. He was on the front row of the session and has published an audio recording of the session to go along with the slides.
=C=

Comments