What is Megaphone?

What is Megaphone?
The Megaphone project is about enhancing open source chat software. Specifically, the goal is to allow ejabberd to support 1,000,000 simultaneous users. See The Plan page for more details on how I plan to solve this problem. See the About this Blog page for more details on why I created this blog.

Tuesday, February 14, 2012

ejabberd_http_bind Interface Issues


Previously...
  • I resolved some problems with dictionaries.
  • I encountered some problems with states.
  • I completed testing for receiving data from the BOSH client.

"Sending" data to the client of a BOSH connection is a little strange.  The thing is, data is always "sent" by responding to an HTTP POST that the client has issued.  The client issues a POST when it wants to send data to the server and the server responds immediately.  

The client also issues a POST when it wants to receive data from the server.  In that case the server delays responding to the POST until either a timeout occurs, at which point it responds with an empty packet, or the server has some data for the client, in which case it puts the data in the response to the POST. 

This poses something of a problem for megaphone: how does the system figure out which virtual connection the server is responding to?  


It turns out that the HTTP stuff really doesn't matter from the standpoint of megaphone: it just sends and receives TCP segments.  While megaphone is marginally aware of the nature of HTTP, in that it has use erlang:decode_packet on the data that it hands off to ejabberd when it sends data back to the client it has no idea if this is a response to an HTTP request - it's just another segment as far as megaphone is concerned.  


As to the issue of which connection the response is going to, when ejabberd_http_bind wants to send something, it includes the socket as one of the arguments.  In the case of megaphone, this includes the connection ID.


This resolves most of the issues associated with the interface except for one thing: how is ejabberd_http_bind notified of a new client connection or new client data.


Next time: just how does megaphone tell ejabberd about new connections?

No comments:

Post a Comment