Skip to content

📝 Update Gunicorn guide to use uvicorn-worker library#11855

Closed
siavashyj wants to merge 3 commits into
fastapi:masterfrom
siavashyj:update-gunicorn-deployment-docs-to-use-uvicorn-worker
Closed

📝 Update Gunicorn guide to use uvicorn-worker library#11855
siavashyj wants to merge 3 commits into
fastapi:masterfrom
siavashyj:update-gunicorn-deployment-docs-to-use-uvicorn-worker

Conversation

@siavashyj

@siavashyj siavashyj commented Jul 17, 2024

Copy link
Copy Markdown

Update FastAPI Server Workers Documentation

Description

This PR updates the FastAPI Server Workers documentation to reflect the changes in Uvicorn worker implementation. The uvicorn.workers.UvicornWorker has been deprecated as of Uvicorn version 0.30.0, and we're now recommending the use of the uvicorn-worker package.

Changes

  • Updated installation instructions to include the uvicorn-worker package
  • Changed references from uvicorn.workers.UvicornWorker to uvicorn_worker.UvicornWorker
  • Updated the explanation of the --worker-class option to reflect the new import

Rationale

These changes are necessary to keep our documentation up-to-date with the latest best practices for deploying FastAPI applications with Gunicorn and Uvicorn workers.

Testing

  • Verified that the installation instructions work with the latest versions of the packages
  • Tested the Gunicorn command with the new worker class
  • Ensured that the document flow and overall structure remain intact

Additional Notes

Users upgrading from an older version may need to update their deployment scripts to use the new uvicorn_worker.UvicornWorker class. We may want to consider adding a migration guide or note in the documentation to help with this transition.

@tiangolo

Copy link
Copy Markdown
Member

📝 Docs preview for commit 98c1c8d at: https://af3405bf.fastapitiangolo.pages.dev

@alejsdev alejsdev changed the title docs: Update Gunicorn guide to use uvicorn-worker library. 📝 Update Gunicorn guide to use uvicorn-worker library. Jul 17, 2024
@alejsdev alejsdev added the docs Documentation about how to use FastAPI label Jul 17, 2024
@siavashyj siavashyj force-pushed the update-gunicorn-deployment-docs-to-use-uvicorn-worker branch from 98c1c8d to 5b057ce Compare July 19, 2024 14:08
@tiangolo

Copy link
Copy Markdown
Member

📝 Docs preview for commit 5b057ce at: https://9afd07f2.fastapitiangolo.pages.dev

@siavashyj

Copy link
Copy Markdown
Author

Ready to merge 🟢

@Kludex

Kludex commented Jul 21, 2024

Copy link
Copy Markdown
Member

My recommendation is to remove Gunicorn from the documentation.

@siavashyj

siavashyj commented Jul 21, 2024

Copy link
Copy Markdown
Author

My recommendation is to remove Gunicorn from the documentation.

I've had some not-so-great experiences running native Uvicorn workers on production instances due to: 1-potential memory leaks on long running instances, 2-slightly lower performance, 3-and higher tendency to timeout (502) under load compared to Gunicorn-Uvicorn workers.

I think keeping it as an option is still a good thing to have, especially for long running production instances.
What do you think @Kludex?

@KissPeter

Copy link
Copy Markdown

My recommendation is to remove Gunicorn from the documentation.

I've had some not-so-great experiences running native Uvicorn workers on production instances due to: 1-potential memory leaks on long running instances, 2-slightly lower performance, 3-and higher tendency to timeout (502) under load compared to Gunicorn-Uvicorn workers.

I think keeping it as an option is still a good thing to have, especially for long running production instances. What do you think @Kludex?

I can proof it with measurements:
https://kisspeter.github.io/fastapi-performance-optimization/workers_and_threads#gunicorn-vs-uvicorn

@Kludex

Kludex commented Jul 22, 2024

Copy link
Copy Markdown
Member

When did you do that?

Also... There's no need to prove anything here.

@alejsdev alejsdev changed the title 📝 Update Gunicorn guide to use uvicorn-worker library. 📝 Update Gunicorn guide to use uvicorn-worker library Aug 2, 2024
@siavashyj siavashyj force-pushed the update-gunicorn-deployment-docs-to-use-uvicorn-worker branch from 5b057ce to 8aa7fcc Compare August 10, 2024 16:02
@github-actions

Copy link
Copy Markdown
Contributor

@estebanx64

Copy link
Copy Markdown
Contributor

Hi @siavashyj

Thanks for your time and for helping us handle this topic. 🙇

We have planned to change these docs soon and we'll be reviewing it! 🤓

@github-actions

Copy link
Copy Markdown
Contributor

@tiangolo

Copy link
Copy Markdown
Member

Thanks for the interest @siavashyj!

I prefer to recommend the new Uvicorn with --workers, it's fewer moving parts, simpler code, and fewer chances of having errors and problems. 🤓

I updated the docs here: #12069, that should cover this.

I'll now close this one, but thanks for the effort! ☕

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

docs Documentation about how to use FastAPI

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants