0
0
FastAPIframework~10 mins

Gunicorn with Uvicorn workers in FastAPI - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the command to run a FastAPI app using Gunicorn with Uvicorn workers.

FastAPI
gunicorn -w 4 -k [1] myapp:app
Drag options to blanks, or click blank then click option'
Async
Bgevent
Cuvicorn.workers.UvicornWorker
Deventlet
Attempts:
3 left
💡 Hint
Common Mistakes
Using default sync worker which blocks async calls.
Using eventlet or gevent which are not compatible with Uvicorn.
2fill in blank
medium

Complete the command to specify 2 worker processes for Gunicorn with Uvicorn.

FastAPI
gunicorn -w [1] -k uvicorn.workers.UvicornWorker myapp:app
Drag options to blanks, or click blank then click option'
A8
B2
C4
D1
Attempts:
3 left
💡 Hint
Common Mistakes
Setting workers to 1 when more concurrency is needed.
Using too many workers causing resource exhaustion.
3fill in blank
hard

Fix the error in the command to run Gunicorn with Uvicorn workers on port 8080.

FastAPI
gunicorn -w 3 -k uvicorn.workers.UvicornWorker myapp:app [1] 0.0.0.0:8080
Drag options to blanks, or click blank then click option'
A-b
B--host
C--port
D-p
Attempts:
3 left
💡 Hint
Common Mistakes
Using --port alone without address.
Using --host which is not a Gunicorn option.
4fill in blank
hard

Fill both blanks to bind Gunicorn to localhost on port 5000.

FastAPI
gunicorn -w 2 -k uvicorn.workers.UvicornWorker myapp:app [1] [2]
Drag options to blanks, or click blank then click option'
A-b
B127.0.0.1:5000
C0.0.0.0:5000
D--bind
Attempts:
3 left
💡 Hint
Common Mistakes
Binding to 0.0.0.0 when localhost is intended.
Using --host instead of -b or --bind.
5fill in blank
hard

Fill all three blanks to run Gunicorn with 3 workers, Uvicorn worker class, and bind to all interfaces on port 8000.

FastAPI
gunicorn [1] [2] [3] myapp:app
Drag options to blanks, or click blank then click option'
A-w 3
B-k uvicorn.workers.UvicornWorker
C-b 0.0.0.0:8000
D--workers 4
Attempts:
3 left
💡 Hint
Common Mistakes
Using --workers 4 instead of -w 3.
Omitting the worker class option.
Binding to localhost instead of all interfaces.