I want to clarify how php and apache work together. If I had an 10GB RAM app server with apache and php, and MySQL on its own dedicated server, how do I determine the maxclients. If I understand correctly, if I set the max_memory in the php.ini to say 128M, and maxclients = 200, there is the potential to try and consume 25GB of memory. Plus, if Apache uses 20M per process, that's another 4GB, so the potential is around 29GB. I know that it is unlikely that all php scripts would use all 128M, so I'm wondering what is a good rule of thumb to start with. Should I reserve 20% of the server for other processes, like on a MySQL server, then set aside a reasonable amount of RAM for php, say 1GB, and then divide the rest by say 20MB for maxclients?
Thank you,
Sean
Comments
More workers means more
More workers means more parallelism which means more likelihood of utilizing all available cores.
More workers also means more potential memory use. (memory limit * workers)
Memory limit should be as low as you can get away with (this requires real-world testing). Number of workers should generally be as high as memory limit * workers lets you get away with (there's unfortunately not easy math to do for this, as system available memory varies, and the memory use of a web worker isn't exactly equal to php's set limit. It requires real-world testing). However, too many workers can also be ineffective (as parallelism != concurrency and more memory used by web workers = less memory available for other things (SQL db, disk caches, etc.) which might have better impact on site performance. So it, again, requires real-world testing).
Make sure that innodb_buffer_pool size is larger than your database (if your database is small enough that that is possible). Make sure that if your site doesn't need to be ACID that innodb_flush_log_at_trx_commit != 1. Make sure that PHP memory limit is large enough that all use cases are covered (generally generating derivative images) but not too large. Make sure your APC cache is on, and has enough space that it rarely misses. Make sure that the number of workers is at least as many as you have CPU cores, experiment with more. Many of these variables (buffer pool, web workers, APC size) will respond favorably to using more memory, of which your supply is limited, make sure you don't end up swapping; no matter how many ms you saved by changing any of this stuff, if a web worker swapped to disk you're going to pay them back.