开发者

Understanding Bayeux

In terms of comet, I often hear about Bayeux. I know that:

Bayeux is a protocol for transporting asynchronous messages (primarily over HTTP), with low latency between a web server.

But is it important? Is it necessary? Are there alternatives? Does everyone use开发者_开发技巧 it? Is Bayeux the only protocol? Aren't there sites, like Facebook? that doesn't use Bayeux? Is google wave an equivalent?

Thanks.


It is primarily used for long-polling communication.

Most web communication is generally one way. The client sends a request to the server and the server returns some data. The server can generally send data to the client when it responds to a request from the client.

With long-polling, the client browser will open a connection to the server. The server may return some data, but will not close the connection. This connection stays open. Then when the server needs to communicate some data to the client, it just sends it down this connection.

It is the only way you can get a web server to instantaneously send information to a web client. Useful in chat programs and the like.

This is possible to do with any (or at least most) web servers; however to keep a client connection open can take up a lot of resources. If you have 20,000 clients doing this on a single IIS server, it will take down the machine. It will not be able to cope with this.

Bayeux is a very efficient way of achieving this. Using Jetty with the CometD library that implements Bayeux, 20,000 simultaneous clients is no sweat!


Well it can also be used for push applications or reverse ajax or wahtever you want to call it. I just wrote a blog about it and created a sample application: http://geeks.aretotally.in/thinking-in-reverse-not-taking-orders-from-yo http://jaye.felipera.cloudbees.net/

Source code is available, fork it on Github.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜