Skip to content

Add support for event loop utilization based load limit #4288

@jonathansamines

Description

@jonathansamines

Support plan

  • is this issue currently blocking your project? (yes/no): no
  • is this issue affecting a production system? (yes/no): no

Context

  • node version: n/a
  • module version: n/a
  • environment (e.g. node, browser, native): n/a
  • used with (e.g. hapi application, another framework, standalone, ...): n/a
  • any other relevant information: n/a

What problem are you trying to solve?

Hapi currently supports limiting the server load by measuring the event loop delay and memory usage. Node recently introduced a new metric event loop utilization which is meant to more accurately measure the cpu utilization, a good candidate for this functionality:

ELU is similar to CPU utilization, except that it only measures event loop statistics and not CPU usage. It represents the percentage of time the event loop has spent outside the event loop's event provider (e.g. epoll_wait). No other CPU idle time is taken into consideration.

Do you have a new or modified API suggestion to solve the problem?

We could introduce a new option as part of the server load options:

  • server.options.load
    • maxEventLoopUtilization - maximum event loop utilization value in milliseconds over which incoming request are rejected with an HTTP Server Timeout (503) response. Defaults to 0 (no limit).
'use strict';

const Hapi = require('@hapi/hapi');

const server = Hapi.server({
  load: {
    maxEventLoopUtilization: 0,
  },
});

Metadata

Metadata

Assignees

No one assigned

    Labels

    featureNew functionality or improvement

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions