Commit Graph

3 Commits

Author SHA1 Message Date
Aliaksandr Valialkin 30e92af08f Limit heap memory usage when compressing high number of concurrent responses
Previously each concurrent compression could allocate huge compression state
with the size up to 1Mb each. So 10K concurrent connections could result in
10Gb of compression state in the heap.

This CL limits the number of compression states among concurrent requests
when {Append,Write}{Gzip,Deflate}* functions are called to O(GOMAXPROCS).
These functions are used by CompressHandler* for non-streaming responses,
i.e. it should cover the majority of use cases.

Memory usage for 10K concurrent connections that compress responses drops
from 10Gb to 200Mb after this CL.
2017-05-17 14:45:31 +03:00
Aliaksandr Valialkin 95456fa9d7 Added AppendGzipBytes and AppendGunzipBytes for simplifying gzipping/gunzipping request/response bodies 2015-12-31 12:09:21 +02:00
Aliaksandr Valialkin 23774a8a18 Added tests for compress.go 2015-12-29 09:46:21 +02:00