| 1 |
Performance |
| 2 |
=========== |
| 3 |
|
| 4 |
.. currentmodule:: websockets |
| 5 |
|
| 6 |
Here are tips to optimize performance. |
| 7 |
|
| 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 |
|
| 15 |
uvloop |
| 16 |
------ |
| 17 |
|
| 18 |
You can make a websockets application faster by running it with uvloop_. |
| 19 |
|
| 20 |
(This advice isn't specific to websockets. It applies to any :mod:`asyncio` |
| 21 |
application.) |
| 22 |
|
| 23 |
.. _uvloop: https://github.com/MagicStack/uvloop |
| 24 |
|
| 25 |
broadcast |
| 26 |
--------- |
| 27 |
|
| 28 |
:func:`~asyncio.server.broadcast` is the most efficient way to send a message to |
| 29 |
many clients. |