Don't block the reactor loop
Use blocks as callbacks
Use async libraries
EM.start_server('0.0.0.0', 1337, ChatClient)
Instance variables keep state on a per Connection basis
Non-idiomatic ruby
callbacks { within { callbacks } }
EventMachine is good for web services
Linux: use .epoll
Check wiki for EM aware gems
Use em-hiredis
JRuby threads work much better -- apps needing concurrency should use
Multithreaded code = hard
Many Rails features not thread safe, such as autoload
- pass messages, don't share state
- allows lock-free concurrency
- See Erlang, Scala
Check out girl_friday gem
Testing: em-spec