gpt4 book ai didi

apache2 - Tornado 是 "a relatively simple, non-blocking web server framework written in Python"-- 可以稍微解释一下这是什么意思吗?

转载 作者:行者123 更新时间:2023-12-03 13:35:25 24 4
gpt4 key购买 nike

这可能是一个愚蠢的问题,但究竟什么是“非阻塞 Web 服务器”?所有的 Web 服务器在技术上都是非阻塞的,不是吗?否则他们如何处理同时连接? Apache2 使用 fork() 和 pthreads 的组合来实现这一点。 Tornado(和 Twisted)到底有什么不同?他们是否只是将一堆套接字设置为非阻塞模式,构建一个 FD 列表(或等效的),然后用一个大的 select() 系统调用循环它?

你会在哪里使用这样的框架,与 Apache2(或其他流行的服务器)相比,它们能给你带来什么优势?谢谢

最佳答案

这个article on EventMachine也可能给你一个提示:

Steeped in the tradition of forking / threaded web-servers I found myself rather surprised when I joined one of the research projects at University of Waterloo a couple of years back: we were benchmarking different web-server architectures, and top performers were all event-driven servers.

As I pestered everyone with questions, I quickly realized why - in an environment with hundreds of thousands requests a second, forking and context switching associated with thread management become prohibitively expensive (fork is worst performer, as it does a memory copy on the parent process every time). Whereas by comparison, a tight and highly optimized event-loop really shines when it comes to performance under heavy loads.

关于apache2 - Tornado 是 "a relatively simple, non-blocking web server framework written in Python"-- 可以稍微解释一下这是什么意思吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1419624/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com