Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Slow init/scaling #358

Closed
four43 opened this issue Jan 25, 2024 · 2 comments
Closed

Slow init/scaling #358

four43 opened this issue Jan 25, 2024 · 2 comments

Comments

@four43
Copy link

four43 commented Jan 25, 2024

Hello,

First of all this is a great project! We absolutely love it and it extends the functionality of Lambda really nicely in a relatively simple way.

We are experiencing slow init times however when using this in our environment.

Lambda base image init: 250ms with some spikes up to 2000ms
Lambda base image with lambda-web-adapter starting FastAPI: 5111ms! (This is very consistent for a cold start)

The FastAPI code being started is their very basic hello world getting started example:

test_api/__init__.py

from fastapi import FastAPI

app = FastAPI()


@app.get("/")
async def root():
    return {"message": "Hello World"}

And it's started from the Dockerfile:

FROM aerisweather/geo-base-python3.10:base-v8
WORKDIR /app

RUN pip install fastapi "uvicorn[standard]"

## Enable Lambda triggered web server
COPY scripts/lambda-adapter /opt/extensions/lambda-adapter
ENV PORT=8000

COPY ./test_api ./test_api

ENTRYPOINT [ ]
CMD exec uvicorn --host 0.0.0.0 --port=$PORT --forwarded-allow-ips='*' --workers=1 test_api:app

The lambda logs don't seem to reflect the long startup init process:
image

Any tips on speeding this up?

Thanks a lot!

@bnusunny
Copy link
Contributor

bnusunny commented Jan 26, 2024

Hmm, I usually see high cold start times in the first a few cold starts after the function is created or updated. This is because of the cold cache in Lambda Service. However, the cold starts after that are much faster. See the test results here.

Could you deploy the FastAPI example and check the cold start time?

@four43
Copy link
Author

four43 commented Jan 26, 2024

That is an awesome analysis in that other thread! Thank you so much for that. I apologize that didn't show up in my search. I think the discussion over there and your tips are enough. Thank you very much!

@four43 four43 closed this as completed Jan 26, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants