多个请求的最佳 http 服务器解决方案 + PHP解释
我目前正在开发一项服务,该服务允许用户在他们的网站上放置一个将从我的http服务器加载的脚本文件(javascript),因为我可以期望处理大量的http请求。另外,javascript 文件是使用 php 生成的(它必须是动态的,我无法更改它 - 所以我使用 php 来生成它)。
由于我的一些客户的网站可能每天有 50-60k 访问者,因此我预计每天至少有 1-200 万个请求。
那么..回到我的问题。 显然我不能使用 Apache httpd(MPM prefork 模块)+ php,因为每个进程占用大约 17-18 MB RAM,而我的 ram 不是无限的。
到目前为止,Apache httpd(MPM 工作模块)+ php 工作得不是很好,因为它仍然不确定 php 是否是线程安全的,即使他们声称它是线程安全的(搜索 google 以查看更多信息)。
所以..我正在考虑使用:
- httpd(MPM工作模块)+ php + fastcgi 或者
- nginx + php +factscgi
坦白说,我听说 nginx 对于静态页面很有用,这就是为什么我想问你 php + fascgi 在处理大量请求时是否可以正常工作。我是否会遇到与使用 apache httpd 相同的内存问题,但这次内存将由 fastcgi 生成?
你认为我应该选择什么:1还是2?或者你还有其他解决方案吗?
谢谢
I'm currently working on a service that will allow users to put on their sites a script file(javascript) that is going to be load from my http server, there for I can expect to handle a lot of http requests. Also the javascript file is generated using php(it has to be dynamically and I can't change that - so I use php to generate it).
Since some of my customers will probably have sites with 50-60k visitors/day I can expect to have at least 1-2 million requests/day.
So.. back to my question.
Obviously I can't use Apache httpd (MPM prefork module) + php since every process eats around 17-18 MB RAM and my ram is not unlimited.
So far Apache httpd(MPM worker module) + php is not working very well because it still undetermined if php is thread-safe or not, even if they claim that it is(search google to see more info).
So.. I was thinking of using:
- httpd(MPM worker module) + php + fastcgi
or - nginx + php + factscgi
To be frank I've heard that nginx is good for static pages, that's why I want to ask you if is working ok with php + fascgi on large amount of requests. Whould I have the same memory problem like using apache httpd but this time the memory will be made by fastcgi?
What do you think I should choose: 1 or 2? or do you have other solutions?
Thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您应该做的第一件事是对服务器进行基准测试。
第二件事是检查你的瓶颈是什么(php、数据库、CPU 使用率、内存、磁盘访问等),这样你就知道要做什么。
然后你就可以费心去寻找问题的解决方案了。如果主要是 php,您是否使用一些缓存并且配置良好?如果这是你的数据库,你能改变它的架构以获得更好的东西吗?如果是您的服务器,请检查具有更好设置的 nginx、lighttpd 或 apache 或它们的组合是否可以完成这项工作。
The first thing you should do is benchmark your server.
The second thing is to check what your bottlenecks are (php, database, CPU usage, memory, disk access etc.) so you know what to work on.
Then you can bother trying to find solutions to your problems. If it's mainly php, do you use some cache and is it well configured ? If it's your database, can you change its architecture to have something better. If it's your server, check if nginx, lighttpd or apache with better settings or a combination of them can do the job.