Does hapijs have something like overload protection?

What will the hapi server do if it is overloaded and there is something like toobusy-js to prevent the server from crashing by cutting down on some error requests.

+3


source to share


1 answer


Yes, it's built into the framework, look load

at the setup connections . You have 3 options:

  • maxHeapUsedBytes

    - the maximum V8 heap size by which incoming requests with a response to the HTTP server timeout are rejected (503). The default is 0 (no limit).
  • maxRssBytes

    - the maximum size of the RSS-format of the process by which incoming requests with a response to the HTTP server timeout are rejected (503). The default is 0 (no limit).
  • maxEventLoopDelay

    - the maximum duration of the event cycle delay in milliseconds, according to which incoming requests with a response are rejected for the server timeout (503). The default is 0 (no limit). `

And you shouldn't forget to set the sampling interval (time between two checks) on server.load

config:

  • sampleInterval

    - sampling rate in milliseconds. Default 0 (no sampling).

Example:



server config:

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

      

Connection configuration:

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

      

+5


source







All Articles