Does hapijs have something like overload protection?

隐身守侯 提交于 2019-12-10 19:33:01

问题


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.


回答1:


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
  }
}


来源:https://stackoverflow.com/questions/31817534/does-hapijs-have-something-like-overload-protection

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!