问题描述
我需要帮助,了解使用非同步架构的优势是什么。假设我想开发一个简单的聊天Web应用程序。为什么不能我写在Django框架,做长轮询,我不直到有人进入一个新的味精发送回一个响应的服务器蟒蛇code。这是什么扭曲的提供给它的实时应用程序,如聊天应用的优势在哪里?
I need help understanding what the advantage of using an asynch framework is. Suppose I want to develop a simple chat web app. Why cant I write python code in the Django framework that does long polling where I dont send a response back the server until someone enters a new msg. What does Twisted provide that gives it an advantage for real-time apps like the chat app?
对不起,我显然有必要进行异步框架有点糊涂了。
Sorry I am obviously little confused about the need for an asynchronous framework.
推荐答案
异步服务器支持更大的客户端同时连接数。更传统的服务器遇到了线程和进程限制服务大量并发用户,尤其是那些长期连接的时候。因为他们避免了如管理费用异步服务器也可以提供更好的性能线程上下文切换。
Asynchronous servers support much larger numbers of simultaneous client connections. More conventional servers come up against thread and process limits when servicing large number of concurrent clients, particularly those with long-lived connections. Async servers can also provide better performance as they avoid the overheads of e.g. thread context switching.
还有扭曲
框架,也有在Python的标准库异步服务器构建模块:previously asyncore
和 asynchat
,但现在还 ASYNCIO
。
As well as the Twisted
framework, there are also asynchronous server building blocks in Python's standard library: previously asyncore
and asynchat
, but now also asyncio
.
这篇关于双绞线(非同步服务器)与Django的(或任何其他框架)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!