CQM
CQM

Reputation: 44278

node.js on heroku hobby dyno, limitations

I am having trouble grasping the performance limitations of using node with a Heroku Hobby dyno, a type which contains just 1 web worker.

My heroku server is used to respond to post requests and initiate server to server communication. We will call this 'the process'.

Node.js is javascript and has only one event loop, does this mean that if my heroku server is not already done the with the process, that it will be unable to initiate another one?

Client side, a user sends one post request, which launches 'the process'.

If the process is not complete, can a second user send another post request and expect anything to happen? Will my server hang until the first process is done?

In my preliminary testing it almost seems like it has no problems with two users sending nearly simultaneous requests, so I'm not sure what limitation I would hit

Upvotes: 1

Views: 1595

Answers (1)

cinnaroll45
cinnaroll45

Reputation: 2800

This is not an issue according to Heroku's docs, you'll be able to handle multiple requests without a problem with Node.js.

Dynos and requests

A single dyno can serve thousands of requests per second, but performance depends greatly on the language and framework you use.

A single-threaded, non-concurrent web framework (like Rails 3 in its default configuration) can process one request at a time. For an app that takes 100ms on average to process each request, this translates to about 10 requests per second per dyno, which is not optimal.

Single threaded backends are not recommended for production applications because of their inefficient handling of concurrent requests. Choose a concurrent backend whenever developing and running a production service.

Multi-threaded or event-driven environments like Java, Unicorn, EventMachine, and Node.js can handle many concurrent requests. Load testing your app is the only realistic way to determine request throughput.

Further reading:

On dynos: https://devcenter.heroku.com/articles/dynos#dyno-types

On jobs and queueing: https://devcenter.heroku.com/articles/background-jobs-queueing

Async Workers: https://devcenter.heroku.com/articles/asynchronous-web-worker-model-using-rabbitmq-in-node

Upvotes: 3

Related Questions