MongoDB Lesson Learned: Remeber To Use Indexes

After launching my first node.js + MongoDB API in production, I was religiously monitoring it like parents watching over their first born child.

As traffic started to roll in, the API server began to quietly cry. The average response in milliseconds increased as more and more concurrent queries were happening in the DB. But this wasn’t happening on my local development environment when I was running three times more traffic in my stress tests. Of course localhost beats the production environment any day of the week right?

Long story short, I forgot to enable indexes on the production environment. After adding db.collection.ensureIndex({"items": 1}) to the most important key that I was querying, the beams of sun broke through the cloudy sky.

Lets look at the difference in our famous before and after example:

Before
> GET /sites/?… 200 2691ms – 128b

After
> GET /sites/?… 200 91ms – 128b

And a chart for giggles

API response time

Thanks to the awesome folks that make these amazing tools

Update: 2/11/13

On a side note, this small instance was able to handle over 1.5k requests per minute without ever breaking a sweat. Big ups OpenShift.

Advertisements

WampServer Problems with Skype on Port 80

For those who have tried to start WampServer with Skype already running, you might have been faced with the yellow icon in the windows notification area and WAMP not starting. This is because Skype is using Port 80 and 443 as alternatives for incoming connections and apache wants to listen to Port 80 as well, therefore causing WAMP to not start up.

To disable Skype from using Port 80 and 443, go to Tools > Options > Advanced > Connection, then uncheck the ‘Use port 80 and 443 as alternatives for incoming connections’.

Screenshot of disabling port 80 in Skype

Now close Skype, and restart WAMP by left clicking the WAMP icon in the system notifications and selecting ‘Restart All Services’ under ‘Quick Admin’.

My suggestion to anyone who is having this problem is close all other programs that might be listening to Port 80 on your computer and then open up WAMP.