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.

Saturday, January 7, 2012

Data Handoff

Previously...
  • I experimented with creating a new module.
  • I added the new module to the system (after troubleshooting a problem).
  • I resolved a problem with erlang processes and TCP sockets.
So I tried out the new system and everything just worked.

Mostly.

OK, so I hit another problem almost immediately, but a man can hope.

The current problem relates to the multiplexing issue.  Specifically, ejabberd_http is set up to expect that when it calls <socket module>:recv, that after the return the data is there.  The actual setup with megaphone is that a separate erlang process keeps track of all the data and sorts it into blobs for each connection.  For lack of a better name, the process that manages the data is called megaphone_socket.


When new data comes in, the data is either for an existing packet or a new packet.  In the case of an existing packet, the system is just waiting for enough data to complete the message.  The system knows how much data to expect because that is the first thing in the packet header.  If the segment of data received is enough to complete the current packet then the system can treat it like a new packet.  Otherwise more data is needed to complete the message and the system goes back to wait for another segment.


When the data pertains to a new packet, an instance of ejabberd_http is started up to handle the new connection.  Before that can happen, the data for the message is handed off to megaphone_socket.  The current problem is that no megaphone_socket process exists to receive the data.  That is the situation, in turn, because nothing starts up the process.  


So the next step is simply to create something that starts up the megaphone_socket process.

No comments:

Post a Comment