Mike Perham

On Ruby, software and the Internet

Entries Tagged as 'Ruby'

Touch a File

February 27th, 2010 · No Comments

Here’s how to touch a file using Ruby, easy as 1-2-3:

File.utime(access_time, mod_time, filename)

[Read more →]

Tags: Ruby

The Trouble with Ruby Finalizers

February 24th, 2010 · 2 Comments

I was test driving Devil, the developer’s image library, recently to see if it would work for us in a long-living daemon. Task #1 to that end is to verify the absence of memory leaks, which seem to be common in image libraries. It was almost immediately apparent that Devil contained a large [...]

[Read more →]

Tags: Ruby

Asynchronous DNS Resolution

February 10th, 2010 · 3 Comments

Ruby has a serious scalability problem most Rubyists are unaware of. When you lookup the IP address for a hostname, the entire Ruby process blocks by default. If you have a slow DNS server, your process can grind to a halt waiting for hostname resolution. Ruby comes standard with a fix, resolv-replace, [...]

[Read more →]

Tags: Ruby

Cassandra and EventMachine

February 9th, 2010 · 1 Comment

I spent this past weekend adding eventmachine support for the Cassandra gem. We’re using Cassandra at OneSpot as our next-gen data store and need EM support. They were nice enough to pull my changes yesterday so the next release of the thrift_client and cassandra gems should work in EM. You just need [...]

[Read more →]

Tags: Ruby

Scalable Ruby Processing with EventMachine

January 27th, 2010 · 1 Comment

I gave a talk at Austin On Rails last night on using EventMachine, focused on maximizing concurrency when processing a message queue. There were a lot of questions, mostly revolving around the flow of execution within EventMachine code. To this point, there were two common stumbling points people seemed to have:

Ruby developers are [...]

[Read more →]

Tags: Ruby

Speaking on January 26th

January 6th, 2010 · No Comments

I’ve been enjoying my holiday break (perhaps a bit too much since I’ve produced no new blog content) but to shake off the cobwebs I’ve signed up to speak at Austin on Rails this month on “Scalable Ruby Processing with EventMachine”. I’ll discuss the advantages of event-driven programming in general, why it’s especially useful [...]

[Read more →]

Tags: Ruby

Event-Driven Applications

December 1st, 2009 · 1 Comment

Getting concurrency in Ruby is tough: Ruby 1.8 threads are green so they don’t execute concurrently. Ruby 1.9 threads are native but they don’t execute concurrently due to the GIL (global interpreter lock) necessary to ensure thread-safety with native extensions. Only JRuby provides a stable, concurrent Ruby VM today. On top of [...]

[Read more →]

Tags: Ruby · Software

EventMachine Examples

November 2nd, 2009 · 2 Comments

I needed to create a simple, but IO-intensive, thumbnailing service for OneSpot last week. This service acts as a proxy to S3 and so a blocking implementation would not scale well, even if threaded. I wanted to use EventMachine instead. Lessons learned:

The programming model is a mind twist and takes a long [...]

[Read more →]

Tags: Ruby

Heading to RubyConf 2009

September 30th, 2009 · 1 Comment

RubyConf 2009 is taking place in San Francisco November 19-21. I’ll be there and have most of the 18th free if anyone is near SFO and wants to join me in some coffeeshop coding.

[Read more →]

Tags: Personal · Ruby

Old versus New

July 29th, 2009 · No Comments

We had some performance issues recently and discovered we were using memcache-client 1.5.0. Our daemon was blocked by memcached socket operations hanging forever, which caused monit to kill and restart the daemon after 5 minutes.
I performed the brain surgery to use 1.7.4 (since we are using Rails 2.1) and deployed. See if you [...]

[Read more →]

Tags: Rails · Ruby