Join GitHub today
GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.
Sign upGitHub is where the world builds software
Millions of developers and companies build, ship, and maintain their software on GitHub — the largest and most advanced development platform in the world.
Usage of HttpCompressionMiddleware needs to be reflected in Scrapy stats #4797
Comments
|
fyi the issue #4797 description has a typo "relfected in Scrapy stats" -> "reflected in Scrapy stats" |
|
I'd like to take this. |
|
Ok no problem, I'll look for another that hasn't been grabbed yet.
Mike Vanbuskirkmike@mikevanbuskirk.io
Sent with [ProtonMail](https://protonmail.com) Secure Email.
‐‐‐‐‐‐‐ Original Message ‐‐‐‐‐‐‐
…On Tuesday, October 6, 2020 5:25 PM, Adrián Chaves ***@***.***> wrote:
***@***.***(https://github.com/codevbus) [#4799](#4799) is quite close to completion already.
—
You are receiving this because you were mentioned.
Reply to this email directly, [view it on GitHub](#4797 (comment)), or [unsubscribe](https://github.com/notifications/unsubscribe-auth/AAMYMRPATDNVKK62L4EMDVLSJODNTANCNFSM4RTJPG4A).
|
Summary
Usage of
HttpCompressionMiddlewareneeds to be relfected in Scrapy stats.Motivation
In order to estimate scrapy memory usage efficiency and prevent.. memory leaks like this.
I will need to know:
trackref)A lot of websites use compression to reduce traffic. In this case I would like to calculate average size of decompressed responses to estimate p.2.
Decompression process means that at some point application will require to allocate memory to store both compressed and decompressed response body and I will need to know this sizes to have more complete vision of scrapy memory usage.
Also size of decompressed body will be several times more than size of compressed response and it will affect scrapy memory usage.
Describe alternatives you've considered
The easiest one - is to change priority of
DownloaderStatsmiddleware and check difference indownloader/response_bytesstats parameter.Stats from quotes.toscrape.com spider (it uses
gzipcompression) with default settings:And with changed priority of
DownloaderStatsmiddleware:Average size of compressed response (by default) - 2453 bytes.
Average size of decompressed response - 11019 bytes (~4.5 times more).
Additional context
Potential solution is to add something like this:
self.stats.inc_value('decompressed_bytes', spider=spider)into
process_responsemethod ofHttpCompressionMiddleware