1
votes

I am using AWS and SES to send Emails and Sms through lambda function using NodeJs and I need to make more than 1k or 500 REST API calls, the average call takes 3sec to execute single lambda function request so I need process multiple requests in the single request so that we can save billing because of every single request lambda trigger bill generated.

  1. AWS SQS receive message limit that 1 to 10 message receive SQS Limit Number of message

    My question is how can we proceed with multiple messages on once AWS lambda function trigger so that we can save billing because every API request one MySQL connection created if I do this for 1k it create 1k mysql connection and it crash MySQL while executing

2
A question, what are you fetching from MySQL DB in the query ?Ankit Deshpande

2 Answers

0
votes

every API request one MySQL connection created if I do this for 1k it create 1k mysql connection and it crash MySQL while executing

Two approches are commonly employed.

  1. Execution context reuse. You open up connection to db outside your lambda handler. Its good chance that lambda we reuse same execution context for your next request, thus you can reuse previously open connection.

  2. Amazon RDS Proxy. The proxy "allows applications to pool and share connections established with the database, improving database efficiency and application scalability".

Appart from that, RDS can handle many more connections than 1000. The upper limits on the number of connections are listed:

0
votes

My take on this would be an cloudwatch scheduled event to trigger the lambda every 10 minutes, for instance, and process everything on the SQS pool, instead of triggering it when it receives a message.