繁体   English   中英

如何使用JS SDK增加AWS Lambda的连接限制

[英]How to increase connectionlimit for aws lambda with js sdk

目前,我最多只能同时执行50个 lambda函数。 是因为我必须设置ConnectionLimit

使用aws .net skd,我可以通过以下方式进行设置:

new AmazonLambdaClient(new AmazonLambdaConfig
    {
        ConnectionLimit = 200,
        RegionEndpoint = RegionEndpoint.APSoutheast2
    });

///这是我用来调用lambda的代码

// Load the AWS SDK for Node.js
var AWS = require('aws-sdk');
// Set the region 
AWS.config.update({region: 'ap-southeast-2'});
var lambda = new AWS.Lambda();

function fireLambda(){
    var lambdaParams = {
        FunctionName: "testLambda", 
        InvocationType: "RequestResponse", 
        LogType: "Tail", 
        Payload: '{"msgCount": 888}'
       };

   lambda.invoke(lambdaParams, function(err, data) {
         if (err){
            console.log(err, err.stack); // an error occurred
         }else{
            console.log(data);           // successful response
         }

         fireLambda();
       });
}

exports.handler = (event, context, callback) => {
    let maxCount = event.maxConcurrentCount || 50;

    setTimeout(() => {
        process.exit(1);
    }, 8000);
    while(maxCount > 0)
    {
        maxCount--;
        fireLambda();
    }
};

另外,此Lambda的最大并发限制设置为300

我认为您应该看看: AWSjavascriptSDKdoc

具体来说,需要参数的函数putFunctionConcurrency

- FunctionName = name of the function you are setting concurrent execution limits on.
- ReservedConcurrentExecutions = concurrent execution limit number

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM