Apache 和 c10k
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/619595/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Apache and the c10k
提问by Robert Gould
How is Apache in respect to handling the c10k problemunder normal conditions ? Say while running very small scripts with little data, or do I need to scale out if I use Apache?
Apache 在正常情况下如何处理c10k 问题?假设在运行数据很少的非常小的脚本时,或者如果我使用 Apache 是否需要横向扩展?
In the background heavy lifting is done by a few servers running specialized software that processes the requests but I'd like to use Apache as a front. Is this a viable plan?
在后台,繁重的工作由几台运行专门处理请求的软件的服务器完成,但我想使用 Apache 作为前端。这是一个可行的计划吗?
回答by Alister Bulman
I consider Apache to be more of an origin server - running something like mod_php or mod_perl to generate the content and being smart about routing to the appropriate system.
我认为 Apache 更像是一个原始服务器 - 运行 mod_php 或 mod_perl 之类的东西来生成内容并聪明地路由到适当的系统。
If you are getting thousands of concurrent hits to the front of your site, with a mix of types of data (static and dynamic) being returned, you may find it useful to put a more optimised system in front of it though.
如果您的网站前端有数千个并发点击,并且返回了混合类型的数据(静态和动态),您可能会发现在其前端放置一个更优化的系统很有用。
The classic post-optimisation problem with Apache isn't generating the dynamic content (or at least, that can be optimised for early in the process), but simply waiting for a slow client to be able to receive the bytes that are being sent. It can therefore be a significant advantage to put a reverse proxy, in the form of Squid or Nginx, in front of the servers to take over the 'spoon-feeding' of the slow network clients, while allowing the content production to happen at full speed, and at local network speeds - 100Mb/sec or even gigabit speeds - if it even has to traverse a network at all.
Apache 的经典后优化问题不是生成动态内容(或者至少可以在过程的早期进行优化),而只是等待慢速客户端能够接收正在发送的字节。因此,将 Squid 或 Nginx 形式的反向代理放在服务器前面以接管慢速网络客户端的“勺子馈送”可能是一个显着的优势,同时允许内容生产完全发生速度,并以本地网络速度 - 100Mb/sec 甚至千兆速度 - 如果它甚至必须穿越网络。
回答by MarkusQ
回答by GioMac
Guys, imagine that you are running web server with 10K connections (simultaneous). How could it be?
伙计们,假设您正在运行具有 10K 连接(同时)的 Web 服务器。怎么会这样?
You've got many many connections per second
Dynamic content
Are you sure that your CPU can handle that many PHP sessions for example? I guess no, so why are you thinking about C10K problem? :D
Static content - small files
And still soo many connections? On single server? Probably you've got problems with networking/throughput too or you are future competitor of Google. Use lighttpd which addresses C10K problem and is stable - fly light. Using Apache for only static files for large sites is obvious.
Your clients are downloading large files for a large time - static content
ISO images, archives etc
If you are doing it via web server - FTP may be more appropriate.
Video streaming
Use lighttpd or specialized software. And still... What about other resources?
你每秒有很多很多连接
动态内容
例如,您确定您的 CPU 可以处理那么多 PHP 会话吗?我猜不是,那你为什么要考虑 C10K 问题?:D
静态内容 - 小文件
还有这么多联系?在单台服务器上?可能您也遇到了网络/吞吐量问题,或者您是 Google 未来的竞争对手。使用可以解决 C10K 问题并且稳定的 lighttpd - fly light。将 Apache 仅用于大型站点的静态文件是显而易见的。
您的客户长时间下载大文件 - 静态内容
ISO 映像、档案等
如果您是通过 Web 服务器进行的 - FTP 可能更合适。
视频流
使用 lighttpd 或专门的软件。还有……其他资源呢?
I am using Linux Virtual Server as load balancer in front of apache servers (with specific patches for LVS-NAT) and I am happy :) This string is an answer you want to hear.
我在 apache 服务器(带有 LVS-NAT 的特定补丁)前使用 Linux 虚拟服务器作为负载平衡器,我很高兴 :) 这个字符串是你想听到的答案。

