tiangolo / fastapi

FastAPI framework, high performance, easy to learn, fast to code, ready for production
https://fastapi.tiangolo.com/
MIT License
73.78k stars 6.22k forks source link

Add doc for `compresslevel` of the GZipMiddleware and use compresslevel=5 in the example #11412

Open RaphaelMarinier opened 3 months ago

RaphaelMarinier commented 3 months ago

compresslevel is defined there in starlette's GZipMiddleware: https://github.com/encode/starlette/blob/4e453ce91940cc7c995e6c728e3fdf341c039056/starlette/middleware/gzip.py#L30

compresslevel=5 is typically a better CPU / compression level tradeoff than 9, e.g. see: https://tukaani.org/lzma/benchmarks.html

tiangolo commented 3 months ago

📝 Docs preview for commit 1ba728844a4ef09619a629453feb753d79032b8a at: https://12056547.fastapitiangolo.pages.dev

soulee-dev commented 3 months ago

Seems like it's duplicated PR #11350

RaphaelMarinier commented 3 months ago

Indeed, it's mostly a duplicate (I was not aware of it), except that the default I propose in the doc is probably a better tradeoff (typically 3x less CPU usage, for only one percent point larger outputs).