@@ -77,8 +77,8 @@ usage for both sides.
77
77
78
78
* **Window Bits ** controls the size of the compression context. It must be
79
79
an integer between 9 (lowest memory usage) and 15 (best compression).
80
- websockets defaults to 12. Setting it to 8 is possible but rejected by some
81
- versions of zlib.
80
+ websockets defaults to 12 for servers and 15 for clients. Setting it to 8
81
+ is possible but rejected by some versions of zlib.
82
82
83
83
:mod: `zlib ` offers additional parameters for tuning compression. They control
84
84
the trade-off between compression rate and CPU and memory usage for the
@@ -101,10 +101,20 @@ Unless mentioned otherwise, websockets uses the defaults of
101
101
Tuning compression
102
102
------------------
103
103
104
- By default, websockets enables compression with conservative settings that
105
- optimize memory usage at the cost of a slightly worse compression rate: Window
106
- Bits = 12 and Memory Level = 5. This strikes a good balance for small messages
107
- that are typical of WebSocket servers.
104
+ By default, for servers, websockets enables compression with conservative
105
+ settings that optimize memory usage at the cost of a slightly worse
106
+ compression rate: Window Bits = 12 and Memory Level = 5. This strikes a good
107
+ balance for small messages that are typical of WebSocket servers.
108
+
109
+ For clients, websockets enables compression but leaves settings up to the
110
+ server. This is for a bad reason: providing compression settings triggers a
111
+ `bug in AWS API Gateway `_ and, since there's no realistic way to file a bug
112
+ against AWS, affected users end up filing bugs against websockets. Optimizing
113
+ memory usage is less critical for clients because it's uncommon to open
114
+ thousands of client connections in a program. This makes it acceptable not to
115
+ perform the same optimization as for servers.
116
+
117
+ .. _bug in AWS API Gateway : https://github.com/aaugustin/websockets/issues/1065
108
118
109
119
Here's how various compression settings affect memory usage of a single
110
120
connection on a 64-bit system, as well a benchmark of compressed size and
0 commit comments