zulip/zerver
Alex Vandiver faeffa2466 queue_processors: Set a bounded prefetch size on rabbitmq queues.
RabbitMQ clients have a setting called prefetch[1], which controls how
many un-acknowledged events the server forwards to the local queue in
the client.  The default is 0; this means that when clients first
connect, the server must send them every message in the queue.

This itself may cause unbounded memory usage in the client, but also
has other detrimental effects.  While the client is attempting to
process the head of the queue, it may be unable to read from the TCP
socket at the rate that the server is sending to it -- filling the TCP
buffers, and causing the server's writes to block.  If the server
blocks for more than 30 seconds, it times out the send, and closes the
connection with:

```
closing AMQP connection <0.30902.126> (127.0.0.1:53870 -> 127.0.0.1:5672):
{writer,send_failed,{error,timeout}}
```

This is https://github.com/pika/pika/issues/753#issuecomment-318119222.

Set a prefetch limit of 100 messages, or the batch size, to better
handle queues which start with large numbers of outstanding events.

Setting prefetch=1 causes significant performance degradation in the
no-op queue worker, to 30% of the prefetch=0 performance.  Setting
prefetch=100 achieves 90% of the prefetch=0 performance, and higher
values offer only minor gains above that.  For batch workers, their
performance is not notably degraded by prefetch equal to their batch
size, and they cannot function on smaller prefetches than their batch
size.

We also set a 100-count prefetch on Tornado workers, as they are
potentially susceptible to the same effect.

[1] https://www.rabbitmq.com/confirms.html#channel-qos-prefetch
2021-11-16 11:48:50 -08:00
..
data_import data_import: Ignore Rocket.Chat livechat streams/messages. 2021-11-07 09:50:55 -08:00
integration_fixtures/nagios tests: Add a test for fixtures for non-webhook integrations. 2021-04-28 08:16:51 -07:00
lib queue_processors: Set a bounded prefetch size on rabbitmq queues. 2021-11-16 11:48:50 -08:00
management rate_limit: Add a flag to lump all TOR exit node IPs together. 2021-11-16 11:42:00 -08:00
migrations migrations: Disable atomic flag on migration 0354. 2021-11-15 17:24:49 -08:00
openapi openapi: Say message_content_delete_limit_seconds won't be 0 anymore. 2021-11-01 17:17:25 -07:00
tests queue: Allow passing down a prefetch count to pika. 2021-11-16 11:48:50 -08:00
tornado tornado: Move SIGTERM shutdown handler into a callback. 2021-11-12 09:57:23 -08:00
views email_change: Show deactivated page if realm is now deactivated. 2021-11-14 18:55:40 -08:00
webhooks webhooks/github: Include discussion ID in messages. 2021-10-26 17:52:57 -07:00
worker queue_processors: Set a bounded prefetch size on rabbitmq queues. 2021-11-16 11:48:50 -08:00
__init__.py django: Upgrade Zulip to Django 3.2 LTS. 2021-05-03 08:36:22 -07:00
apps.py caching: Make sender type optional for flush_cache. 2021-07-26 14:48:07 -07:00
context_processors.py auth: Add login buttons for web public access. 2021-10-05 16:30:40 -07:00
decorator.py rate_limit: Add a flag to lump all TOR exit node IPs together. 2021-11-16 11:42:00 -08:00
filters.py typing: Fix function signatures. 2021-08-20 05:54:19 -07:00
forms.py reset_password: Show user-facing page on rate-limit. 2021-11-04 20:34:39 -07:00
logging_handlers.py logging_handlers: Remove STAGING_ERROR_NOTIFICATIONS setting. 2021-07-07 09:26:02 -07:00
middleware.py lint: Fix typos found by codespell. 2021-10-19 16:51:13 -07:00
models.py models: Add comment documenting how email uniqueness is enforced. 2021-11-15 13:46:28 -08:00
signals.py python: Convert deprecated Django ugettext alias to gettext. 2021-04-15 18:01:34 -07:00