Apache的mod_php,并且OR的FastCGI?这有利于字preSS? [英] Apache's mod_php OR FastCGI? Which is good for Wordpress?

查看:200
本文介绍了Apache的mod_php,并且OR的FastCGI?这有利于字preSS?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我对像mod_php的,CGI,FastCGI的等不同的配置运行PHP的基本理念。

在我的调查结果和试验,我发现FastCGI的稍微好一点。我喜欢的FastCGI的了suEXEC大多数的支持。等一下,我不想进入标杆企业在这里再次。如果你上网浏览,你会发现人们证明方法之一是在每秒处理的请求数量方面比另一种更快。那么其良好的指标,但我感兴趣的不同因素,这里是我的问题...


  1. 哪些运行PHP的方法消耗较少的内存?

  2. 此外哪种方法消耗内存几乎不变。我看到有300MB和800MB,每隔几秒钟之间mod_php,并且我的服务器内存使用率波动。

  3. 但是FastCGI的,从服务器中第一个响应来自很晚。我FastCGI的看到有在每个网页请求的初始延迟。一旦从服务器首先响应到达,其他项目,如图像,CSS,JS负荷pretty更快。

  4. 是否确定同时运行的组合?我有专门的服务器上的5个站点。它是确定,如果我跑几个与mod_php,并且和FastCGI的?休息

  5. 我相信我的服务器宕机,因为不当mod_php,并且内存使用量的下降居多。我检查了所有的脚本。有没有什么办法让服务器确保内存消耗保持几乎不变的?

  6. 的.htaccess是否复杂影响内存使用情况显著?如果是的话,它可以是一个单一的理由让服务器运行内存不足?

  7. 是否阿帕奇MPM prefork /工人设置会影响内存消耗?难道他们影响mod_php,并且和FastCGI模式一样?

  8. 当我运行顶命​​令,我看到阿帕奇(httpd的)消耗40MB左右的内存。还有的httpd运行多个实例。此外,在除了FastCGI的叉类似规模的一些过程。什么是httpd进程普通内存的大小?

  9. 当我运行在所有我们网站的话语preSS,这将是在这方面好办法?

  10. 是否FastCGI的/的SuExec正常工作与APC?我是否需要重新配置APC与suEXEC的和FastCGI工作。

请注意,我在对生存或DIGG流量高峰不感兴趣。我想一个办法,可以使服务器稳定,predictable。

很抱歉,如果我是混乱的,但我真的一塌糊涂。我有512MB的物理内存,400MB交换和我的服务器正在运行的内存像疯了似的。平均内存要求是350MB左右,它只是内存使用峰值使得几秒钟内存不可用,如果那几个第二个窗口中获得一些额外的命中,阿帕奇坠毁而MySQL和其他所有的小伙子们继续运行正常。

请帮我家伙。我不是要去购买更多的RAM或硬件。我该死的肯定问题出在我的配置。很抱歉,如果我听起来傲慢或​​无知的。


解决方案

  

哪种方法运行PHP的消耗更少的内存?


我认为每个PHP加工要求,他们或多或少是一样的。但是,如果你有mod_php,并且加载到apache的服务形象也一样,那么我想你的内存占用会更高,由于提供静态文件。


  

此外该方法消耗的内存几乎不变。我看到有300MB和800MB,每隔几秒钟之间mod_php,并且我的服务器内存使用率波动。


您可以使双方pretty不变。如果你仔细设置的MaxClients,而且比MinSpareServers MaxSpareServers的,你pretty多少可以告诉多少进程正在运行。如果你也是你的PHP配置中设置memory_limit的,你可以计算出你需要多少内存。
你可以做FCGI同样也是如此,因为你可以决定多少进程正在运行。


  

但随着FastCGI的,从服务器中第一个响应来自很晚。我FastCGI的看到有在每个网页请求的初始延迟。一旦从服务器首先响应到达,其他项目,如图像,CSS,JS负荷pretty更快。


这是没有意义的。我不知道为什么你的情况发生。


  

是否确定同时运行的组合?我有专门的服务器上的5个站点。它是确定,如果我跑几个与mod_php,并且和FastCGI的休息?


我猜,但它都将是维持一个恶梦,可能会更难配置的节省内存的。恰恰相反,我相信。


  

我相信我的服务器宕机,因为不当mod_php,并且内存使用量的下降居多。我检查了所有的脚本。有没有什么办法让服务器确保内存消耗保持几乎不变的?


配置内存和进程,因为我上文所述,并保持监控。


  

的.htaccess是否复杂影响内存使用情况显著?如果是的话,它可以是一个单一的理由让服务器运行内存不足?


我不这么认为。每目录的.htaccess可以慢下来,但如果没有在Apache中的一些严重的错误,它不应该造成大量的内存消耗。


  

请问apache的MPM prefork /工人设置会影响内存消耗?难道他们影响mod_php,并且和FastCGI模式一样?


这可能,但我建议远离工人了,因为PHP主要是不是线程安全的。


  

当我运行顶命​​令,我看到阿帕奇(httpd的)消耗40MB左右的内存。还有的httpd运行多个实例。此外,在除了FastCGI的叉类似规模的一些过程。什么是httpd进程普通内存的大小?


30MB是分钟。上限取决于您的应用程序(我所看到的情况下,这是1GB〜)


  

由于我对我们所有的网站,这将是在这方面很好的方式运行Word preSS?


这可能是一个口味问题。我最近搬到来自Apache逐渐远离的nginx + FastCGI的。它需要一点时间来适应,但它确实工作得很好。没有任何的问题用字preSS(即使不与supercache,这是相当复杂的Web服务器而言)。


  

请问FastCGI的/的SuExec正常工作与APC?我是否需要重新配置APC与suEXEC的和FastCGI工作。


我不使用suexec的,但用的FastCGI APC效果很好。无需任何配置。

I have basic idea about running PHP in different configurations like mod_php, cgi, FastCGI, etc.

In my findings and test I found FastCGI is slightly better. I like FastCGI's support for SuEXEC most. Wait I do not want to get into benchmarking business here again. If you surf web, you will find people proving one way is faster than another in terms of number of requests handled per second. Well its good metrics but I am interested in different factors and here are my questions...

  1. Which method of running PHP consumes less memory?
  2. Also which method consumes memory nearly constant. I see with mod_php my servers memory usage fluctuating between 300MB and 800MB, every few seconds.
  3. But with FastCGI, first response from server comes very late. I see with FastCGI there is an initial delay per webpage request. Once first response from server arrives, other items like images, css, js loads pretty faster.
  4. Is it OK to run mix of both? I have 5 sites on dedicated server. Is it ok if I run few with mod_php and rest with FastCGI?
  5. I am sure that my server goes down mostly because of improper memory usage by mod_php. I checked all scripts. Is there any way to make sure memory consumption on server remains nearly constant?
  6. Does complexity of .htaccess affects memory usage significantly? If yes, can it be a single reason to make server run out of memory?
  7. Does apache MPM prefork/worker settings affect memory consumption? Do they affect mod_php and FastCGI mode equally?
  8. When I run "top" command, I see apache (httpd) consuming memory around 40MB. There are many instances of httpd running. Also in addition to that FastCGI forks some processes of similar size. What is normal memory size for httpd process?
  9. As I am running Wordpress on all of our sites, which will be good way in that context?
  10. Does FastCGI/SuExec works fine with APC? Do I need to reconfigure APC to work with SuEXEC and FastCGI.

Please note, I am less interested in surviving against DIGG or traffic spikes. I want a way which can make server stable and predictable.

Sorry if I am confusing but I am really in mess. I have 512MB physical RAM, 400MB Swap and my server is running out of memory like crazy. Average memory requirement is around 350MB, it just memory usage spikes makes memory unavailable for few seconds and if few extra hits received in those few second window, apache crashed while mysql and all other fellas keep running fine.

Please help me out guys. I am not gonna buy more RAM or hardware. I am damn sure that problem is in my configuration. Sorry if I sound arrogant or ignorant.

解决方案

Which method of running PHP consumes less memory?

I assume that per PHP-processed request they are more or less the same. But if you have mod_php loaded into apache serving images too, then I assume your memory footprint will be higher due to serving static files.

Also which method consumes memory nearly constant. I see with mod_php my servers memory usage fluctuating between 300MB and 800MB, every few seconds.

You can make both pretty constant. If you carefully set MaxClients, MinSpareServers and MaxSpareServers, you pretty much can tell how many processes are running. If you also set memory_limit within your PHP config, you can calculate how much memory you need. You can do the same for fcgi too, since you can decide how many processes are running.

But with FastCGI, first response from server comes very late. I see with FastCGI there is an initial delay per webpage request. Once first response from server arrives, other items like images, css, js loads pretty faster.

This doesn't make sense. I am not sure why it happens in your case.

Is it OK to run mix of both? I have 5 sites on dedicated server. Is it ok if I run few with mod_php and rest with FastCGI?

I guess, but it will both be a nightmare to maintain and will probably be harder to configure for saving memory. Quite the contrary I believe.

I am sure that my server goes down mostly because of improper memory usage by mod_php. I checked all scripts. Is there any way to make sure memory consumption on server remains nearly constant?

Configure memory and processes as I outlined above, and keep monitoring.

Does complexity of .htaccess affects memory usage significantly? If yes, can it be a single reason to make server run out of memory?

I don't think so. per-directory .htaccess can slow things down, but unless there is some serious bug in Apache, it should not cause mass memory consumption.

Does apache MPM prefork/worker settings affect memory consumption? Do they affect mod_php and FastCGI mode equally?

It might, but I recommend to stay away from worker, as PHP is mostly not thread safe.

When I run "top" command, I see apache (httpd) consuming memory around 40MB. There are many instances of httpd running. Also in addition to that FastCGI forks some processes of similar size. What is normal memory size for httpd process?

30MB is the min. The upper limit depends on your application (I have seen cases where it was ~1GB)

As I am running Wordpress on all of our sites, which will be good way in that context?

It is probably a matter of taste. I have recently moved away from apache towards nginx+fastcgi. it takes a bit of time to get used to, but it does work well. No problems whatsoever with wordpress (even not with supercache, which is rather involved in terms of web server).

Does FastCGI/SuExec works fine with APC? Do I need to reconfigure APC to work with SuEXEC and FastCGI.

I am not using suExec, but fastcgi works well with APC. No need to configure anything.

这篇关于Apache的mod_php,并且OR的FastCGI?这有利于字preSS?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆