0

I am having my node.js backend application ready with multiple APIs so now I want to scale my application.

Let's say now I have 10 APIs exposed on my node.js server and if 1 API gives me 3 sec/API, then how much time it will take for parallel access of 10 APIs.

I have to test the above mentioned scenario. What factors matter for it to calculate response time?

Wyck
  • 10,311
  • 6
  • 39
  • 60

2 Answers2

0

Node can handle up to 10000 simultaneous requests. It has a single thread which takes care of every request.

Heare a nice explanation:

https://stackoverflow.com/a/34857298/11951081

However, you could run several node processes on different ports behind a load balancer (Nginx or Apache) with a round-robin configuration.

Anyway, based what are you doing on your service, you could also consider to cache response

0

It can handle multiple request parallel(same time) and won't take extra time for other requests, Nodejs is single-threaded asynchronous language and it depends on CPU, RAM. if you want to see response time you can use morgan npm package.

Small Setup for App.js

npm i morgan
var morgan = require('morgan')
app.use(
  morgan(function (tokens, req, res) {
    return [
      chalk.cyanBright(moment(tokens.date(req, res))
        .format("MMM D YYYY, h:mm:ss A")),
      tokens.method(req, res),
      tokens.url(req, res),
      chalk.greenBright(tokens.status(req, res)),
      tokens.res(req, res, 'content-length'), '-',
      tokens['response-time'](req, res), 'ms'
    ].join(' ')
  })
); 
Ankit Kumar Rajpoot
  • 5,188
  • 2
  • 38
  • 32
  • morgan is not really necessary to benchmark api responses inbuilt `console.time()` and `console.timeEnd()` would just do fine. – ambianBeing Aug 28 '19 at 14:27