test your rails app for slashdot/digg'ing

just put this in a script or something and you can see if your rails app chokes when you start getting alot of crazy traffic. Thanks to j'ey from #rubyonrails

require 'net/http'
page = "the_rails_page"


hehejo said...

woa, that's kinda heavy stuff.
In time I will try this for my site too.

hehejo said...

But notice:
All you thousands of threads are not parallel.
You create a Thread and immediately join it.

Better is this:
require 'net/http'
t = Array.new
1000.times {
t << Thread.new {
Net::HTTP.start("your.server.tld",80) { |h|

t.each { |thread|

Andrew Ferguson said...

Couple questions:

First, this script only loads one page. While I'm not a rails programmer, I do program in PHP and know that pages, or parts thereof, are cached. And with all your clients connect from the same IP address (i.e. localhost loopback). Wouldn't that provide an artificially high page serve rate?

Second, this only tests the first page. Can you make it test some random link for some random number of link depth?

Samuel "Artoo" Goodwin said...

heh, it's not a perfect test, mind you. And yes, rails does caching too. As far as testing depth goes, that's kinda specific to your app you're running and I don't really want to spend any kind of time abstracting it to work for any site.

The only real test of if you can handle a slashdot/digg'ing is to actually have it done to you... or hire a zombie-army of computers to try it for you.