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, December 24, 2011

Once More Unto the Breach


Previously...

  • I read up on various OTP behaviors.
  • I resolved to use a different plan.
  • I went through the "entry point" into ejabberd/BOSH/http-bind
Looking at the approach that I wanted to use before: that is replace the socket interface that ejabberd/BOSH was using to one that is megaphone aware, appears to be incompatible with the way that the BOSH/http-bind module of ejabberd works.

Here is an event trace of how I thought things worked:

Client      Socket      BOSH        Session
                        Module
|           |           |           |
HTTP POST   |           |           |
----------->|           |           |
|           Data        |           |
|           ----------->|           |
|           |           |           |
< The BOSH Module finds the client's session >
|           |           |           |
|           |           Data        |
|           |           ----------->|
|           Response    |           |
|           |<-----------------------
POST response content   |           |
|<-----------           |           |
|           |           |           |

Therefore, replacing the Socket with something that is "megaphone aware" makes a certain sense.

From what I can see, this was dead wrong.

Here is how I now think that the BOSH module actually works:


Client      HTTP        BOSH        
            Server      Module
|           |           |
HTTP POST   |           |
----------->|           |
|           process_request(POST data)
|           ----------->|
|           |           |
< The BOSH module waits until either it has some data
  for the client or a timeout occurs >
|           |           |
|           |           |
|           |Return (POST response)
|           |<-----------
|Response (POST response)
|<-----------           |
|           |           |

This being the case, I don't think I can just swap out the socket module with something that understands that it is using a multiplexed connection.  Instead I think I will need to do something along the lines of this:

ECM         megaphone   Session     BOSH        
                        Process     Module
|           |           |           |
Data        |           |           |
----------->|           |           |
|           start(Data) |           |
|           ----------->|           |
|           |           process_request(Data)
|           |           ----------->|
|           |           |           |
< The BOSH module waits until either it has some 
  data or a timeout occurs >
|           |           |           |
|           |           |Return(POST response)
|           |           |<-----------
|           |Send(POST response)    |
|           |<-----------           |
|           |           |           |
< Session Process terminates >
|           |           |           |
|Data (POST response)   |           |
|<-----------           |           |
|           |           |           |

Or at least that's what my current plan is.  I'm sure this plan is correct.  Absolutely.  Positively.  Unless it's wrong.  In which case I'll have to use something else.  Sigh.

No comments:

Post a Comment