简体   繁体   中英

How to call same AWS Lambda function concurrently?

I have a AWS lambda function which process data and returns calculated results, then results saved to the db by java backend. Each call takes approximately 2-3 seconds. I followed this tutorial and successfully invoked lambda function from java. But my payload is big and I want to split it and call same function multiple times. One way of doing it is using many threads. My question is, is there any better way of doing this? Does aws lambda library has support for it?

Example payload:

{
user_1: data_1,
user_2: data_2,
...
user_300: data_300
}

I simply want to call lambda function for each user and finish processing of all users data less than 5 seconds.

UPDATE: One way is using Asynchronous Programming as stated in the documentation. Another way can be adding an API Gateway and doing async post request.

To me, Lambda should be as lightweight as possible. Doing 4MB of payload, looks like you need a different approach.

S3 bucket will do, but I prefer API gateway with something like How do you create an asynchronous HTTP request in JAVA? , using multiple threads on the producer of that information.

Yes, definitely, I would go for the API gateway approach in which you can still use for smaller payloads as well.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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