@@ -340,8 +340,11 @@ log lines and looking for any 'Processed request' lines which take more than
340
340
a few seconds to execute. Please let us know at #synapse:matrix.org if
341
341
you see this failure mode so we can help debug it, however.
342
342
343
- Help!! Synapse eats all my RAM!
344
- -------------------------------
343
+ Help!! Synapse is slow and eats all my RAM/CPU!
344
+ -----------------------------------------------
345
+
346
+ First, ensure you are running the latest version of Synapse, using Python 3
347
+ with a PostgreSQL database.
345
348
346
349
Synapse's architecture is quite RAM hungry currently - we deliberately
347
350
cache a lot of recent room data and metadata in RAM in order to speed up
@@ -352,14 +355,29 @@ variable. The default is 0.5, which can be decreased to reduce RAM usage
352
355
in memory constrained enviroments, or increased if performance starts to
353
356
degrade.
354
357
358
+ However, degraded performance due to a low cache factor, common on
359
+ machines with slow disks, often leads to explosions in memory use due
360
+ backlogged requests. In this case, reducing the cache factor will make
361
+ things worse. Instead, try increasing it drastically. 2.0 is a good
362
+ starting value.
363
+
355
364
Using `libjemalloc <http://jemalloc.net/ >`_ can also yield a significant
356
- improvement in overall amount , and especially in terms of giving back RAM
357
- to the OS. To use it, the library must simply be put in the LD_PRELOAD
358
- environment variable when launching Synapse. On Debian, this can be done
359
- by installing the ``libjemalloc1 `` package and adding this line to
360
- ``/etc/default/matrix-synapse ``::
365
+ improvement in overall memory use , and especially in terms of giving back
366
+ RAM to the OS. To use it, the library must simply be put in the
367
+ LD_PRELOAD environment variable when launching Synapse. On Debian, this
368
+ can be done by installing the ``libjemalloc1 `` package and adding this
369
+ line to ``/etc/default/matrix-synapse ``::
361
370
362
371
LD_PRELOAD=/usr/lib/x86_64-linux-gnu/libjemalloc.so.1
363
372
364
373
This can make a significant difference on Python 2.7 - it's unclear how
365
374
much of an improvement it provides on Python 3.x.
375
+
376
+ If you're encountering high CPU use by the Synapse process itself, you
377
+ may be affected by a bug with presence tracking that leads to a
378
+ massive excess of outgoing federation requests (see `discussion
379
+ <https://github.com/matrix-org/synapse/issues/3971> `_). If metrics
380
+ indicate that your server is also issuing far more outgoing federation
381
+ requests than can be accounted for by your users' activity, this is a
382
+ likely cause. The misbehavior can be worked around by setting
383
+ ``use_presence: false `` in the Synapse config file.
0 commit comments