 |




 |
|
 |
 |
 |
 |
|
 |
 |
Since I had spent some time with ActiveMQ, I thought I would check out RabbitMQ. RabbitMQ is an AMQP messaging server, but it also has an XMPP and Stomp adaptor. Getting the source built was easy, but I had to make sure my MacPorts directory was first in the path, and to make with PYTHON=python2.5. Then getting everything setup was easy-peasy. Do a 'make run' and get the server running in the foreground. I then whipped up a simple stock watcher and publisher in ruby using the amqp gem. I would recommend getting the source from github ( http://github.com/tmm1/amqp/tree/master). Here is the code for the simple client and publisher. It will fetch Apple stock data from Yahoo! Finance every 30 seconds and publish it to the 'stock queues' exchange.
require 'rubygems'
require 'amqp'
require 'mq'
require 'pp'
require 'net/http'
class SimpleStockWatcher
def run
EM.run do
connection = AMQP.connect(:host => 'haruhi.local', :logging => false)
channel = MQ.new(connection)
queue = MQ::Queue.new(channel, 'stocks')
queue.bind('stock queues')
queue.subscribe do |headers, msg|
pp [:got, headers, msg]
end
end
end
end
class SimpleStockPublisher
def run
EM.run do
connection = AMQP.connect(:host => 'haruhi.local', :logging => false)
channel = MQ.new(connection)
exchange = MQ::Exchange.new(channel, :fanout, 'stock queues')
EM.add_periodic_timer(30) do
uri = URI.parse('http://download.finance.yahoo.com/d/quotes.csv?s=AAPL&f=sl1d1t1c1ohgv&e=.csv')
res = Net::HTTP.start(uri.host, 80) do |http|
http.read_timeout = 30
http.get('http://download.finance.yahoo.com/d/quotes.csv?s=AAPL&f=sl1d1t1c1ohgv&e=.csv')
end
msg = res.body.split(',')
exchange.publish("#{msg[0]}:#{msg[1]}:#{msg[5]}")
end
end
end
end
Tags: ruby rabbitmq amqp
|
 |
 |
 |
 |
|
 |
 |


 |
|
 |
 |
 |
 |
|
 |
 |
Doing some basic application testing with the new Phusion Passenger module for nginx and Apache. These tests were done on some Parallels virtual machines, one for the web/app server and one for the database. The setup on the web servers is identical, from a hardware standpoint. Anyway, here are some meaningless numbers :) ApacheBench was used for the testing, 500 requests with a concurrency of 20.
Nginx/Passenger (no proxy, NFS for photos, inital hit to start the server)
Server Software: nginx/0.6.36
Server Hostname: www.things.fm
Server Port: 80
Document Path: /things/953125641
Document Length: 5567 bytes
Concurrency Level: 20
Time taken for tests: 26.821 seconds
Complete requests: 500
Failed requests: 0
Write errors: 0
Total transferred: 3113499 bytes
HTML transferred: 2783500 bytes
Requests per second: 18.64 [#/sec] (mean)
Time per request: 1072.821 [ms] (mean)
Time per request: 53.641 [ms] (mean, across all concurrent requests)
Transfer rate: 113.37 [Kbytes/sec] received
Connection Times (ms)
min mean[+/-sd] median max
Connect: 1 4 4.2 2 39
Processing: 170 1055 279.1 990 1616
Waiting: 169 1047 278.8 980 1615
Total: 178 1059 278.4 994 1621
Percentage of the requests served within a certain time (ms)
50% 994
66% 1244
75% 1337
80% 1369
90% 1425
95% 1478
98% 1535
99% 1570
100% 1621 (longest request)
Nginx -> Passenger (Prewarmed 6 runners, NFS for photo storage)
Server Software: nginx/0.6.34
Server Hostname: www.things.fm
Server Port: 80
Document Path: /things/953125641
Document Length: 5567 bytes
Concurrency Level: 20
Time taken for tests: 28.798 seconds
Complete requests: 500
Failed requests: 0
Write errors: 0
Total transferred: 3124497 bytes
HTML transferred: 2783500 bytes
Requests per second: 17.36 [#/sec] (mean)
Time per request: 1151.935 [ms] (mean)
Time per request: 57.597 [ms] (mean, across all concurrent requests)
Transfer rate: 105.95 [Kbytes/sec] received
Connection Times (ms)
min mean[+/-sd] median max
Connect: 1 3 3.2 2 23
Processing: 140 1134 315.8 1084 1761
Waiting: 139 1114 314.4 1060 1716
Total: 149 1137 315.5 1085 1764
Percentage of the requests served within a certain time (ms)
50% 1085
66% 1363
75% 1437
80% 1475
90% 1549
95% 1598
98% 1657
99% 1699
100% 1764 (longest request)
Apache/Passenger (NFS for photo storage)
Server Software: Apache/2.2.11
Server Hostname: www.things.fm
Server Port: 80
Document Path: /things/953125641
Document Length: 5567 bytes
Concurrency Level: 20
Time taken for tests: 27.831 seconds
Complete requests: 500
Failed requests: 0
Write errors: 0
Total transferred: 3141500 bytes
HTML transferred: 2783500 bytes
Requests per second: 17.97 [#/sec] (mean)
Time per request: 1113.221 [ms] (mean)
Time per request: 55.661 [ms] (mean, across all concurrent requests)
Transfer rate: 110.23 [Kbytes/sec] received
Connection Times (ms)
min mean[+/-sd] median max
Connect: 1 3 2.2 2 16
Processing: 179 1090 274.6 1028 1923
Waiting: 168 1062 274.4 1001 1906
Total: 185 1093 274.5 1034 1924
Percentage of the requests served within a certain time (ms)
50% 1034
66% 1242
75% 1340
80% 1376
90% 1472
95% 1531
98% 1623
99% 1666
100% 1924 (longest request)
(Updated Apache setup to use Ruby-EE, as the nginx test did) Tags: nginx apache passenger rails
|
 |
 |
 |
 |
|
 |
 |

|
 |
|
 |