Ruby : the best of all worlds

I have recently embarked on a quest to understand why some very smart people would insist that Ruby is awesome. I even bought a book, and started using it seriously on production systems. I believe I can now safely tell you why.

First of all, there is an awesome user community, with a host of expert rails coders, always attentive to the needs of the people in operations. That’s no wonder that Ruby is the language of DevOps ! I’m not sure what I like most about them, their refreshing attitude towards the use of memory (it is so cheap !), insistence on using specific versions of carefully crafted libraries with a stable API (that bundle tool is so easy to use) or testing methodology (there are so many useful tests, it is a pity that production performance is so hard to test for). This reminds me of the good old days of PHP, with its thriving community of smart hackers. The only difference I can think of is that the PHP coders were constrained by the damn sysadmins about memory usage, while the Ruby ones will eagerly put all your computational power to use.

Ruby programs are also incredibly easy to maintain, thanks to the unique features of the object model (singleton methods, mixins), stability of the libraries APIs, great coding conventions (two words : two tabs), compatibility between interpreter versions, and great code hiding capacities of blocks. It is really easy to spot memory leaks or understand how this cool feature works. To sum it up : its readability is comparable to Perl, with even more syntactic sugar.

Ruby interpreter speed is often described as horrible. Seasoned Ruby coders know the truth about it : it is a debugging feature. Ruby is just like Mac OS before X : tailored to work with the human mind. Who needs multitasking when your brain can only concentrate on a single thing at once ? Who needs speed when your brain only processes information that slowly ? With Ruby you can actually watch the computing taking place.

Modules are awesome too. That is no wonder that every time you want to use a single Rails app you have to install dozens of dependencies, each of them being gems of efficient computing. Never has a dependency management tool been so aptly named.

To be fair, Ruby is just like a baseball bat. Very fun to swing around, but not as nice when you are on the receiving end. I am using Puppet and Snorby for real. Puppet is typical of good Ruby projects : you can’t live without it, it is easy to start using (once you installed it) and horribly slow, to initialize or to run. I was pretty unhappy when the puppet master began to swap and I realized that I could not control Ruby memory usage. The best I can do is restart the rails instances every few requests. Did I mention how slow the initialization is ?

Snorby on the other hand is typical of average Ruby projects : cute looking, recommended as the new hot thing on every website you visit, a pain to install and then a torture to your production systems. Try doing a classification on 1M events, and it will suck up all your memory (it takes 15 minutes to use 4G, which is either really fast or really slow, depending on how you see it). After tuning, it can classify up to 12 events every second. And it needs megabytes and megabytes of memory to do that. There are also all kinds of cool AJAX effects. Except that after a few seconds visiting some pages, my browser starts using 100% CPU and freezes. I know Firefox isn’t the fastest browser on the planet, but the page is displaying almost nothing …


2 thoughts on “Ruby : the best of all worlds

  1. Interesting article. I tend to agree with most points. (except those about perl, which I think is a great language, provided the coder does not try to get tricky and instead trys to keep the code readable)… but I have to agree. After installing several snorby VMs passively monitoring the firewalls they are sitting on, that the memory leaks or usage are insane, and after a bout 10gb of traffic have passed through, processes start being killed do to lack of memory and the worker is so slow It cant catch up to restart.

    I take it you found the same thing. Can you recommend a replacement that is lighter on resource usage?

    • Right now I am stuck with it. I just configured the hell out of snort so that I only get around 150 alerts / day maximum. I haven’t had time to find (or write!) a custom solution, but this is not a priority. I restart the worker processes every day too …

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s