Message queues»
Spacelift uses a number of message queues to support asynchronous processing. We support two options for message queues: AWS SQS, or a built-in message broker that uses your Postgres database.
For new installations we suggest using the Postgres message broker. The main exception to this is if you want to use AWS IoT Core rather than our built-in MQTT broker. In that case you must use SQS as IoT Core can only deliver messages to SQS queues by design.
Queues»
Spacelift splits its asynchronous processing across the following logical queues.
| Queue | Purpose |
|---|---|
async-jobs |
Background operations: run state changes, notifications, drift detection, billing, and similar |
async-jobs.fifo |
Background operations that must be processed in order |
cronjobs |
Scheduled (cron) job triggers |
dlq |
Messages that repeatedly failed processing |
dlq.fifo |
Ordered messages that repeatedly failed processing |
events-inbox |
Internal domain events fanned out to multiple consumers |
iot |
Messages from workers (heartbeats, run progress), bridged from the MQTT broker |
webhooks |
Inbound webhooks from your VCS and other integrations |
Configuration»
The following environment variables can be used to configure message queues:
| Environment variable | Required | Description |
|---|---|---|
MESSAGE_QUEUE_TYPE |
No | Can be set to either sqs or postgres. Defaults to sqs. |
MESSAGE_QUEUE_SQS_ASYNC_FIFO_URL |
For sqs |
The URL of the SQS queue backing the async-jobs.fifo queue. Required when MESSAGE_QUEUE_TYPE is set to sqs. |
MESSAGE_QUEUE_SQS_ASYNC_URL |
For sqs |
The URL of the SQS queue backing the async-jobs queue. Required when MESSAGE_QUEUE_TYPE is set to sqs. |
MESSAGE_QUEUE_SQS_CRONJOBS_URL |
For sqs |
The URL of the SQS queue backing the cronjobs queue. Required when MESSAGE_QUEUE_TYPE is set to sqs. |
MESSAGE_QUEUE_SQS_DLQ_FIFO_URL |
For sqs |
The URL of the SQS queue backing the dlq.fifo queue. Required when MESSAGE_QUEUE_TYPE is set to sqs. |
MESSAGE_QUEUE_SQS_DLQ_URL |
For sqs |
The URL of the SQS queue backing the dlq queue. Required when MESSAGE_QUEUE_TYPE is set to sqs. |
MESSAGE_QUEUE_SQS_EVENTS_INBOX_URL |
For sqs |
The URL of the SQS queue backing the events-inbox queue. Required when MESSAGE_QUEUE_TYPE is set to sqs. |
MESSAGE_QUEUE_SQS_IOT_URL |
For sqs |
The URL of the SQS queue backing the iot queue. Required when MESSAGE_QUEUE_TYPE is set to sqs. |
MESSAGE_QUEUE_SQS_WEBHOOKS_URL |
For sqs |
The URL of the SQS queue backing the webhooks queue. Required when MESSAGE_QUEUE_TYPE is set to sqs. |
SQS»
When using SQS, create one queue for each of the logical queues below. The name of the AWS resource is up to you — only the URL you pass to the matching MESSAGE_QUEUE_SQS_* variable (see Configuration) matters. Use the following configuration options for each:
| Queue | Visibility timeout | Message retention |
|---|---|---|
async-jobs |
300s | Default |
async-jobs.fifo |
300s | Default |
cronjobs |
300s | 3600s |
dlq |
300s | Default |
dlq.fifo |
300s | Default |
events-inbox |
300s | Default |
iot |
45 | Default |
webhooks |
600s | Default |
In addition, you should use the following configuration options for all the queues:
- A max receive count of
3. - The
async-jobs.fifoqueue should have its redrive policy configured to send messages to thedlq.fifoqueue. - All other queues should use the
dlqqueue.
IoT Core topic rule»
In order to allow messages sent from Spacelift workers to be processed by the backend services, an IoT Core topic rule needs to be created to publish messages sent to certain topics onto your IoT SQS queue.
The rule should look something like this:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 | |
Postgres»
The Postgres message broker doesn't require any specific additional configuration other than setting the MESSAGE_QUEUE_TYPE environment variable to postgres.
Monitoring & scaling»
For detailed information on monitoring message queue performance and metrics, see the observability guide.