Invoking lambda to lambda 22 times concurrent taking too much time

Viewed 575

I am invoking lambda_B 22 times(asynchronously) from lambda_A, Single lambda_B call completes execution in 3 sec so according to this when i am invoking 22 lambda asynchronously so it should take time around 3 sec. But its taking time 16-20 sec

Here is sample code i am using

async callingLambda(arrayvalue) {
  try {
    const lambdaResponse = await BPromise.all(
      arrayvalue.map((leg) => {
        return new BPromise((resolve, reject) => {
          const FunctionName = 'Lambda_B';
          lambda.invoke({
            FunctionName: FunctionName,
            InvocationType: 'RequestResponse',
            LogType: 'Tail',
            Payload: JSON.stringify(reqParmaters)
          }, function(error, data) {
            if (error) {
              reject(error);
            } else {
              resolve(body.errors.length ? null : body.data);
            }
          });
        });
      })
    );
    return lambdaResponse;
  } catch (error) {
    return BPromise.reject(error);
  }
}

i have made few observation that is if i decrease no of calls to 4-6 then its take around 3 sec but when i increase the no of calls time is increased as well.

According to my research this issue may be arise due to the no. of I/O operation handled by nodejs parallelly is equal to UV_THREADPOOL_SIZE and default value of UV_THREADPOOL_SIZE is 4.

I have also increase the size of UV_THREADPOOL_SIZE but its not working.

1 Answers
Related