高级聊天网络应用程序
我正在寻求实现类似于 facebook/gmail 聊天的功能。 我知道他们使用 comet & jabber 作为他们的技术。 但我对几件事感到困惑。
我真的需要 jabber 吗? 我可以使用带有 from、to、message、sent 和 recd 的简单 mysql 表吗? 使用mysql有没有效率低下的地方? 有性能损失吗?
Comet 可以使用常规网络服务器来实现吗? 我需要一些特殊的服务器吗? AFAIK,apache+php 无法处理太多打开的连接? 我应该使用简单的轮询,这会对我的系统产生不利影响吗? 我可以在普通网络主机上使用什么开箱即用的功能? (因为如果我出售聊天应用程序,它应该适用于大多数人。)
(当前)实现 comet 的最佳方法是什么? 无限 iframe 是个好主意吗? php一段时间后不会超时吗? 这将是一个跨浏览器解决方案还是我必须编写一些丑陋的黑客? 这会导致服务器负载吗? Gmail 和 Facebook 使用什么来实现永久连接?
I am looking to implement something similar to facebook/gmail chat. I know they use comet & jabber as their technology. But am confused about a couple of things.
Do i really need jabber? Can I instead use a simple mysql table with from, to, message, sent and recd? Are there any inefficiencies in using mysql? Is there any performance loss?
Can comet be implemented using regular web-servers? Do i need to have some special servers? AFAIK, apache+php cannot handle too many open connections? Should I use simple polling, will that have an adverse effect on my system? What can I use out-of-the-box on ordinary webhosts? (Cause if i sell the chat app, it should work for most people.)
Which is the best way (currently) to implement comet? Is the infinite iframe a good idea? Wont php timeout after a while? Will it be a cross browser solution or do i have to write some ugly hacks? Will that lead to server load? What do gmail and facebook use for the forever connection?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
很好的问题,希望这个周末不会在堆栈中迷失。 如果您想使用 flash,kirupa 有一个关于如何使用 PHP 和套接字的很好的教程。 就 comet 而言,我相信您必须有某种服务器实现。 我的薄弱知识现在就到此为止了。
简单的轮询示例(jquery + asp.net)
http://trappedinhoth.blogspot.com/2009/04/ ajax-jquery-chat-demo.html
Kirupa 的教程(php5 套接字 + flash 8)
http://www.kirupa.com/developer/flash8/php5sockets_flash8.htm
开源 Flash 聊天客户端(谷歌,还有更多)
https://blueimp.net/ajax/
彗星信息
http://cometdaily.com/
我并没有真正回答您的问题,只是向您指出更多资源。 我很好奇其他人会怎么回答。
Great questions, hopefully this won't get lost in the stack on the weekend. If you want to use flash kirupa has a good tutorial on how to use PHP and sockets. As far as comet goes, I believe you have to have some sort of server implementation. That is about where my feeble knowledge ends right now.
Simple polling example (jquery + asp.net)
http://trappedinhoth.blogspot.com/2009/04/ajax-jquery-chat-demo.html
Kirupa's tutorial (php5 sockets + flash 8)
http://www.kirupa.com/developer/flash8/php5sockets_flash8.htm
Open source flash chat client (google, plenty more)
https://blueimp.net/ajax/
Comet info
http://cometdaily.com/
I'm not really answering your question, just pointing you to more resources. I'm very curious as to what others will answer.
是的,您确实需要使用 jabber 而不是 mysql。 您可以阅读 Stonebraker 等人撰写的 [The End of an Architectural Era (It's Time for a Complete Rewrite)][1],了解为什么使用 RDBMS 不合适的详细信息。
彗星是一个有点模糊的术语,但不用担心。 您不需要特殊的服务器,也不应该使用轮询。 您可以使用 [BOSH][2] - 这也是 Facebook(我怀疑 Gmail)使用的。
在客户端使用 [JSJaC][3](或 [我在 Github 上的分支][4]),在服务器端使用 [ejabberd][5]。 两者都支持 [BOSH][6](和 [XMPP over BOSH][7]),这意味着您可以直接与 XMPP 服务器建立 HTTP 连接,避免轮询并处理高流量负载。
所有这些的链接都已添加书签 http://delicious.com/petef/stackoverflow-843889
Yes, you do need to use jabber and not mysql. You can read [The End of an Architectural Era (It’s Time for a Complete Rewrite)][1] by Stonebraker et al for the details of why using an RDBMS is a bad fit.
Comet is a bit of a nebulous term but not to worry. You don't need special servers, you shouldn't use polling. You can use [BOSH][2] - which is also what Facebook (and I suspect Gmail) uses.
Use [JSJaC][3] (or [my fork on Github][4]) on the client side and [ejabberd][5] on the server side. Both support [BOSH][6] (and [XMPP over BOSH][7]) meaning you can make HTTP connections to your XMPP server directly, avoid polling and handle high traffic loads.
Links for all of these are bookmarked at http://delicious.com/petef/stackoverflow-843889
我认为 Jabber 可以安全地概念化为(妈妈)中间件,而 MySQL 无疑是(持久存储)后端。 这就是苹果和橙子。
鉴于 RDBMS 的 ACID 保证及其扩展特性所带来的限制,任何大型 web2.0 应用程序都不能依赖 RDBMS 进行实时消息传递。 (考虑动态对 SQL 表进行分区以添加更多服务器,从而了解所涉及的问题之一。)
最重要的考虑因素是系统中消息的持久性。 它们是永久保留还是仅在给定的时间窗口内保留。 鉴于它是一个聊天应用程序,很可能是后者。 为什么不使用基于内存的存储而不是 RDBMS?
为什么应该使用 Jabber? 嗯,它是一种标准,因此您将来会打开互操作的可能性,即使目前这不是问题。
更重要的是,它是一个经过很长一段时间(在互联网狗年)认真开发的系统,因此可以合理地假设它(截至目前)并且将继续比您设法设计的任何东西更加成熟、实施、调试并在内部做好生产准备。
对彗星一无所知,所以不发表评论!
I think Jabber can be safely conceptualized as a (mom) middleware, where as MySQL is certainly (persistent store) backend. So that's apples and oranges.
None of the mega scale web2.0 applications can rely on RDBMS for realtime messaging given the limits that is encountered due to the ACID guarantees of a RDMBS, and its scaling characteristics. (Think of partitioning your SQL tables on the fly to add more servers to get a sense of just one of the issues involved.)
The most important consideration is the durability of the messages in your system. Are they to be persisted forever or only during a given time window. Given that its a chat application, more than likely it is the latter. Why not use a memory based store instead of an RDBMS?
Why should you use Jabber? Well, its a sort of standard, so you'll open up the interop possibilities in the future, even if that is not an issue at this point.
More importantly, it is a system that's been under serious development for a long time (in internet dog years), so its certainly fair to assume that it is (as of now) and will continue to be more mature than whatever you manage to design, implement, debug, and make production ready in house.
Entirely clueless about comet, so no comment!