Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
149 views
in Technique[技术] by (71.8m points)

java - 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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

1.4m articles

1.4m replys

5 comments

56.7k users

...