Hacker News new | past | comments | ask | show | jobs | submit login

Although I liked seeing your article there is an additional factor you are not taking into account. PHP is not a webserver.

You should think about settings in php and other major services that are running on the server such as Apache, your chosen database, your OS.

Let's say you are running Apache, your php memory limit depends on which Apache MPM handler you are using. So let's say your client had 1GB of ram on the server, but you were running the Apache MPM handler "Prefork". Prefork does not support multithreading which most common cpu's run in these days. Additional Prefork actually takes into account what the php memory limit is set at and it likes to reserve this amount of memory so that php processes can be executed. So although php does not lock up the php memory. The Prefork handler does.

Prefork likes to also perform whats called a one-to-one execution. So the php script is executed and it locks up one Apache slot. So this also depends on what you have set your MaxClients value to in your httpd.conf.

If you set your MaxClients in Apache on Prefork to 50... you have 50 available slots, but let's say you set your php memory limit to 256M. That means with 4 different requests to your site, Prefork has now allocated and locked up all your ram on your server, even if your individual scripts do not need it.

Keep in mind these processes get executed very quickly so those slots get freed fairly quickly, however it all depends on your Apache MPM handler.

If you switch your Apache MPM handler to event, the memory limit no longer comes into play as Event can handle multithreading as well as for every php process that is spawned and locked to an apache slot, it can spawn 10,000 child processes from the same slot.

I feel like your clients webhost was probably correct in their assessment and you should really factor in other elements that hold control over how php reacts. Great article though :)

Wth mpm_event (which is the better choice) php is still not multi-threaded. As in this case the limit was per script as per the way php is designed to work.

Anyone still using prefork/mod_php ...well that's cute.

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact