Some more speed improvements
Posted by Myles Eftos on October 28, 2008 at 16:02
Over the past couple of weeks, I've been experimenting with some optimisations at all points of the 88 Miles stack — everywhere from code to database queries to database optimisation and Apache configuration. Because of the downtime today, I though I'd finish off some of those optimisations and push them live.
At the server level, 88 Miles is now running Passenger (aka mod_rails) instead of Mongrel, which better utilises memory and doesn't require the overhead of proxing. It's also a lot more reliable and stable (especially when it comes to restarting or pushing out new versions). Although I must admit, this mornings downtime was more to do with some overzealous settings than anything else — I think we are at a sweet spot now, so I don't think I'll need to touch it again for a while.
Much of the code for the core functionality was written quite a while a go, and was in dire need for a clean up. There was a lot of unnecessary iteration and object instantiation that resulted in really long load times for the main page (as well as for punching in and punching out). By pushing more of the work to the database and utilising the fact that a DB is better at searching for things than my code is, I managed a 4x speed increase.
However, that wasn't quite enough! By adding some database indexed to regularly used foreign keys, I managed to bump that speed increase to nearly 10x! And this is just the start — the priority at the moment is the speed and stability of the system.
Hopefully you will notice the speed increase — there is, of course, things out of my control, such as network latency and server load — however on the whole, you should be getting a much snappier 88 Miles experience.
