Skip to content

How to know the size of the threadpool ? and why --workers makes no difference on concurrency #4591

@yyfhust

Description

@yyfhust

First Check

  • I added a very descriptive title to this issue.
  • I used the GitHub search to find a similar issue and didn't find it.
  • I searched the FastAPI documentation, with the integrated search.
  • I already searched in Google "How to X in FastAPI" and didn't find any information.
  • I already read and followed all the tutorial in the docs and didn't find an answer.
  • I already checked if it is not related to FastAPI but to Pydantic.
  • I already checked if it is not related to FastAPI but to Swagger UI.
  • I already checked if it is not related to FastAPI but to ReDoc.

Commit to Help

  • I commit to help with one of those options 👆

Example Code

uvicorn run:app --host 0.0.0.0 --port 8000 --workers 2

Description

Hi,
How to know the size of the thread pool ? And what is the use of --workers in uvicorn

I have tested locally:
I used uvicorn to run fastAPI based backend locally on my Mac, and I can see that it can create up to 6 distinct threads ( the server gets blocked when I sent more request ).
I also tried to run the backend with different --workers, but there was no difference at all, the threads limit was always 6 no matter how many workers I specified.
Commend I have run:
uvicorn run:app --host 0.0.0.0 --port 8000 --workers 1
uvicorn run:app --host 0.0.0.0 --port 8000 --workers 2
uvicorn run:app --host 0.0.0.0 --port 8000 --workers 10

Operating System

macOS

Operating System Details

Macpro 2020

FastAPI Version

0.70.0

Python Version

Python 3.7.9

Additional Context

No response

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions