Skip to content

Instantly share code, notes, and snippets.

@timharding
Created November 3, 2011 22:12
Show Gist options
  • Save timharding/1337952 to your computer and use it in GitHub Desktop.
Save timharding/1337952 to your computer and use it in GitHub Desktop.
EventMachine hello world...
require 'rubygems'
require 'eventmachine'
require 'evma_httpserver'
class Handler < EventMachine::Connection
include EventMachine::HttpServer
def process_http_request
resp = EventMachine::DelegatedHttpResponse.new( self )
#sleep 2 # Simulate a long running request
resp.status = 200
resp.content = "Hi!"
resp.send_response
end
end
EventMachine::run {
EventMachine.epoll
EventMachine::start_server("0.0.0.0", 3000, Handler)
puts "Listening..."
}
tim@li164-209:~$ ab -n 50000 -c 1000 http://0.0.0.0:3000/
This is ApacheBench, Version 2.3 <$Revision: 655654 $>
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Licensed to The Apache Software Foundation, http://www.apache.org/
Benchmarking 0.0.0.0 (be patient)
Completed 5000 requests
Completed 10000 requests
Completed 15000 requests
Completed 20000 requests
Completed 25000 requests
Completed 30000 requests
Completed 35000 requests
Completed 40000 requests
Completed 45000 requests
Completed 50000 requests
Finished 50000 requests
Server Software:
Server Hostname: 0.0.0.0
Server Port: 3000
Document Path: /
Document Length: 3 bytes
Concurrency Level: 1000
Time taken for tests: 7.173 seconds
Complete requests: 50000
Failed requests: 0
Write errors: 0
Total transferred: 2100504 bytes
HTML transferred: 150036 bytes
Requests per second: 6971.03 [#/sec] (mean)
Time per request: 143.451 [ms] (mean)
Time per request: 0.143 [ms] (mean, across all concurrent requests)
Transfer rate: 285.99 [Kbytes/sec] received
Connection Times (ms)
min mean[+/-sd] median max
Connect: 0 96 501.2 9 3042
Processing: 8 20 19.4 15 653
Waiting: 5 16 16.9 12 649
Total: 17 116 506.0 24 3653
Percentage of the requests served within a certain time (ms)
50% 24
66% 26
75% 28
80% 34
90% 50
95% 92
98% 3052
99% 3062
100% 3653 (longest request)
tim@li164-209:~$
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment