Text

Jun 17, 2009
@ 4:17 am
Permalink

Dancing Threads with Thin and Ebb

I’ve been cleaning up the code for a release later in the day, pondering over whether it’d be worth it to take Sinatra out of the picture and go pure Rack… doubtful. But enough of that!

Consider the JSONP long-polling problem. In order to keep a user’s experience constantly fresh with new content, we set up a javascript function that opens a request to the web server, and waits for new data to come pouring in. Once that’s done, it opens up another request and waits, ready to start the cycle all over. How Pavlovian.

Now this works great and all for data that isn’t constantly being generated. I don’t believe this to be our case, with Dtrace probes firing on all four cylinders to keep a tight grip on the pulse of our beloved server. So what’s the solution? I don’t know. I have some leads though, maybe. It’s late, ask me again in the morning…

However, while dealing with this, I did find out that Thin, Ruby web server of some that has been my trusty sidekick in development thus far, is single-threaded. Didn’t do my homework, is what happened. To make a short story shorter, I decided to give Ebb a try, got frustrated (it’s late, seriously) with the lack of documentation on getting it going with a Sinatra modular app, found out that Thin does have a threaded mode, found out that both web servers make use of a deferred() method to figure out which requests should be handed off to separate threads, and I’m heading to bed and may have more to say once I’m refreshed after some sleep.

Good night!