(from American Scientist magazine, Mar-Apr 2008)
Thin vs. Mongrel: A Ruby on Rails performance shootout 2
Previously Science and wayneseguin published a study looking at the performance of nginx fair proxy. To take that a little further, Science conducted an examination of how Thin and Mongrel compare head-to-head on performance. For kicks we took a look at Rails page template caching facility to see if that significantly impacts performance (it does). Full details follow..
Thin, Ruby on Rails & Nginx fair proxy: Performance testing
By science & wayneeseguin
Thin a new-ish application server, primarily designed for serving the same community as Zed Shaw’s (and now community managed) masterwork Mongrel. Its job is to dispatch web requests, primarily Rails and other Ruby frameworks. There’s plenty already written about Thin, to get you up and running.
I’ve been eying Thin and thanks to Wayne, I got motivated to test it out. He and I spent the better part of a day doing configuration analysis and performance testing on Thin in the context of EngineYard’s hosting environment. We had access to a brand new, unloaded “slice” (aka web server) on their server farm. The stack we used looks like:
Load balancers => Nginx => unix sockets => Thin => Rails
We ran a quite a few performance tests against Thin using the above setup and overall liked what we saw.
Converting numbers or currency to comma delimited format with Ruby regex
There may be much easier ways to do this but Science wrote a nice little regular expression which will convert your numbers to comma delimited strings in pure Ruby. It demonstrates some cool features of Ruby from which maybe you will learn!
Continue reading…
Rails page caching, nginx, SSI, Ajax and form POSTS 3
A couple of great blog posts have come out in the last year, dealing with how to squeeze more performance out of Ruby on Rails. These techniques are actually massively improving the performance of Ruby on Rails, so much so that I’m starting to think of Rails less as an Application Framework and more as an Web Page Template Generator.
MojoMagick: Ruby Image Library (for ImageMagick) 4
Science releases MojoMagick, an Ruby language image library “that does very little” ™. There are several useful image tools that “do a lot” - MojoMagick is designed to just a few things: Continue reading…
Passing Multiple Arguments in Ruby: “*” is your friend
Passing multiple arguments in Ruby is easy. You can pass any number of arguments, and even vary the class/types according to context. You can even vary the number of arguments passed. The receiver has to deal with this somehow, but even that’s pretty easy to manage. It’s a little trickier if the receiver has to delegate an unknown number of arguments to another receiver, but the * does the job for you - a great example of Ruby syntax that works for you. What follows is some simple example code to illustrate the idea. Continue reading…
On magnifying glasses, microscopes and the act of looking.
A larger world exists, but we have never looked at it. We are too concerned with our microscopes or our magnifying glasses. We try to make things large by using magnifying glasses—but we have never looked at outer space with our naked eyes. If we looked into it, we could find it—but we don’t have to use our binoculars and telescopes. We don’t need them, they are false pretenses. We don’t need any means to do this; we could just simply look at it, whatever it is, and enjoy it. An immensely larger version of thinking and of celebration is taking place. That seems to be the very important point.
- Chögyam Trungpa Rinpoche
Synchronizing Files 2
Science regularly has to synchronize files across file systems. Normally, this would involve a Ruby script or something heinous in a shell language. But that’s just business. When the synchronization is complex, the problem is much more difficult. Answering questions like these becomes a major painola: was the file deleted from one side, or added to the other? Was the folder renamed or removed?
It’s possible to try to be clever and check all your things into SVN to manage the changes, but with gigabytes of music files, for example, this could be another kind of pain (if I delete “Wham Rap” from my collection - not that I would - I don’t want it kicking around in the SVN repo taking up space).
There’s a better way. Continue reading…
Using ActiveMerchant to process credit cards in Ruby/Rails 3
ActiveMerchant is a very nice little Ruby library that permits connecting to payment processing gateways to charge money against credit cards. To understand how this works, you need to know that there are two separate entities, a “payment gateway” and a “merchant account” (aka a bank). The Payment Gateway receives your request over the Internet for a charge, and authorizes that charge in real-time. The Gateway then hands the authorization/transaction over to the Merchant Account, which converts that credit card transaction into money in your account.
