user3640506
user3640506

Reputation: 21

Heroku: How to properly scale out node.js app?

I'm hosting my site on heroku and we're experiencing severe performance issues.

Basically it's a node.js/express app serving both static html (AngularJS) and REST APIs to be consumed by the client.

Deployment is near so we started benchmarking with JMeter and the results make no sense whatsoever - adding web dynos made no impact at all.

At first I thought maybe our code is at fault but I'm already pretty sure that Heroku is at fault because we get the same results when benchmarking some static image or html. Just to make sure none of my express middleware is causing the problems I've put the static file serving on the top of the express stack.

Thanks in advance.

Upvotes: 1

Views: 636

Answers (2)

user3640506
user3640506

Reputation: 21

So it turns out that the Heroku router was playing tricks on us. Our test wasn't really relevant as all of the requests were made from a single IP address.

Just noticed this question is still open, so for anyone else out there who experiences the same problems.

Upvotes: 0

Steve N
Steve N

Reputation: 2737

Be sure to avoid any console.log calls in your production environment, as well as any logging middleware like app.use(express.logger()), etc as these can have a very negative impact on performance for Heroku node.js apps.

I have something like the following in one of my apps:

if (process.env.NODE_ENV !== 'production') {
    app.use(morgan('dev'));
} else {
    console.log = function () {};
}

See here for a discussion of this phenomenon: http://micheljansen.org/blog/entry/1698

Upvotes: 1

Related Questions