Mike Perham

On Ruby, software and the Internet

Entries Tagged as '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

memcached vs memcache-client Performance

June 16th, 2009 · 1 Comment

memcached is Evan Weaver’s Ruby wrapper around the libmemcached C library and widely regarded as quite fast. After an hour of trying, I finally got a build of memcached to actually compile and install on my machine (the trick: you need to download the custom packages Evan links on his blog, nothing else seems [...]

[Read more →]

Tags: Ruby

Scraping with Typhoeus and Nokogiri

June 12th, 2009 · 1 Comment

I’ve been working on some cool new functionality at OneSpot. We want to provide a widget that can give the reader more context about a given article. Zemanta takes the article text and hands us back a set of semantic entities, including links to their Wikipedia page, but we wanted to get a [...]

[Read more →]

Tags: Ruby

Memory-hungry Ruby daemons

May 25th, 2009 · 6 Comments

We’ve had a perplexing issue with our Ruby daemons at OneSpot: they seem to grow to 300-400MB each within about 30 minutes, at which point our Monit scripts restart them. We suspected a memory leak and so upgraded from stock Ruby 1.8.5 shipped with CentOS to the latest REE 1.8.6 but nothing changed. [...]

[Read more →]

Tags: Ruby

memcache-client rdoc

March 30th, 2009 · 2 Comments

I’ve put up the memcache-client rdoc by request of my coworker Chris.

[Read more →]

Tags: Ruby

Caching and Rails

March 25th, 2009 · 3 Comments

Here’s the slides from my AOR talk last night: Caching, Memcached and Rails (600KB).
Caching, Memcached And Rails

I was a little unhappy with my wrapup – the one thing I wanted to teach people was when to use each different caching mechanism provided by Rails and I didn’t really revisit and summarize that content. So [...]

[Read more →]

Tags: Rails · Ruby

Socket Timeouts in Ruby

March 15th, 2009 · 9 Comments

One of Ruby’s weaknesses is its poor networking performance. Much of that has to do with the net/http implementation, which uses Ruby’s awful Timeout library. The issues with Timeout are well documented. SystemTimer provides a reliable alternative that also performs better.
However I started today wondering if there was a better way. [...]

[Read more →]

Tags: Ruby