可扩展 PHP(基于 AJAX)聊天系统的最佳方法

发布于 2024-08-25 08:19:28 字数 251 浏览 4 评论 0原文

我正在为一家公司构建一个聊天系统,我想知道构建该系统的最佳方法是什么?

我们当前的设置是一个带有 PHP 和 Memcacheq 的 Nginx HTTP 服务器(作为将聊天消息附加到用户自己的队列的消息队列)。然后,我们轮询 Nginx 服务器(通过 Comet 样式请求)并查询消息队列以获取更新。

使用消息队列(例如 Memcacheq)来处理同时具有用户对用户和站点范围聊天的聊天系统是一个好主意还是最好只使用 MySQL?

谢谢!

I'm building a chat system for a company and I'm wondering as to what the best way to build the system would be?

The current setup we have is a Nginx HTTP Server with PHP and Memcacheq (as a message queue that appends the chat messages to the user's own queue). We then poll the Nginx server (through a Comet style request) and query the message queue for updates.

Is it a good idea to use a message queue such as Memcacheq to handle a chat system that has both user-to-user and site-wide chat or is it best to just stick to MySQL?

Thanks!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

请远离我 2024-09-01 08:19:29

试试这个: http://pushmodule.slact.net/ 。 Nginx 会处理 comet 的事情,你的 php 应用程序需要做的就是向模块发送 HTTP 请求。

Try this: http://pushmodule.slact.net/ . Nginx will take care of the comet stuff, and all your php application will need to do is send HTTP requests to the module.

双马尾 2024-09-01 08:19:28

Memcache 仅在数据有些陈旧(或数据库设计不佳导致查询执行时间增加)时才有用。在您的情况(聊天系统)中,数据将是新鲜的,据我所知,添加 Memcache 只会使事情变得复杂(读取性能降低)。将 memcache 视为 mysql 和 php 之间的中间件(在 RAM 上)。如果数据过时,则行程时间会减少,因为 PHP 不必访问 mysql,但如果有新数据,负载实际上会增加(因为 memcache 也需要从 PHP 获取更改)。

总之,我不建议在聊天系统中使用 memcache。建议多上网搜索一下。一篇好文章,位于 http://blog.tech.stylefeeder .com/2008/08/22/memcached-vs-mysql/

Memcache is only useful when you have somewhat stale data (or bad database design to increase query execution time). In your case (chat system), the data would be fresh and adding Memcache can only complicate (read decrease performance) things as far as I can see. Think of memcache as a middle ware (on RAM) between mysql and php. If the data is stale the trip time is reduced as PHP does not have to go to mysql but in case of fresh data the load will actually increase (since memcache will also need to fetch the changes from PHP).

In summary, I would not recommend using memcache for a chat system. Would recommend to search the web more. A good post at http://blog.tech.stylefeeder.com/2008/08/22/memcached-vs-mysql/

孤独患者 2024-09-01 08:19:28

我希望 Memcacheq 的性能比 MySQL 好得多。

I would expect Memcacheq to perform much better than MySQL.

椵侞 2024-09-01 08:19:28

Memcacheq 是一个很棒的工具,可以帮助避免 Web 请求的延迟。
它可以充当php和mysql之间的缓冲区,但它并不能替代mysql。 Memcacheq 还可以使扩展更容易,因为可能存在多个分布式消息消费者。

我建议将其放在高负载的 php 请求之间,将数据保存到 mysql 并执行耗时的操作。这将加快用户的页面加载速度,并将您的网络服务器从长请求中解放出来。

Memcacheq 相当快。不会占用太多资源

Memcacheq is a great tool which can help to avoid latency of web requsts.
It can act as a buffer between php and mysql, but it's not a replacement of mysql. Memcacheq can also make scaling easier, cause there maybe multiple distributed message consumers.

I'd recommend to put it in between high loaded php requests saving data to mysql and doing time consuming operations. This wil speed up page loading for users and will free your webservers from long requests.

Memcacheq is pretty fast. It will not take much resourses

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文