Skip to main content

Why they are separate

The separation is by purpose, not by convenience, and the reason is head-of-line blocking. A broadcast to fifty thousand contacts is a large volume of individually unimportant work. A reply to someone who just asked a question is a single piece of work that is urgent by definition — a person is watching a chat window. Put them on one queue and the broadcast is in front, and every reply waits behind it. The same argument is why messaging.transactional exists beside flow.execution: inbound processing can be slow, because a flow may make an HTTP call or a retrieval query, and a reply should not queue behind the next contact’s inbound message. Today replies are sent from inside the flow.execution job that produced them, so the queue is reserved and Horizon only keeps a worker on it. flow.automations keeps background runs off the conversation path: an automation that makes several calls in a row must not hold the workers that answer contacts, nor wait behind a retrying external sync. An automation run never holds one job for long — after a number of steps or seconds (the platform settings flow.automation.segment_steps and flow.automation.segment_seconds) it saves its position and continues in a new job, so no job outlives its timeout and a retried job continues the run instead of starting it again. A delay’s wake-up of an automation run stays on flow.execution and runs at most one segment there before the rest continues on flow.automations. sync.external is isolated for a different reason: it depends on systems whose availability is not ours. When a third party is down and its jobs are retrying with backoff, that retry storm must not occupy the workers that answer contacts.
Do not mix queues by purpose. A job placed on a queue because it happens to be configured, rather than because it belongs there, removes the isolation the separation exists to provide.

Backpressure

Provider rate limits and backpressure are handled preventively, not as a reaction to a provider’s error response. A sender that discovers a limit by being rejected has already spent the request, and on a broadcast that failure multiplies across the whole fan-out — turning one rate limit into tens of thousands of failed jobs, each of which will retry.

Which worker takes which

Horizon runs seven supervisors, an eighth while a Solution is installed, and the grouping is the separation made operational: The first pair is the latency-critical path — a message arriving and the reply going out — and it has its own processes so nothing else can crowd it.

Removing a tenant

Deleting a workspace calls the channel providers, deletes files and drops a schema, which can take minutes. It runs on tenancy.decommission, on the redis-long connection: the same Redis as the others, but a retry_after (REDIS_LONG_QUEUE_RETRY_AFTER, 1800 seconds) above the job’s timeout (1500 seconds), so a long run is never reserved a second time by another worker. Keep that order if you change either value. The job is unique per tenant.

Running the workers

Queues are processed by Horizon. An installation without it accepts messages and never answers them — see Services.