title: Lambda timeouts with calls to external api when scaling up
body: <p>I have set up a lambda A (Nodejs) which gathers data from other lambdas B,C,D,... by invoking them synchronously. These other lambdas call an external API. The issue is that when there is traffic, these other lambdas (B,C,D,  ...) timeout their request to this external API. With a single invokation of Lambda A, these other lambdas perform their external api http request in under a second, but under load, the time keeps increasing.</p>
  <p>The timeout is set at 10 seconds so reattempting can be made, but I tried changing this to a minute just to see if I get a response, and it does happen. It seems as if there is not enough of <em>something</em> available and subsequent requests get queued.</p>
  <p>There are no errors in logs (regarding hitting AWS limits) and I'm not hitting AWS Concurrency limits. I also thought I could be hitting burst concurrency limits, but there are no errors in logs.</p>
  <p><a href="https://i.stack.imgur.com/wbkTq.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/wbkTq.png" alt="enter image description here" /></a></p>
  <p>(Graph shows sum per minute)</p>
  <p>How can the ConcurrentExecutions be so high if there are only 366 invocations?</p>
  <p>I have started fiddling around with maxSockets (I wasn't aware that Infinity equals to only 50), but I'm thinking it is not set correctly at the moment. Could this however be the case, eq. it only can process 50 connections at a time and rest are queued?</p>
  <p>Code below (mock).</p>
  <pre class="lang-js prettyprint-override"><code>const soapConfig = {
    endpoint: 'https://soapapi.com',
    options: { timeout: 29000, time: true, pool: { maxSockets: Infinity },
      wsdl: `${__dirname}/ASC2021.wsdl`
    }
  }
  
  const handler = (event, context, callback) =&gt; {
    let processed = (async function () {
      let params = Object.assign({}, event.pathParameters, event.queryStringParameters)
      const client = await soap.createClientAsync(soapConfig.wsdl,
        soapConfig.options, soapConfig.endpoint)
      const result = await client.GetData(params, soapConfig.options)
      return result
    })()
    postProcess(processed, context, callback)
  }
  </code></pre>
  <p><code>AWS_NODEJS_CONNECTION_REUSE_ENABLED</code> is set to 1</p>
  <p>Could there <em>some</em> queue <em>somewhere</em> that I'm hitting?</p>
  <p>EDIT: I forgot to add that I have had detailed discussions with the API maintainer and the calls do not even reach said api. If timeout is raised to said 1 minute, the api receives the request but near the end of the request. There are also no limits on the API.</p>