Saturday, June 19, 2010

Catalyst is the only web framework that has a mailing list I subscribe to - but I am sure that it happens at others too. In a recurring pattern someone someone posts a benchmark showing that Catalyst for some trivial operation is many times (or many hundred times) slower than some other web framework or for that matter PHP. That does not fail to generate a heated debate - but eventually the seasoned framework developers gain the upper hand with the argument that for all the, often big, web sites they worked on, those few micro-seconds lost in the Catalyst dispatcher never mattered much because the application spent hundred times more in other code fragments and mostly in business logic parts, so shaving off some part of the few micro-seconds would not improve the overall speed more than 1%. This is a great argument, perfectly reasonable and rational but it is biased towards the status quo. It might be true that everywhere where Catalyst is currently used it works great but it is also not hard to imagine an application with very simple business logic that needs to serve millions of users, Twitter anyone? Or an app that does many simple Ajax callbacks. Sure you can always code the speed requiring, simple parts in PHP and keep Catalyst only for the other more heavy-weight tasks but having a universal solution would be so much more convenient.

2 comments:

I think the main point people were trying to make in the most recent thread is that it's actually as fast as it could possibly be without breaking encapsulation.

If you're really at the point where that really matters, it's likely you have the resources to even maintain a specialized fork of Catalyst (and it would still probably be worth and more maintainable than a fast-but-crappy PHP solution - but then, writing a straight mod_perl handler with no framework would probably also be more maintainable).

Another thing you might consider would be to add another layer to your stack. We've found that catalyst is actually quite fast (30-70ms response time including database hit.) That could be increased if you added a cache to slow parts.

Also note: twitter is not a great example since they had some serious growing pains early on and actually rewrote core parts of their app in ErLang. You could do the same thing for your app.