title: collaborative editing in ruby on rails - architectural approach?
body: <p>In our app, we are considering to enable collaborative online editing. It is a graphic application heavily relying on javascript for creating mind-map-like structures. </p>
  
  <p>The first obvious candidate is to use websockets.</p>
  
  <p>Users come to the site to create those maps. I have looked at <a href="https://github.com/igrigorik/em-websocket" rel="nofollow">em-websocket</a> which seems to start an own process, but </p>
  
  <pre><code> EventMachine.run {
  
           EventMachine::WebSocket.start(:host =&gt; "0.0.0.0", :port =&gt; 9876) do |ws|
  </code></pre>
  
  <p>it seems there is not much of context information there; people may be editing different maps at the same time!
  So my current guess is to </p>
  
  <ul>
  <li>for every map being edited on, a new WebSocket server is started on a
  different port </li>
  <li><p>as this would entail control of the WebSocket
  life-cycle, I was thinking to spawn a <code>Thread</code> for every such <code>WebSocket</code> server:</p>
  
  <p>#on map create/edit:
         Thread.new do
             EventMachine.run {</p>
  
  <pre><code>         EventMachine::WebSocket.start(:host =&gt; "0.0.0.0", :port =&gt; 9876) do |ws|
         ....
     end
  </code></pre></li>
  </ul>
  
  <p>What do people think on this approach? Is this reasonable? Any other suggestions? Thank you!</p>