duanmengmiezen8855 2014-11-29 09:41
浏览 133

nginx php-fpm缓存每秒多次请求

I'm having the following situation:

An auction website where all users connected make a ajax request to the server every 2 seconds.

The data changes every 2 seconds so it cannot be cached for a long duration so I was wondering.

What would be the best way to accomplish this:

If I have 200 request in the same second, serve them the same response instead of running again php and connecting to mysql to get results.

So I don't know if this could be done with such a small duration of cache of 1 second, also I don't know what would be better to use, something on Nginx side, or something on PHP side such as APC.

Any ideas? does it make sense?

My problem is that I've tried to tweak Nginx and php-fpm and right now it can handle 200 requests/s at 2000ms response time, at 500requests/s is about 5000ms so I'm looking for a way to speed things up and handle as much requests per second as possible.

Update:
The website is running on Symfony2 so any suggestions related to it are also welcome.

Update 2!!!
I have moved the part of the application that handled the ajax request into a single php file without using the Symfony2 framework. It does 3 sql queries and returns json response. Now it can handle 1000+ requests at 150ms/second, it's really incredible.. I guess Symfony2 really needs tweaks to be able to do the same and I guess the problem was not php but all the memory used by the framework.

  • 写回答

1条回答 默认 最新

  • douli7841 2014-11-29 17:08
    关注

    Vanilla PHP is of course faster than any PHP framework but maintaining dozens of such scripts is painful. You can stick with Symfony and use Varnish to handle the heavy load. Cache TTL can be as low as 1 second and with Varnish you can handle thousands of requests.

    评论

报告相同问题?

悬赏问题

  • ¥15 RPA正常跑,cmd输入cookies跑不出来
  • ¥15 求帮我调试一下freefem代码
  • ¥15 matlab代码解决,怎么运行
  • ¥15 R语言Rstudio突然无法启动
  • ¥15 关于#matlab#的问题:提取2个图像的变量作为另外一个图像像元的移动量,计算新的位置创建新的图像并提取第二个图像的变量到新的图像
  • ¥15 改算法,照着压缩包里边,参考其他代码封装的格式 写到main函数里
  • ¥15 用windows做服务的同志有吗
  • ¥60 求一个简单的网页(标签-安全|关键词-上传)
  • ¥35 lstm时间序列共享单车预测,loss值优化,参数优化算法
  • ¥15 Python中的request,如何使用ssr节点,通过代理requests网页。本人在泰国,需要用大陆ip才能玩网页游戏,合法合规。