大网数据广告活动
服务器运维问答

Scaling Apache/PHP is as simple as maximizing the number of CPU cores?

· 52CE 我爱测

I have an Linux/Debian server with Intel i7 CPU with 4 cores and 8 threads. When I run my heavy duty Apache/PHP job it uses 1 thread, and when I run concurrent Apache/PHP jobs they each use their own thread. So, if I want to be p…

问题原文

原帖链接 · TheStoryCoder · CC BY-SA 4.0

I have an Linux/Debian server with Intel i7 CPU with 4 cores and 8 threads. When I run my heavy duty Apache/PHP job it uses 1 thread, and when I run concurrent Apache/PHP jobs they each use their own thread.

So, if I want to be prepared for high traffic, is it simply a matter of maximizing the number of cores (by choosing other CPUs) to be able to handle more concurrent jobs, provided it has enough memory and that the database/filesystem doesn't pose extra challenges?

I have tried running 8 and 10 jobs concurrently and it used all threads and CPU utilization was mostly 100% (but ran flawlessly), so it seems like the theory is not completely off - but is there something else that could bust this linear thinking?

Alternatively I could go with a load balanced system with multiple servers but I wonder how far I can get with a single server.

PS. Apache/PHP is using mod_php with thread safety disabled, therefore it uses Prefork MPM. Not sure I dare use Worker MPM as I'm uncertain about thread safety...

PSS. Also, I'm not necessarily looking for better performance, mainly just be able to handle higher traffic/more concurrent jobs.

已采纳解答

原帖链接 · Kai Petzke · CC BY-SA 4.0

From what you describe (100% CPU utilization), your application seems CPU bound. So adding more CPU cores or moving to a machine with faster cores will likely improve your performance.

Many cloud providers charge you only a few cents each hour to rent powerful virtual machines with many CPU cores and lots of RAM. Just go ahead and test on 16 or 32 cores to find out, how your performance scales with number of CPUs/cores.

And yes, I recommend increasing the number of cores in your system, first, before you increase the number of systems.

摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。

资料来源与适用范围

资料来源
Server Fault
适用范围
以原帖系统、软件版本与发布日期为准(2018-09-21)
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY-SA 4.0

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。