Skip to content

Commit 8e4d408

Browse files
committed
Document asyncio's TLS read buffer.
Fix #1644.
1 parent cb3500b commit 8e4d408

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
lines changed

docs/topics/memory.rst

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,9 @@ the frequency of system calls or the need to pause reading or writing.
8888
You should keep these buffers small. Increasing them can help with spiky
8989
workloads but it can also backfire because it delays backpressure.
9090

91-
* In the :mod:`asyncio` implementation, there is no library-level read buffer.
91+
* In the :mod:`asyncio` implementation, there is no library-level read buffer
92+
for plain TCP connections. There is a 256 KiB read buffer for TLS connections,
93+
plus 32KiB on Windows with the default event loop.
9294

9395
There is a write buffer. The ``write_limit`` argument of
9496
:func:`~asyncio.client.connect` and :func:`~asyncio.server.serve` controls its
@@ -107,6 +109,9 @@ workloads but it can also backfire because it delays backpressure.
107109
it drains under the low-water mark. This creates backpressure on the TCP
108110
connection.
109111

112+
In addition, there is a 256 KiB read buffer for TLS connections, plus 32KiB on
113+
Windows.
114+
110115
There is a write buffer. It as controlled by ``write_limit``. It behaves like
111116
the :mod:`asyncio` implementation described above.
112117

docs/topics/performance.rst

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,13 @@ Performance
55

66
Here are tips to optimize performance.
77

8+
TLS
9+
---
10+
11+
You should terminate TLS in a reverse proxy rather than in a websockets server.
12+
13+
This will reduce memory usage of the websockets server and improve performance.
14+
815
uvloop
916
------
1017

0 commit comments

Comments
 (0)