# Aws api gateway really slowly

**URL:** <https://forum.serverless.com/t/aws-api-gateway-really-slowly/644>\
**Category:** Serverless Framework\
**Tags:** aws\
**Created:** [October 26, 2016, 10:36pm UTC](https://forum.serverless.com/t/aws-api-gateway-really-slowly/644 "2016-10-26T22:36:02Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![renanosf](https://yyz2.discourse-cdn.com/flex036/user_avatar/forum.serverless.com/renanosf/32/1057_2.png) [@renanosf](https://forum.serverless.com/u/renanosf)\
**Post date:** [October 26, 2016, 10:36pm UTC](https://forum.serverless.com/t/aws-api-gateway-really-slowly/644/1 "2016-10-26T22:36:02Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![johncmckim](https://yyz2.discourse-cdn.com/flex036/user_avatar/forum.serverless.com/johncmckim/32/27_2.png) [@johncmckim](https://forum.serverless.com/u/johncmckim)\
**Post date:** [October 26, 2016, 11:52pm UTC](https://forum.serverless.com/t/aws-api-gateway-really-slowly/644/2 "2016-10-26T23:52:12Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![renanosf](https://yyz2.discourse-cdn.com/flex036/user_avatar/forum.serverless.com/renanosf/32/1057_2.png) [@renanosf](https://forum.serverless.com/u/renanosf)\
**Post date:** [October 27, 2016, 12:17am UTC](https://forum.serverless.com/t/aws-api-gateway-really-slowly/644/3 "2016-10-27T00:17:27Z")

</div>

Just 2ms testing from the lambda console

---

<div class="post-metadata">

**Author:** ![johncmckim](https://yyz2.discourse-cdn.com/flex036/user_avatar/forum.serverless.com/johncmckim/32/27_2.png) [@johncmckim](https://forum.serverless.com/u/johncmckim)\
**Post date:** [October 27, 2016, 12:24am UTC](https://forum.serverless.com/t/aws-api-gateway-really-slowly/644/4 "2016-10-27T00:24:04Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![renanosf](https://yyz2.discourse-cdn.com/flex036/user_avatar/forum.serverless.com/renanosf/32/1057_2.png) [@renanosf](https://forum.serverless.com/u/renanosf)\
**Post date:** [October 27, 2016, 12:54am UTC](https://forum.serverless.com/t/aws-api-gateway-really-slowly/644/5 "2016-10-27T00:54:09Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![enesdo](https://avatars.discourse-cdn.com/v4/letter/e/ea666f/32.png) [@enesdo](https://forum.serverless.com/u/enesdo)\
**Post date:** [October 27, 2016, 6:58am UTC](https://forum.serverless.com/t/aws-api-gateway-really-slowly/644/6 "2016-10-27T06:58:16Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![renanosf](https://yyz2.discourse-cdn.com/flex036/user_avatar/forum.serverless.com/renanosf/32/1057_2.png) [@renanosf](https://forum.serverless.com/u/renanosf)\
**Post date:** [October 27, 2016, 2:16pm UTC](https://forum.serverless.com/t/aws-api-gateway-really-slowly/644/7 "2016-10-27T14:16:38Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![buggy](https://yyz2.discourse-cdn.com/flex036/user_avatar/forum.serverless.com/buggy/32/177_2.png) [@buggy](https://forum.serverless.com/u/buggy)\
**Post date:** [October 29, 2016, 10:47am UTC](https://forum.serverless.com/t/aws-api-gateway-really-slowly/644/8 "2016-10-29T10:47:29Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![faceyspacey](https://yyz2.discourse-cdn.com/flex036/user_avatar/forum.serverless.com/faceyspacey/32/506_2.png) [@faceyspacey](https://forum.serverless.com/u/faceyspacey)\
**Post date:** [March 10, 2017, 9:26am UTC](https://forum.serverless.com/t/aws-api-gateway-really-slowly/644/9 "2017-03-10T09:26:22Z")

</div>

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

> **[AWS latency comparison: API Gateway vs Lambda vs Bare EC2](https://www.prerender.cloud/lambda-latency)**
>
> AWS Lambda, API Gateway and EC2 latency compared over a 24 hour period within the us-east-1 region

It’s an ongoing problem:  
[https://forums.aws.amazon.com/thread.jspa?threadID=225458](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).
