-
First Check
Commit to Help
Example Code# Dockerfile Configuration
FROM <base_image>
COPY requirements.txt /app/requirements.txt
RUN pip install --no-cache-dir --upgrade -r /app/requirements.txt
COPY . /app/
# CMD ["gunicorn", "--preload", "--timeout", "0", "-kuvicorn.workers.UvicornWorker", "-w", "3", "--threads", "8", "--log-file", "-"]
CMD ["uvicorn", "main:app", "--port", "8000", "--host", "0.0.0.0", "--workers", "4"]
# CMD ["gunicorn", "--preload", "--timeout", "0", "-w", "4", "-k", "uvicorn.workers.UvicornWorker", "--threads", "9", "--bind", "0.0.0.0:8000", "main:app"]>DescriptionI have an AI based API built with FastAPI. When I run locally in a docker container and test concurrency with Apache Benchmark I get successful results. However, when I deploy to Google Kubernetes Engine the API immediately reverts back to being sequential. Two things I noted that might be helpful context in diagnosing:
I am not sure why uvicorn is able to handle concurrency on a local level, but fail to do so when deployed to GKE. I just want to figure out whether this is a problem with my FastAPI/Uvicorn/Gunicorn implementation or not. Any help would be greatly appreciated! Operating SystemLinux Operating System DetailsNo response FastAPI Versionlatest Python Versionlatest Additional ContextStartup Command
Local Startup LogsDocker Run Command: Cloud Startup LogsApache Benchmark Results: LocalConcurrency works fine. Apache Benchmark Results: CloudFailed concurrency. Results always come back sequential. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
|
This is not a FastAPI issue. |
Beta Was this translation helpful? Give feedback.
This is not a FastAPI issue.