Merb Rules
Well I came across a “problem” the other day in Rails. It turns out that Rails is not exactly thread safe at the CGI level. What this really means is that it waits for a file upload to finish before another can happen, which for a busy file uploading site is not actually good. But, since I have read that this is not as big of a deal as you would have thought if using Mongrel because it magically handles multithreading requests and only offloads the request to Rails once it has finished, meaning that it is only blocked whilst being mime parsed etc, which is not that bad. But whilst thinking oh shit I came across Merb, which is another Ruby framework that is really cool and extremely lightweight meaning its nice and fast. It also allows you to pick from a selection of ORM providers such as Sequel, Datamapper and of course ActiveRecord. The main advantage is that it has its own CGI handlers and effectively handles multiple file uploads concurrently which is big benefit.
This does not mean that I am now going to switch over to Merb – infact not a chance. Rails is now very very good at what it does and has a million plugins that are very useful (most can also be used in Merb) and it is very useful for the actual application side of the system. It has so many useful features that its hard to explain them all. But it does mean that I can use Merb for all file handling activities. Its fast and allows me to handle multiple files effectively. In fact it was my original plan that we would someday move file handling off the main app to another server just so that the system can run the application so much faster. As it turns out, this is what some very heavy traffic sites have begun to do which means the idea isn’t totally crazy. You might as well let things do what they are good at hadn’t you?
Another good thing is that we can share code between the Rails and Merbs apps. Like I said, Merb lets you use ActiveRecord which means all the models are available in both apps without any code duplication so it makes sense.