Why is node.js only processing six requests at a time?

前端 未结 6 1730
长情又很酷
长情又很酷 2020-11-27 10:35

We have a node.js server which implements a REST API as a proxy to a central server which has a slightly different, and unfortunately asymmetric REST API.

Our client

6条回答
  •  有刺的猬
    2020-11-27 11:22

    How are you getting data from the central server? "Node does not limit connections" is not entirely accurate when making HTTP requests with the http module. Client requests made in this way use the http.globalAgent instance of http.Agent, and each http.Agent has a setting called maxSockets which determines how many sockets the agent can have open to any given host; this defaults to 5.

    So, if you're using http.request or http.get (or a library that relies on those methods) to get data from your central server, you might try changing the value of http.globalAgent.maxSockets (or modify that setting on whatever instance of http.Agent you're using).

    See:

    • http.Agent documentation
    • agent.maxSockets documentation
    • http.globalAgent documentation
    • Options you can pass to http.request, including an agent parameter to specify your own agent

提交回复
热议问题