New to Kestra?
Use blueprints to kickstart your first workflows.
Audits Memcached slab class memory allocations and eviction rates, calculating cache starvation and alerting SREs on Slack before latency spikes.
In high-concurrency web tiers and distributed application backends, Memcached provides ultra-fast in-memory caching to shield primary databases from read overload. Memcached organizes its memory pool into discrete slab classes, where each class stores items within specific chunk size ranges (e.g. 96 bytes, 120 bytes, 150 bytes).
When incoming data patterns shift toward specific object sizes without slab rebalancing enabled, individual slab classes run out of free chunks even if total server RAM is plentiful. As a result, Memcached prematurely evicts active unexpired keys from the saturated slab class. These silent evictions trigger cache thundering herds: hundreds of application threads miss the cache simultaneously and slam backend relational databases with redundant expensive SQL queries.
This blueprint provides an automated caching reliability sentinel. Running on a recurrent ten-minute schedule, it communicates with Memcached daemons via the standard text protocol socket, inspects stats slabs outputs, quantifies key evictions across individual slab classes, and dispatches real-time alerts to SREs on Slack with slab automove configuration advice.
poll_memcached_slabs trigger (io.kestra.plugin.core.trigger.Schedule) initiates the audit every ten minutes.scan_slab_eviction_metrics task (io.kestra.plugin.scripts.python.Script) opens a socket connection to port 11211, sending stats slabs to extract chunk usage and per-slab eviction counters.evaluate_slab_evictions flowable task (io.kestra.plugin.core.flow.If) evaluates whether total or per-slab evictions exceed safe thresholds.alert_slack_slab_evictions (io.kestra.plugin.slack.notifications.SlackIncomingWebhook) dispatches an incident card detailing the saturated slab class and runtime tuning options (slab_reassign, slab_automove).log_healthy_memcached_slabs logs nominal cache health.export_slab_manifest task records execution state for platform telemetry pipelines.flowchart TD
A[Schedule: Every 10 Minutes] --> B[scan_slab_eviction_metrics: Memcached Stats Slabs]
B --> C{Evictions Exceed Threshold?}
C -- Yes --> D[alert_slack_slab_evictions: Slack Webhook]
C -- No --> E[log_healthy_memcached_slabs: Log]
D --> F[export_slab_manifest: Return JSON]
E --> F
-f factor) to maximize memory packing density.slab_automove=1 successfully migrate free memory pages to congested slab classes.| Name | Type | Default | Description |
|---|---|---|---|
memcached_host |
STRING | "localhost" |
Hostname or IP address of the target Memcached node. |
memcached_port |
INT | 11211 |
Network communication port exposing Memcached ascii commands. |
max_evictions_threshold |
INT | 100 |
Maximum allowable key eviction rate within interval before alerting. |
slack_channel |
STRING | "#caching-reliability" |
Slack channel destination for caching incident notifications. |
{{ outputs.scan_slab_eviction_metrics.vars.has_evictions }}: Boolean flag indicating if active evictions were detected.{{ outputs.scan_slab_eviction_metrics.vars.total_evictions }}: Total number of evicted cache keys.{{ outputs.scan_slab_eviction_metrics.vars.worst_slab }}: Slab class identifier suffering the highest eviction pressure.{{ outputs.scan_slab_eviction_metrics.vars.worst_count }}: Count of evictions inside the worst slab class.{{ outputs.scan_slab_eviction_metrics.outputFiles['memcached_slabs_report.json'] }}: Structured JSON diagnostic report.SLACK_WEBHOOK_URL: Slack Incoming Webhook endpoint URL with permissions to post messages.SLACK_WEBHOOK_URL in your Kestra namespace secrets.memcached_host and memcached_port to match your caching cluster node.slab_automove to mitigate.slabs reassign <src> <dst> directly over the management socket.