Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there any overhead when using ASGI based FastAPI for AWS Lambda?

Can you please advise, if there are any issues with using of FastAPI Web Framework in AWS Lambda:

  • What framework capabilities will be lost if using in AWS Lambda environment?
  • Is there any overhead associated with ASGI technology or anything else, e.g. when we have to use additional libraries like Magnum?
like image 280
Viji Avatar asked Jun 18 '26 23:06

Viji


1 Answers

We have been using the API gateway -> AWS Lambda -> Mangum -> FastApi combo in production for 3-4 months now and have had no issues.

The restrictions come from the fact that Lambda is a sync request/reply setup.

  • Less benefit from async ( async inside the request but not between requests). AWS lambda will create a container/python process for each request so while your code is awaiting a call in a request it won't move on to the next request.
  • No response streaming bodies.(use s3 for files etc)

The overhead is tiny, Mangum is super light ( see how little code is in: https://github.com/jordaneremieff/mangum/tree/main/mangum) its basically just restructuring the input dictionary.

like image 98
Nath Avatar answered Jun 21 '26 13:06

Nath



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!