Why are AWS Lambda Function URL cold starts 10X slower?

0

I have a Lambda function written in Go that has a cold start of 150ms

When I invoke the function via the function url the function executes in > 1.5s

Why are cold starts 10X worst when using a function url?

  • Can you please include more information as to how you are measuring the cold start durations?

  • I just tried a custom runtime with a similar result. Here is the function log:

    REPORT RequestId: dc459ec7-f341-45e1-a757-8a61e57ad245 Duration: 53.82 ms Billed Duration: 969 ms Memory Size: 128 MB Max Memory Used: 107 MB Init Duration: 915.04 ms

    The function URL responded to the browser request in almost 5 seconds.

asked a year ago555 views
2 Answers
0

There's not much advice I can offer here other than to take a look at this blog post. I'm not familiar (enough) with Go to provide specific advice but for most runtimes in Lambda I'd encourage "lazy invocation" of various libraries and startup components; or look at using provisioned concurrency (more information in the blog post).

profile pictureAWS
EXPERT
answered a year ago
  • Thanks for trying to help. I'm familiar with that blog post and I've also tried other runtimes. It seems like Function URLS have much slower cold starts regardless of language.

-1

When you invoke a Lambda function directly, the request is sent straight to the Lambda service. However, when you use a function URL, the request typically goes through API Gateway or an Application Load Balancer before it reaches the Lambda function. This extra hop adds an additional layer of processing and network latency, which can contribute to the increased cold start time.

There maybe some workarounds about this

  • Make sure the API Gateway or Application Load Balancer and the Lambda function are in the same region to reduce network latency.
  • Use provisioned concurrency for your Lambda function to reduce the cold start time.
  • Optimize your API Gateway settings, such as caching and logging, to reduce the latency introduced by API Gateway.
  • Review and optimize the configuration of the Application Load Balancer, such as target group settings and health checks, to reduce latency.
profile picture
EXPERT
answered a year ago
  • Can you mention an official resource about lambda function urls being based on api gateway and/or application load balancer, as information seems incorrect?

  • I don't believe Lambda Function URLs use API Gateway or Application Load Balancer. It is a feature managed by AWS so it is probably some sort of load balanced service that they have setup. After the cold start the Function URL is faster than API Gateway and it is free. No brainer for my use case. However, the longer cold start times don't really make sense.

  • It's not using API Gateway or Application Load Balancer, everything is wrong in this answer.

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.

Guidelines for Answering Questions