OpenNeo

Dress to Impress - Neopets wearables made easy

Jun 4

Upgrade successful!

Today we had some downtime here and there, but it was for a worthy cause :) In short, we swapped out some of the technology that runs Dress to Impress in order to reduce memory usage (that’s how much RAM the site is using) so that we can do more things at once.

Note that these changes involved moving to a different version of Ruby. I think I caught all of the major compatibility issues, but please keep an eye out for errors and report them when you see them.

Thanks for supporting Dress to Impress, both by spreading the word and donating to keep our super cool server running. You guys make it all possible :D

For the more technically minded…

Here’s the lowdown on our stack before the change. We were using the nginx web server (that’s kinda like Apache) as a proxy to share HTTP requests among three separate instances of Thin, a web server that runs Ruby on Rails applications like Dress to Impress. I originally chose this setup because Thin supports asynchronous connections: most servers can only handle one request at a time, which can be a problem if there’s one type of request that’s a serious bottleneck, like how typing a pet’s name into the box on the homepage means waiting on a request to Neopets.com, processing all that data, inserting it into the database, etc. However, asynchronous requests turned out to be too messy to implement, causing errors on various pages at random intervals. It would seem that the technology isn’t quite as polished as it needs to be. So, I instead left it at just having three Thin instances, since if one were busy loading a pet, the other two were probably free. (And loading a pet doesn’t really take that long, anyway.)

However, those Thin processes were running out of memory. Each Thin instance loaded up its own copy of Dress to Impress and all the libraries the site uses (and there are quite a few big ones!), which require a lot of RAM. This usually wasn’t a big problem, though once or twice a day Monit, our program that keeps an eye on the server, would restart a Thin process for taking up too much memory. Since it was only one at a time, y’all usually didn’t notice, since the other two stayed up; however, falling back on other servers is just our backup plan, and it’s not acceptable for that to happen regularly. Also, we’re working on a big feature that will take some serious processing power over the next few days—guess what it is!—so it’s important that we have significantly more RAM available without sacrificing the concurrency we get from multiple Thins.

So, we moved to Ruby Enterprise Edition via Phusion Passenger. That’s two important things there. The first is another version of the Ruby interpreter. Ruby is the programming language we use to make Dress to Impress, and there are a few different programs out there that run Ruby code. Ruby Enterprise Edition (REE) is a modification of the standard Ruby 1.8 interpreter, designed specifically to reduce memory usage. Phusion Passenger is another open-source project by the same company that replaces our Thin servers. Its main selling point is that it’s easy to plug into servers like Apache or nginx, but its best feature for us is that, when used with REE, Passenger also significantly reduces memory usage. It’s a clever trick: since every instance of Dress to Impress loads exactly the same fundamental application code, Passenger uses REE’s memory-sharing feature to only load one copy of the application code and share it among the application instances. So, instead of loading three separate copies of the app, we load three mini-servers that use the same application code. Much better for our memory usage by far :D

Hooray! We’re stable! Now the server is running more smoothly, and is able to also run a super cool background process or two…and those who stalk the Dress to Impress source code repository should know what they are for ;) It’ll be a few days until all that heavy-duty processing is done, but it will be so totally worth it. I’m excited.

Thanks for your continued support! It’s tons of fun to be able to make all this cool stuff for y’all. Here’s hoping you’ve enjoyed it :)