Skip to content

Instantly share code, notes, and snippets.

@jschoolcraft
Forked from jraines/eventmachine.md
Created May 18, 2011 23:28
Show Gist options
  • Select an option

  • Save jschoolcraft/979822 to your computer and use it in GitHub Desktop.

Select an option

Save jschoolcraft/979822 to your computer and use it in GitHub Desktop.
EventMachine Railsconf notes

Implementation of the Reactor pattern

  • Most web apps are I/O bound, not CPU bound
  • Instead of waiting on a response from the network, use that time to process other requests
  • Handle 5-10k concurrent connections with a single Ruby process
EM.run do 
  EM.start_server '0.0.0.0', 2202, EchoServer
end

while reactor_running?
  . . .
end

#your interface module

post_init
receive_data

Never block the reactor

  • no long loops
  • no MySQL queries
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment