akkoma/lib/pleroma/web/mastodon_api
Oneric 13e2a811ec Avoid accumulation of stale data in websockets
We’ve received reports of some specific instances slowly accumulating
more and more binary data over time up to OOMs and globally setting
ERL_FULLSWEEP_AFTER=0 has proven to be an effective countermeasure.
However, this incurs increased cpu perf costs everywhere and is
thus not suitable to apply out of the box.

Apparently long-lived Phoenix websocket processes are known to
often cause exactly this by getting into a state unfavourable
for the garbage collector.
Therefore it seems likely affected instances are using timeline
streaming and do so in just the right way to trigger this. We
can tune the garbage collector just for websocket processes
and use a more lenient value of 20 to keep the added perf cost
in check.

Testing on one affected instance appears to confirm this theory

Ref.:
  https://www.erlang.org/doc/man/erlang#ghlink-process_flag-2-idp226
  https://blog.guzman.codes/using-phoenix-channels-high-memory-usage-save-money-with-erlfullsweepafter
  https://git.pleroma.social/pleroma/pleroma/-/merge_requests/4060

Tested-by: bjo
2024-06-22 22:22:33 +02:00
..
controllers Don't try to handle non-media objects as media 2024-05-22 20:30:23 +02:00
views No need to spawn() any more 2024-06-12 02:09:24 +01:00
mastodon_api.ex Add 'notifying' to relationship for compatibility with Mastodon 2021-12-06 21:24:12 +01:00
websocket_handler.ex Avoid accumulation of stale data in websockets 2024-06-22 22:22:33 +02:00