We are a team of 10 developers, trying to move process intensive jobs from our Rails application on Heroku to AWS Lambda (Java). We are blocked on deciding whether to invoke lambda functions via API gateway or via AWS Ruby SDK directly. Depending on the use case, we might have to invoke lambda asynchronously as well. Our payload is very small (< 1-2 KB). We are considering direct invocation primarily to maximise execution time. We are looking for pointers here:
As others have stated, adding API Gateway does not improve performance but does add extra overhead. Use API Gateway if any of the additional feature it provides are useful to you. If you control the client, can get credentials on the client with permissions to invoke your Lambda functions directly, and don't need/want any of the additional API Gateway features, the go with the Lambda direct invoke.
Direct lambda calls are faster b/c there's one network hop less. I doubt you can directly compare lambdas/APIG with regard to latency of IAM verification, but we've benchmarked lambda-lambda calls and lambda-APIG-lambda calls, where the lambdas do no work, i.e. simply return the event object. The average timings are as follows:
lambda-lambda: 27ms
lambda-APIG: 47ms
So the tax for the extra hop is 20 ms. We use lambda-lambda calls whenever feasible, especially with lambdas we don't want to expose to the world.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With