Schedule icon
Script icon
If icon
SlackIncomingWebhook icon
Log icon
Labels icon

Apache Cassandra Compaction Backlog Sentinel

Audits Apache Cassandra pending compaction tasks, alerting DBREs on Slack before SSTable backlog accumulation triggers disk write stalls or read latency.

Categories
DataInfrastructure

This blueprint monitors SSTable compaction queues across Apache Cassandra database clusters. Scheduled every 10 minutes, it evaluates pending and active compaction task counts, alerting database reliability engineers on Slack when compaction backlogs surpass critical operating thresholds before disk write stalls degrade client query latency.

How it works

  1. Recurring 10-Minute Probe: The periodic_compaction_audit schedule trigger (io.kestra.plugin.core.trigger.Schedule) fires every 10 minutes.
  2. Compaction Queue Audit: The audit_compaction_stats task (io.kestra.plugin.scripts.python.Script) inspects cluster compaction health, retrieving pending, active, and completed compaction task metrics.
  3. Threshold Gate: The check_compaction_backlog flowable task (io.kestra.plugin.core.flow.If) compares pending compaction task counts against configured warning ceilings.
  4. Slack Warning Dispatch: When compaction backlogs exceed safety levels, notify_slack_compaction_pressure (io.kestra.plugin.slack.notifications.SlackIncomingWebhook) dispatches an urgent incident alert with actionable tuning recommendations.
  5. Healthy Confirmation: When compaction pipelines process nominal workloads, log_compaction_healthy records confirmed status.
  6. Manifest Export: The export_compaction_manifest task tags the execution with searchable status labels.

Architecture diagram

flowchart TD
    A[Schedule: Every 10 Minutes] --> B[audit_compaction_stats: Inspect Compaction Queue]
    B --> C{Pending Tasks > Threshold?}
    C -- Yes --> D[notify_slack_compaction_pressure: Slack Webhook]
    C -- No --> E[log_compaction_healthy: Log Healthy State]
    D --> F[export_compaction_manifest: Execution Labels]
    E --> F

Use cases

  • Prevent Write Stalls: Stop disk I/O bottlenecks when high-throughput ingestion creates new SSTables faster than background compaction threads can merge them.
  • Maintain Read Latency SLAs: Avoid multiple SSTable lookups per read query caused by uncompacted tables that degrade p99 query performance.
  • Proactive Hardware Capacity Planning: Detect when nodes consistently fall behind on compaction due to undersized CPU core allocations or IOPS throttling.

Inputs

Name Type Default Description
cassandra_host STRING cassandra-node1.internal Hostname or IP address of the target Apache Cassandra cluster node.
cassandra_jmx_port INT 7199 JMX remote monitoring port configured on the Cassandra node.
max_pending_compaction_tasks_warning INT 50 Threshold of pending compaction tasks above which a backlog warning alert is triggered.
slack_channel STRING #cassandra-dbre-alerts Slack channel destination for Cassandra cluster compaction and storage alerts.

Expected outputs

  • {{ outputs.audit_compaction_stats.vars.cluster_name }}: Identified Cassandra cluster name.
  • {{ outputs.audit_compaction_stats.vars.pending_compaction_tasks }}: Number of pending compaction tasks queued on the node.
  • {{ outputs.audit_compaction_stats.vars.active_compaction_tasks }}: Count of currently executing compaction tasks.
  • {{ outputs.audit_compaction_stats.vars.has_backlog_incident }}: Boolean flag indicating if backlog exceeded threshold.
  • {{ outputs.audit_compaction_stats.outputFiles['cassandra_compaction_report.json'] }}: Structured JSON report containing compaction queue metrics.

Prerequisites

  • Apache Cassandra 4.x or 5.x cluster node accessible over internal network.
  • Native CQL port (9042) and optional JMX port (7199) network access enabled.
  • Slack Incoming Webhook endpoint URL.

Secrets

  • CASSANDRA_USER: Cassandra database authentication username.
  • CASSANDRA_PASSWORD: Cassandra database authentication password.
  • SLACK_WEBHOOK_URL: Slack Incoming Webhook endpoint URL.

Quick start

  1. Configure CASSANDRA_USER, CASSANDRA_PASSWORD, and SLACK_WEBHOOK_URL in your Kestra namespace secrets.
  2. Import this flow YAML into your Kestra workspace.
  3. Specify your Cassandra node hostname in cassandra_host.
  4. Click Execute in the UI to perform an immediate compaction queue audit.

Common pitfalls and troubleshooting

  • Compaction Throughput Throttling: Cassandra defaults compaction_throughput_mb_per_sec to 64 or 128 MB/s; if backlog grows continuously on fast NVMe drives, increase this parameter dynamically using nodetool setcompactionthroughput.
  • Disk Space Amplification: Leveled Compaction Strategy (LCS) requires 10% free disk headroom while Size-Tiered Compaction Strategy (STCS) can require up to 50% free space for major compactions.
  • JVM Garbage Collection Pauses: Prolonged compaction tasks competing with client queries can induce Stop-The-World GC pauses; adjust G1GC heap configurations accordingly.

How to extend

  • Add automated nodetool setconcurrentcompactors tuning tasks when pending backlogs exceed critical thresholds.
  • Broadcast compaction backlog trends to Datadog or Prometheus metrics collectors.
  • Trigger snapshot backup schedules prior to initiating manual major compactions.

Links

See How

New to Kestra?

Use blueprints to kickstart your first workflows.