5 reasons why your code is running so slowly—and how to fix it

Here’s how to address why the code runs well on your development machine but has totally borked in production

Become An Insider

Sign up now and get FREE access to hundreds of Insider articles, guides, reviews, interviews, blogs, and other premium content. Learn more.

If your lovingly crafted application is running slowly after deployment, there are five common reasons it runs well on your development machine but has totally borked in production.

There are of course other reasons why your software doesn’t work well in production, but these are the top reasons I’ve seen when developers say “it runs fine on my machine” and then discover that with great volume comes great responsibility for the concerns of scale.

Cause No. 1: You have one big thread

In some modern frameworks (like Node.js), threading is handled for you. You’re supposed to make the right nonblocking I/O calls at the right time to go do things and have your main line of code clean of a lot of heavy lifting. Failing that, you can start to starve the system of actual threads.

If you have this problem, it begs some questions. The most basic is: If you’re doing a major algorithm inside of some JavaScript running in Node.js, whether Node.js and (gasp) JavaScript is the right technology to use here? If you must, you need to learn about how Node.js handles concurrency and how to avoid blocking the event loop. You need to learn how to submit work to a workerpool instead. You may even have to learn (gasp!) about threads.

Cause No. 2: Your database is !@#$

To continue reading this article register now