3

I am currently using AWS Lambda for my internal application to application calls using spring framework implemented with jrestless.

Application to application call is working perfect with decent latency(~10-15ms ideally)

But when I am trying to leverage same lambda function via API Gateway the latency shoots up to 700-800 ms. Even though my lambda function is taking same 10-15 ms.

Lambda Function Configurations:

VPC: open(no vpc)
Region: ap-south-1(Mumbai)
Memory: 1500 MB(Highest)
Timeout: 5 min(Highest)

API Gateway Configurations:

Region: ap-south-a(Mumbai)
Request Integration: proxy+
Request Method: ANY

No Authentication is being used and its an HTTPS call.

Has anyone faced a similar issue?

nikhil1265
  • 77
  • 2
  • 12
  • Absolutely. 900-1200ms was typical for me, even with a pre-warmed Lambda function (which is a red herring issue from my perspective) for a "Hello World" equivalent returning JSON (their pet store example), from the region *closest* to mine. Meanwhile, a simple server program I wrote running on an EC2 micro instance 1) returning data from RDS, which should be even slower, in 2) the *farthest* region from me, was generally 600ms round trip at most, so typically one-half the response time and usually less. Responses from AWS representatives on questions like this have been less than satisfactory. – SexxLuthor Aug 16 '17 at 05:08

2 Answers2

3

I also have faced latency issues with api gateway but I don't have exact figures on that. However as of now by design api gateway has a latency issue and it's an ongoing.

https://forums.aws.amazon.com/thread.jspa?threadID=225458

According to the engineers I think 700ms is bit more high.

Just in case there is another concern with lambda as hot start and cold start. when you first call lambda latency is bit high. And there are couple of workarounds to overcome this as mentioned in the following blog post

https://serverless.com/blog/keep-your-lambdas-warm/

Asanka
  • 429
  • 3
  • 10
  • 1
    I have no issues with lambda cold start. Already have scheduler in place to keep my lambda function up and running. But because of api gateway latency I can't go live with production environment. – nikhil1265 Aug 03 '17 at 19:11
  • I just checked the minimum latency we have achieved in one our api gateway apis, and it's 260ms. However I found and an answer give by an api gateway engineer. https://stackoverflow.com/questions/41865304/can-will-aws-api-gateway-lambda-performance-be-improved. Unfortunately that's all I have as of now – Asanka Aug 04 '17 at 01:27
3
  1. If you are curious where the latency is introduced, API Gateway provides two CloudWatch metrics: Latency and IntegrationLatency. Latency is the total server-side latency recorded by API Gateway, and IntegrationLatency is only the latency of the backend request/response. The difference between these two metrics is the API Gateway server-side overhead. Any difference between client-side latency and the Latency metric will be network/TLS/connection latency.
  2. We have recently launched the 'Regional' endpoint type which is an option for use cases where the client is in the same AWS region as the API itself. This should bring your latency down closer to what you get when calling Lambda directly.
  3. Latency will generally improve with volume
  4. Lambda itself will always have overhead, and they do not expose the server-side overhead (unlike API Gateway). The duration exposed by Lambda is only the function duration that you are billed for. It does not indicate the total latency.
jackko
  • 6,998
  • 26
  • 38