douou8954 2015-03-26 13:27
浏览 201

Nginx + PHP-FPM缓慢,并发更多的并发AJAX请求

I switched from common LAMP stack (Linux+Apache+MySQL+PHP) to nginx + PHP-FPM mostly because of the speed. The speed increase is incredible - not measured but it looks like for a project using both Zend (old libraries) and Zend 2 (new apps) for backend and Bootstrap + CoffeeScript + Backbone.js on the frontend the site renders 2 to 3 times faster!

The only drawback is for pages on which too many concurrent AJAX requests are called. Most of the times one page calls up to 5 different AJAX requests to load data on render but few of them require even 10 to 20 concurrent requests. In this case the rendering is slowed down 2 to 4 times when compared to rendering on Apache (comparison could now be done only on two different servers while the one running Apache is older and overall slower - but it can render pages with many concurrent AJAX requests much quicker).

This is my PHP-FPM configuration (regarding the pool manager):

pm = dynamic
pm.max_children = 20
pm.start_servers = 3
pm.min_spare_servers = 2
pm.max_spare_servers = 4

Increasing pm.max_children to 40 doesn't seem to have any influence on the speed though after changing from the default value 5 to current 20 I could see some speed increase.

I have also increased the worker_processes for nginx to value 4 (number of the cores) while keeping the worker_connections on the default 1024 value.

Is there anything else I should change in order to make the pages with more concurrent AJAX requests running much faster?

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 如何将下列的“无限压缩存储器”设计出来
    • ¥15 下图接收小电路,谁知道原理
    • ¥15 装 pytorch 的时候出了好多问题,遇到这种情况怎么处理?
    • ¥20 IOS游览器某宝手机网页版自动立即购买JavaScript脚本
    • ¥15 手机接入宽带网线,如何释放宽带全部速度
    • ¥30 关于#r语言#的问题:如何对R语言中mfgarch包中构建的garch-midas模型进行样本内长期波动率预测和样本外长期波动率预测
    • ¥15 ETLCloud 处理json多层级问题
    • ¥15 matlab中使用gurobi时报错
    • ¥15 这个主板怎么能扩出一两个sata口
    • ¥15 不是,这到底错哪儿了😭