Not a Propaganda Machine

    node-inflight-requests

    1.0.1 • Public • Published

    node-inflight-requests

    Measure the number of inflight requests at any single time in your Node.js server.

    Install

    npm install node-inflight-requests
    

    Usage

    const http = require("http");
    const congestion = require("node-inflight-requests")();
    const server = http.createServer(serve);
     
    function serve(req, res) {
      const inflightReqs = congestion(res);
     
      console.log("No of requests in flight", inflightReqs);
     
      reportMetrics(inflightReqs);
     
      if (inflightReqs > 100) {
        res.statusCode = 503; // Service Unavailable
        res.setHeader("Retry-After", 10);
      }
     
      res.end();
    }

    License

    The MIT License (MIT)

    Copyright (c) 2019 Vignesh Shanmugam

    Install

    npm i node-inflight-requests

    DownloadsWeekly Downloads

    69

    Version

    1.0.1

    License

    MIT

    Unpacked Size

    3.14 kB

    Total Files

    4

    Last publish

    Collaborators

    • vignesh.shanmugam