tornadoweb / tornadoweb/tornado
Provide control over gzip compression level in tornado.web.Application
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 22.2k
- Forks
- 5.6k
- Avg merge
- 3h 42m
- Merged PRs (30d)
- 16
Description
By default, GzipFile in the Python standard library uses a compression level of 9 (the highest available): https://docs.python.org/2/library/gzip.html#gzip.GzipFile
Most other applications (like the gzip command line tool) default to level 6 or lower. The difference in throughput can be something like a factor of 3-5x on a single core, leading many people to incorrectly conclude that using gzip compression with Tornado is "too slow" compared to other web servers (like node.js, for example, which led me to discover the cause of this problem).
It would be nice if the gzip option to tornado.web.Application could also be a number (1-9), indicating the compresslevel to pass to GzipFile. If True is passed, I would also advocate that a default value of 6 is used, rather than the standard library default. The compression factor will be very close to that of level 9, but throughput will be much larger.
If this sounds reasonable, I can make a PR.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by locating the gzip option handling in tornado.web.Application and review how Python's standard-library GzipFile accepts compresslevel. The requested behavior is to accept levels 1-9 and use level 6 when gzip is True; done should include coverage for these option forms and preserve existing gzip behavior.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- backend, performance
- Issue type
- Feature
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 38/100