haha, I wish I could tell you about the exact performance gain in the version of Hab.la that I just pushed to production. However, we don’t really have a great method of benchmarking code outside of production and so we won’t really know the TRUE speed ups until we have a few hours of statistics generated from actual use.
What I can tell you is that I have spent the last week or so refactoring the backend RPC server that handles the connection between Jabber and the JavaScript widget to make the code much cleaner, and the session management far better.
Here’s a brief summary comparing the new setup with the old setup.
Old method of session management: mysql
Minimum of 2 SQL calls per RPC call. I.e. we load the session from mySQL perform updates on it, and save it back to SQL one time per hit. We were doing this over 200,000 times a day, generating approximately 400,000 SQL calls from session management alone (200,000 writes).
New method of session management: MemcacheD
Unlike most high traffic sites that use MemcacheD we don’t have to perform a MySQL write every time a session is updated. Therefore memcacheD not only reduced mysql reads, it also reduces mysql writes. We now only write conversation buffer changes to Mysql. This means that instead of updating the mysql copy of the Hab.la session each time a visitor hits the RPC server, we only write it to SQL when an important event occurs (i.e. a message is sent), so if a server goes down we might lose our temporary record of what page your visitor is on – but won’t lose the conversation.
We get about 3,000 messages sent on Hab.la a day. So this reduces our number of mysql writes to about 3,000 + the number of visitors we handle a day (currently about 12,000 on average). So 200,000 mysql writes, becomes 15,000 mysql writes, and 200,000 mysql reads, becomes 0 session related mysql reads.
Of course there are other mysql related reads that occur during session setup, and before initiating a chat, but the vast majority of our reads and writes come from session handling, and the new memcacheD option pretty much eliminates the need to read from mysql to get session data.
In the coming weeks I will be phasing out even more of the mysql reads, to continue to make it easy for Hab.la to scale going forward.
As always, please let me know if you are experiencing any problems with the new RPC server, it passes my unit tests, and I haven’t seen anything in the error log, but that doesn’t mean there aren’t conditions we’ve overlooked.
Comments [0]