You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Comparison between AWS Web Adapter and (Python) Mangum + Fastapi #283
Hi, Just saw the presentation and was thinking, performance-wise (mainly cold-start time) how would this compare to using the Mangum adapter + a framework (such as fastapi).
I don't have exact numbers to share. In general, a framework adds a bit of cold-start time because it starts a full-blown web server.
Fastapi with Uvicorn usually adds about 100~200ms cold-start time. Usually it is a worthy trade off for the productivity and portability gain.
The main goal of this project is to provide an easy on-ramp for people new to Lambda, and wants to start building a Serverless Web App using familar tools and frameworks. In addition, people found that this tool help to migrate existing web apps to Lambda without requiring major refactoring of the exiting code base, such as this one.
I agree, portability is the key-word.
I wouldn't be so humble to say this is just an easy on-ramp, perhaps this is a true game-changer! (I wish I'd known about this before. I went the Mangum way (which I do not regret)).
Regarding the overhead, 100-200 ms doesn't bother me at all.
My question is: how about the full startup (cold-start) time (consider no db connection, just a hello-world using: minimal Dockerfile (python Alpine?), uvicorn, fastapi). I'd like to know that number (which is very hard to measure from the outside of AWS)
Here come the results: the cold start time is actually pretty close for LWA and Mangum, within 100ms.
Test setup: two Lambda functions (256MB memory) with Http API endopoints, triggered every 10 minutes to ensure we hit cold start every time. I collected 144 data pointes over 12 hours (excluding the first a few outliers caused by the cold cache in Lambda). The latenency data is from Http Api's IntegrationLatency metric, which is the end-to-end latency of Lambda invoke.
Here is the Http Api IntegrationLantecy over different percentiles. LWA is faster at high percentil p99 and p100. Mangum is faster at lower percentil P90 to P0. The difference is less than 100ms.
Here is the lantency graph over 12 hours.
And here are two samples of x-ray traces.
LWA
Mangum
Reacted by Carlos Garcés, gabriels1234 and Seth Miller
Thanks so much!
The numbers you got are good enough to start testing it on real projects.
The only metric missing would be from a warm-start, would those 100ms be equally present with the lambda adapter vs mangum?
Activity
bnusunny commentedon Sep 14, 2023
I don't have exact numbers to share. In general, a framework adds a bit of cold-start time because it starts a full-blown web server.
Fastapi with Uvicorn usually adds about 100~200ms cold-start time. Usually it is a worthy trade off for the productivity and portability gain.
The main goal of this project is to provide an easy on-ramp for people new to Lambda, and wants to start building a Serverless Web App using familar tools and frameworks. In addition, people found that this tool help to migrate existing web apps to Lambda without requiring major refactoring of the exiting code base, such as this one.
gabriels1234 commentedon Sep 14, 2023
I agree, portability is the key-word.
I wouldn't be so humble to say this is just an easy on-ramp, perhaps this is a true game-changer! (I wish I'd known about this before. I went the Mangum way (which I do not regret)).
Regarding the overhead, 100-200 ms doesn't bother me at all.
My question is: how about the full startup (cold-start) time (consider no db connection, just a hello-world using: minimal Dockerfile (python Alpine?), uvicorn, fastapi). I'd like to know that number (which is very hard to measure from the outside of AWS)
gabriels1234 commentedon Sep 14, 2023
Moreover: would you say that in absolute numbers, an adapter made of Mangum vs the AWS lambda adapter, is Mangum going to be faster? by many ms?
bnusunny commentedon Sep 14, 2023
I will do a test in this weekend and post the resultes here.
bnusunny commentedon Sep 17, 2023
Here come the results: the cold start time is actually pretty close for LWA and Mangum, within 100ms.
Test setup: two Lambda functions (256MB memory) with Http API endopoints, triggered every 10 minutes to ensure we hit cold start every time. I collected 144 data pointes over 12 hours (excluding the first a few outliers caused by the cold cache in Lambda). The latenency data is from Http Api's IntegrationLatency metric, which is the end-to-end latency of Lambda invoke.
Here is the Http Api IntegrationLantecy over different percentiles. LWA is faster at high percentil p99 and p100. Mangum is faster at lower percentil P90 to P0. The difference is less than 100ms.
Here is the lantency graph over 12 hours.
And here are two samples of x-ray traces.
LWA

Mangum

bnusunny commentedon Sep 17, 2023
Here is the function code and docker files used in the test.
gabriels1234 commentedon Sep 18, 2023
Thanks so much!
The numbers you got are good enough to start testing it on real projects.
The only metric missing would be from a warm-start, would those 100ms be equally present with the lambda adapter vs mangum?
bnusunny commentedon Sep 18, 2023
No, for warm-start, it is very close: almost identical at p50.
bnusunny commentedon Sep 20, 2023
@gabriels1234 I'm closing this issue. Feel free to open new ones if additional questions come up.
hamilton-earthscope commentedon Dec 21, 2023
I just learned about LWA today and had this exact same question. Thank you so much @bnusunny for the thorough comparison. Super helpful!!