Aws api gateway really slowly

Hello Guys,

I started testing serverless framework today and it is awesome, but i’m having a problem with AWS that I’d like to know if anyone is also experiencing.

After creating the basic project with hello world function I attached the http event to use API Gateway and for my surprise the response time is taking around ~550ms

I know there would be some latency since I’m in São Paulo making requests to us-east-1, but this is just way above my expectations

So, is just me or there are other people facing this problem? Is there any recommendations to improve performance on API Gateway?

@renanosf what is your Lambda execution time? I assume it is very quick for a hello world, but it is worth asking.

Just 2ms testing from the lambda console

We use runscope to monitor our endpoints. We see similar latency from the Brazil location. I’m not sure about methods of improving this other than developing a multi-region architecture. Would like to see if others have solutions.

Well, I hope aws to launch api gateway and lambda in São Paulo region anytime soon. Although I’m not sure about that after all that time without it.

Just to be perfectly clear, you did try doing multiple requests? Because first request is supposed to be slower but subsequent requests are faster.

I get similar latency from EU to US with my first request, but it’s good afterwards.

I did a test with 1000 requests and the average time was 551ms.

Now the weird part of the test is that once in a while the request returns in ~200ms as I was previously expecting

I have similar issues from Sydney to us-east-1 and us-west-2. For example: I have a Rails app hosted in us-west-2 that responds in about 450ms but the Lambda function via the API GW is taking 750ms despite the Lambda function itself running in less than 50ms. us-east-1 was even worse at 950ms and you needed to double those times from a user perspective if it triggers a CORS pre-flight check.

In the end I’ve decided to no worry about it. I can find ways to keep the response times within acceptable limits and being able to easily scale wins.

1 Like

Is API gateway always putting 200-300ms of latency in front of lambda requests:

It’s an ongoing problem:
https://forums.aws.amazon.com/thread.jspa?threadID=225458

Has anyone found a way around it? It seems Lambda + API Gateway only avoids this latency if your app is already so large that you’re doing 100 requests per second (per function).