eventmachine /eventmachine
EventMachine: fast, simple event-processing library for Ruby programs
★ 4,280⑂ 628👁 100⑃ 381● 648▤ 19
4,280
stars
628
forks
100
watchers
381
prs
648
issues
19
releases
README
About EventMachine
What is EventMachine
EventMachine is an event-driven I/O and lightweight concurrency library for Ruby.
It provides event-driven I/O using the Reactor pattern,
much like JBoss Netty, Apache MINA,
Python's Twisted, Node.js, libevent and libev.
EventMachine is designed to simultaneously meet two key needs:
Extremely high scalability, performance and stability for the most demanding production environments.
An API that eliminates the complexities of high-performance threaded network programming,
allowing engineers to concentrate on their application logic.
This unique combination makes EventMachine a premier choice for designers of critical networked
applications, including Web servers and proxies, email and IM production systems, authentication/authorization
processors, and many more.
EventMachine has been around since the early 2000s and is a mature and battle-tested library.
What EventMachine is good for?
Scalable event-driven servers. Examples: Thin or Goliath.
Scalable asynchronous clients for various protocols, RESTful APIs and so on. Examples: em-http-request or amqp gem.
Efficient network proxies with custom logic. Examples: Proxymachine.
File and network monitoring tools. Examples: eventmachine-tail and logstash.
What platforms are supported by EventMachine?
EventMachine supports Ruby 2.0.0 and later (see tested versions at
.github/workflows/workflow.yml). It runs on JRuby and works well on Windows
as well as many operating systems from the Unix family (Linux, Mac OS X, BSD flavors).
Install the gem
Install it with RubyGems
gem install eventmachine
or add this to your Gemfile if you use Bundler:
gem 'eventmachine'
Getting started
For an introduction to EventMachine, check out:
blog post about EventMachine by Ilya Grigorik.
EventMachine Introductions by Dan Sinclair.
Server example: Echo server
Here's a fully-functional echo server written with EventMachine:
ruby
require 'eventmachine'
module EchoServer
def post_init
puts "-- someone connected to the echo server!"
end
def receive_data data
send_data "you sent: {data}"
close_connection if data =~ /quit/i
end
def unbind
puts "-- someone disconnected from the echo server!"
end
end
Note that this will block current thread.
EventMachine.run {
EventMachine.start_server "127.0.0.1", 8081, EchoServer
}
EventMachine documentation
Currently we only have reference documentation and a wiki.
Community and where to get help
Join the mailing list (Google Group)
Join IRC channel eventmachine on irc.freenode.net
License and copyright
EventMachine is copyrighted free software made available under the terms
of either the GPL or Ruby's License.
Copyright: (C) 2006-07 by Francis Cianfrocca. All Rights Reserved.
Alternatives
If you are unhappy with EventMachine and want to use Ruby, check out Celluloid.Top issues
#869jekyll --livereload gives bad file descriptor error in Windows45 comments · 2019-01-17#266Memory leak with start_tls42 comments · 2011-09-23#94add native support for async dns35 comments · 2010-10-12#689Cannot install eventmachine on Windows with SSL31 comments · 2016-02-24#932eventmachine does not compile with ruby 3.0.0preview1 on macOS30 comments · 2020-09-30#990eventmachine(1.2.7) installation issue on Intel mac with ruby 3.3.019 comments · 2024-08-29#960Unable to load the EventMachine C extension, ruby 2.7.4, Mac OS 12.0.1 x8617 comments · 2021-11-19#566Memory leak/bloat with EM::Queue under load17 comments · 2015-01-21
Latest release
1.2.7 v1.2.7 2018-05-121.2.7 (May 12, 2018) Fix segfault on large numbers of connections [843]