PHP Jquery:聊天系统,理想的框架是什么?

发布于 2024-12-03 01:27:58 字数 440 浏览 1 评论 0原文

我想为我的网站实现一个聊天系统。该功能将与 Facebook 聊天非常相似。聊天将是一对一的。

我知道如何使用 PHP、MySql 和 JQuery 构建聊天系统。但我担心的是,从长远来看,它不会扩展到大量用户。

使用 JQuery,我会每秒发出请求以保持聊天窗口更新,或者如果用户正在发送与其他用户聊天的请求。这将导致服务器上的额外负载,因为用户群会随着时间的推移而增加。

我被告知使用 PHP 这不是一个理想的解决方案,我应该研究彗星编程,这是我以前从未尝试过的。

我的问题是,是否有我可以使用的预构建框架,或者更好的构建方法?

我听说过 NodeJs 和 APE,但我的服务器不支持这些。

谢谢你们。

编辑:在与我的服务器人员交谈后,我可能会更改我的操作系统,以便我可以运行 NodeJS。 Nodejs 在可扩展性方面有多好,它能满足我的需求吗?

I want to implement a chat system for my site. The functionality will be very similar to facebook chat. The chats will be one to one based.

I know how to build the chat system using PHP, MySql and using JQuery. But my concern is that it won’t scale to large number of users in the long term.

Using JQuery I would be making requests every second to keep the chat window updated or if the user is sending a request to chat with another user. This will cause extra load on the server as the user base will increase overtime.

I’ve been told using PHP for this is not a ideal solution, that I should look into comet programming, which I never tried before.

My question is that are there any pre-build frameworks out there that I could use, or a better approach of building it?

I heard of NodeJs and APE but these are not supported by my server.

Thanks guys.

EDIT: after having word with my server guys, i might change my OS so i can run NodeJS.
How good is nodejs is term of scalability and will it meet my needs?

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

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

发布评论

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

评论(2

谜兔 2024-12-10 01:27:58

PHP 和 Comet 并不相互排斥。 Comet 只是一种服务器推送技术,因此您不必每秒轮询。你用 PHP 和 PHP 实现 Comet; JS,它不是一种单独的编程语言。

尽管:我不建议您自己编写聊天程序,除非您需要非常具体的功能。耗时并且容易出错. 使用预制解决方案之一,例如:

http://www.phpfreechat.net/< /a>

或 java IRC 聊天室。谷歌了解更多。

PHP and Comet are not mutually exclusive. Comet is just a technique of server push, so you don't have to poll ever second. You implement Comet in PHP & JS, it is not a separate programming language.

Although: I DO NOT recommend programming chat on your own, unless you need very specific features. It is time consuming and error prone. Use one of the pre-made solution, for example:

http://www.phpfreechat.net/

or java IRC chatroom. Google for more.

等风也等你 2024-12-10 01:27:58

正如 Rok Kralj 所说,Comet 是一种范例,可以应用于不同的技术。 PHP 和 PHP如果您想研究这个问题,Comet 问题是一个很好的起点。

人们普遍认为 PHP 作为一种实时技术的扩展性不太好。 Facebook,他们是 PHP 之家(尽管最终将他们的 PHP 编译为 C(或者可能是 C++) )以提高效率)。最常见的解决方案是使用专用的实时技术进行实时通信并将其保留在您的网络服务器之外。

在技​​术选择方面,我会考虑 WebSockets,因为它们已经成为实时的标准双向通信。一些“Comet”服务器也使用 WebSockets 作为传输,并回退到效率较低的 HTTP 流或旧浏览器的 HTTP 长轮询。

如果您考虑使用托管服务,并且不想只局限于聊天功能,希望在某个时候将实时通知、视觉协作或游戏添加到您的应用程序中,那么http://pusher.com我工作的公司提供托管实时消息传递服务,您可以轻松地实现聊天功能。

As Rok Kralj says Comet is a paradigm and can be applied to different technologies. The PHP & Comet question is a good place to start if you want to look into this.

It tends to be commonly agreed that PHP doesn't scale too well as a realtime technology. Facebook, who are a PHP house (although ended up compiling their PHP down to C (or maybe C++) for efficiency). The most common solution is to use dedicated realtime technology for your realtime communication and keep this outside of your web server.

In terms of technology choice I would consider WebSockets since they have become the standard for realtime bi-directional communication. Some 'Comet' servers use WebSockets as a transport too and fallback to the less efficient HTTP Streaming or HTTP Long-Polling for older browsers.

If you'd consider using a hosted service, and don't want to be tied to just chat functionality, would like realtime notifications, visual collaboration or gaming to be added to your app at some point, then http://pusher.com, who I work for, offer a hosted realtime messaging service which you can easily implement your chat functionality.

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