gpt4 book ai didi

django - 使用 django 开发实时应用程序

转载 作者:行者123 更新时间:2023-12-02 11:44:51 24 4
gpt4 key购买 nike

我已经研究这个问题了一两天了。我正在开发一个实时应用程序(聊天和视频聊天)。我正在使用 django/apache 组合,我知道它不适合这个(至少 apache 部分)。

在这方面,我在 stackoverflow 中找到了几个链接,例如 http://www.skitoy.com/p/django-tornado-chat/305以及一些比较,例如 http://nichol.as/asynchronous-servers-in-python 处的比较

我的问题是。从事过 django 实时应用程序工作的人可以让我知道我应该使用什么框架吗?看来我可以在tornado上使用django,也可以在twisted框架上使用django。我是实时应用程序的新手,只需要指针,这样我就可以节省一些时间。

最佳答案

做过类似事情的人提供了更多提示:
http://eflorenzano.com/blog/post/technology-behind-convore/

更新 2023-05-04

此问答已有 12 年历史。上面链接的文章已经死了(Convore 本身 AFAICT 也是如此),但可以在以下位置找到:https://web.archive.org/web/20120819142511/http://eflorenzano.com/blog/2011/02/16/technology-behind-convore

我应该在我原来的答案中发布它的摘录。

...the first question developers tend to ask when they find Convore is "what technology powers this site?

嗯,12 年后我问的第一个问题是“Convore 是什么?”

它似乎是一个“托管 IRC”平台,即 Slack 或 Discord 之类的平台:https://www.ycombinator.com/companies/convore

Convore is an online platform that enables its users to communicate with groups in real time. Its users have the ability to join an existing group or create groups of their own.Convore allows its users to post topics and have conversations with friends about those topics. The platform also provides its users with both public and private groups.

好的,回到原来的博文:

All of our application code is powered by Python. Our front-end html page generation is done by Django, which we use in a surprisingly traditional way given the real-time nature of Convore as a product.

All of the important data is canonically stored in PostgreSQL, including messages, topics, groups, unread counts, and user profiles. Search functionality is provided by Solr, which is interfaced into our application by way of the handy Haystack Django application

When a new message comes into the system ... a task is sent to Celery (by way of Redis) notifying it that this new message has been received ... then it publishes to a Redis pub/sub for the group that the message was posted to.

Our live updates endpoint is actually a very simple and lightweight pure-WSGI Python application, hosted using Eventlet. It spawns off a coroutine for each request, and in that coroutine, it looks up all the groups that a user is a member of, and then opens a connection to Redis subscribing to all of those channels. Each of these Eventlet-hosted Python applications has the ability to host hundreds-to-thousands of open connections, and we run several instances on each of our front-end machines. It has a few more responsibilities, like marking a topic as read before it returns a response, but the most important thing is to be a bridge between the user and Redis pub/sub.

这个基本架构在今天仍然具有现实意义。

对于 Solr,我们可能会考虑 ElasticSearch。我们可能会使用 Python 3 异步功能,而不是 Eventlet(另请参阅 Gevent)。

此外,Django 本身现在通过“Channels”支持实时功能:

https://channels.readthedocs.io/en/stable/

Channels is a project that takes Django and extends its abilities beyond HTTP - to handle WebSockets, chat protocols, IoT protocols, and more. It’s built on a Python specification called ASGI.

关于django - 使用 django 开发实时应用程序,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7732069/

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