Alinex
Alinex

Reputation: 979

Does hapijs have something like overload protection?

What will a hapi server do if it is overloaded and is there something like toobusy-js to prevent a fallout of the server by shortcutting some requests with errors.

Upvotes: 3

Views: 1312

Answers (1)

Pierre Inglebert
Pierre Inglebert

Reputation: 3930

Yes it's embedded in the framework, look at load on connections settings. You have 3 options :

  • maxHeapUsedBytes - maximum V8 heap size over which incoming requests are rejected with an HTTP Server Timeout (503) response. Defaults to 0 (no limit).
  • maxRssBytes - maximum process RSS size over which incoming requests are rejected with an HTTP Server Timeout (503) response. Defaults to 0 (no limit).
  • maxEventLoopDelay - maximum event loop delay duration in milliseconds over which incoming requests are rejected with an HTTP Server Timeout (503) response. Defaults to 0 (no limit). `

And you must not forget to set a sample interval (time between 2 checks) on server.load config:

  • sampleInterval - the frequency of sampling in milliseconds. Defaults to 0 (no sampling).

Example :

server configuration :

{
  "load": {
    "sampleInterval": 1000
  }
}

connection configuration :

{
  "load": {
    "maxHeapUsedBytes": 1073741824,
    "maxRssBytes": 1610612736,
    "maxEventLoopDelay": 5000
  }
}

Upvotes: 8

Related Questions