One Spare TaskManager Cut Flink Node Loss Catch-Up From 439 s to 29 s#
Every Kubernetes cluster loses a node sooner or later. A spot instance is taken back, an autoscaler drains a node, a host fails. When that node runs a Flink TaskManager, the job stops and restarts. Everyone expects that part.
The part that hurts comes after the restart. While the job stands still, the input keeps arriving. When the job runs again, it has to process the backlog plus everything it replays from the last checkpoint, and it sends all of that downstream in one burst. The downtime is only the first cost.
After my earlier post on spare TaskManagers, a reader asked the better question: how long until the backlog is gone? So I built a lab, deleted a node on purpose, and measured the full picture, second by second.
In this article, we will build that lab step by step, break a node under a running job, and bring the catch-up from 439 seconds to 29 seconds with two settings.

๐ฏ What We Will Cover#
- Why a node loss costs more than the downtime
- The lab: Kafka, a Flink SQL job on Ververica Platform, and Kubernetes nodes from Karpenter
- Step by step: the nodes, the topics, the job, the deployment and the node delete
- Two fixes: one spare TaskManager and a shorter checkpoint interval
- The results with charts, and how Kafka Streams compares
- Production settings to start with
Prerequisites:
- A Kubernetes cluster with node autoscaling. This lab ran on Amazon EKS with Karpenter, one worker per node.
- Ververica Platform 3.1.4 (self-managed) with the engine
vera-4.5-jdk11-flink-1.20. The Flink settings in this post are standard Apache Flink settings, so they apply to open source Flink too. - Apache Kafka (3.9.0 in this lab) and the Kafka CLI tools. If you need a cluster first, see my posts on deploying Kafka on Kubernetes and on Kafka topics.
kubectl,curlandjq.
๐ฅ Why a Node Loss Costs More Than the Downtime#
Three things happen when a TaskManager disappears:
| Cost | What it is | Who feels it |
|---|---|---|
| Downtime | All partitions stop until the job runs again | Anyone waiting for new results |
| Replay | Flink restores the last checkpoint and processes everything after it a second time | Downstream systems: with an at-least-once sink, the replay arrives as duplicates |
| Catch-up burst | The job works off the backlog at its maximum speed | Downstream databases and services: up to 12 times the normal rate in this lab |
A simple rule tells you how long the catch-up takes:
backlog = (time stopped + replay window) x input rate
drain time = backlog / (maximum throughput - input rate)
Key Points:
- A spare TaskManager shortens the time stopped.
- The checkpoint interval sets the replay window.
- Spare capacity (maximum throughput minus input rate) sets how fast the backlog drains.
๐๏ธ The Lab Setup#
| Item | Value |
|---|---|
| Kafka | Apache Kafka 3.9.0, one broker, on a node that is never deleted |
| Input topic | 12 partitions, a steady 50,000 records per second, 1 million keys with a uniform random distribution |
| Output topic | 12 partitions, message.timestamp.type=LogAppendTime |
| Flink job | Flink SQL, GROUP BY the key, into an upsert-kafka sink with at-least-once delivery |
| Platform | Ververica Platform 3.1.4, engine vera-4.5-jdk11-flink-1.20 |
| Resources | parallelism 2, 1 slot per TaskManager, TaskManager 2 CPU and 4 GiB, JobManager 1 CPU and 2 GiB |
| Checkpoints and restart | checkpoint every 180 s with a minimum pause of 180 s, fixed-delay restart after 10 s |
| Nodes | a Karpenter node pool with on-demand m5, m6i, m6a and m7i xlarge instances, one worker per node |
| Measurement | a checker pod outside the engine reads the output topic and the input end offsets every second |
Info:
The checker does not trust any engine metric. It compares what came in with what came out, per second and per partition: output rate, latency of new results, lag per input partition, and records emitted twice. The same checker measured Kafka Streams later, so the numbers are comparable.
๐ Step by Step#
Step 1: Give Flink its own nodes#
Each worker gets its own node, so deleting one node removes exactly one TaskManager. A Karpenter node pool with a taint keeps other pods away. Adapt the instance types and the names to your cluster:
apiVersion: karpenter.sh/v1
kind: NodePool
metadata:
name: flink-workers
spec:
disruption: {consolidationPolicy: WhenEmpty, consolidateAfter: 2m}
limits: {cpu: "40"}
template:
spec:
nodeClassRef: {group: karpenter.k8s.aws, kind: EC2NodeClass, name: flink-workers}
requirements:
- {key: karpenter.sh/capacity-type, operator: In, values: [on-demand]}
- {key: node.kubernetes.io/instance-type, operator: In, values: [m5.xlarge, m6i.xlarge, m6a.xlarge, m7i.xlarge]}
taints:
- {key: dedicated, value: flink, effect: NoSchedule}
kubectl apply -f nodepool.yaml
Step 2: Create the topics#
# Input topic: 12 partitions
kafka-topics.sh --bootstrap-server kafka:9092 --create \
--topic events-in --partitions 12 --replication-factor 1
# Output topic: the broker stamps every record with its append time
kafka-topics.sh --bootstrap-server kafka:9092 --create \
--topic results-out --partitions 12 --replication-factor 1 \
--config message.timestamp.type=LogAppendTime
Tip:
With LogAppendTime on the output topic, the latency of a result is the broker append time minus the event time inside the record. No clock inside the job is involved, so the measurement is fair for every engine. The lab used one broker and a replication factor of 1; use 3 in production.
Step 3: Write the Flink SQL job#
The job keeps a running aggregate per key and writes one output record per input record. It also carries the source partition and offset, so the checker can count every record that is processed twice.
CREATE TEMPORARY TABLE src (
`k` STRING,
`v` STRING,
`p` INT METADATA FROM 'partition' VIRTUAL,
`off` BIGINT METADATA FROM 'offset' VIRTUAL
) WITH (
'connector' = 'kafka',
'topic' = 'events-in',
'properties.bootstrap.servers' = 'kafka:9092',
'properties.group.id' = 'node-loss-lab',
'scan.startup.mode' = 'earliest-offset',
'key.format' = 'raw',
'key.fields' = 'k',
'value.format' = 'raw',
'value.fields-include' = 'EXCEPT_KEY'
);
CREATE TEMPORARY TABLE snk (
`k` STRING,
`cnt` BIGINT,
`last_ts` BIGINT,
`p` INT,
`off` BIGINT,
PRIMARY KEY (`k`) NOT ENFORCED
) WITH (
'connector' = 'upsert-kafka',
'topic' = 'results-out',
'properties.bootstrap.servers' = 'kafka:9092',
'key.format' = 'raw',
'value.format' = 'csv',
'value.fields-include' = 'EXCEPT_KEY',
'sink.delivery-guarantee' = 'at-least-once'
);
INSERT INTO snk
SELECT `k`, COUNT(*) AS cnt, MAX(CAST(`v` AS BIGINT)) AS last_ts, MAX(`p`) AS p, MAX(`off`) AS off
FROM src
GROUP BY `k`;
Key Points:
GROUP BY kkeeps one small state entry per key: 1 million keys, about 100 MB of state in this lab.upsert-kafkawithat-least-oncemeans a replay reaches the output topic as duplicates. That makes the replay visible and countable.pandofflet the checker find the same input offset emitted twice.
Step 4: Deploy the job on Ververica Platform#
Ververica Platform takes the SQL script, the resources and the Flink configuration in one deployment. I used the platform REST API, so every run of the lab was the same. The console offers the same settings in the deployment form.
Save this as deployment.json (paste the SQL from step 3 into sqlScript):
{
"name": "node-loss-lab",
"engineVersion": "vera-4.5-jdk11-flink-1.20",
"executionMode": "STREAMING",
"deploymentTarget": {"mode": "PER_JOB", "name": "default"},
"artifact": {"kind": "SQLSCRIPT", "sqlArtifact": {"sqlScript": "<the SQL from step 3>"}},
"streamingResourceSetting": {
"resourceSettingMode": "BASIC",
"basicResourceSetting": {
"parallelism": 2,
"jobmanagerResourceSettingSpec": {"cpu": 1, "memory": "2Gi"},
"taskmanagerResourceSettingSpec": {"cpu": 2, "memory": "4Gi"}
}
},
"flinkConf": {
"execution.checkpointing.interval": "180 s",
"execution.checkpointing.min-pause": "180 s",
"restart-strategy": "fixed-delay",
"restart-strategy.fixed-delay.attempts": "2147483647",
"restart-strategy.fixed-delay.delay": "10 s",
"taskmanager.numberOfTaskSlots": "1",
"high-availability": "kubernetes",
"kubernetes.taskmanager.node-selector": "karpenter.sh/nodepool:flink-workers",
"kubernetes.taskmanager.tolerations": "key:dedicated,operator:Equal,value:flink,effect:NoSchedule"
}
}
Then create the deployment and start it:
VVP=http://localhost:8080 # port-forward to the platform
AUTH="Authorization: Bearer $VVP_TOKEN" # an access token for the platform API
WS="workspace: defaultworkspace"
# Create the deployment
curl -s -X POST "$VVP/api/v2/namespaces/default/deployments" \
-H "$AUTH" -H "$WS" -H "Content-Type: application/json" -d @deployment.json
# Find its id
DEPLOYMENT_ID=$(curl -s "$VVP/api/v1/namespaces/default/deployments" -H "$AUTH" -H "$WS" \
| jq -r '(.data // .).items[] | select(.metadata.name=="node-loss-lab") | .metadata.id')
# Start it without a savepoint
curl -s -X POST "$VVP/api/v2/namespaces/default/jobs:start" \
-H "$AUTH" -H "$WS" -H "Content-Type: application/json" \
-d "{\"deploymentId\": \"$DEPLOYMENT_ID\", \"restoreStrategy\": {\"kind\": \"NONE\"}}"
Important:
On Ververica Platform, the deployment defaults can set execution.checkpointing.min-pause to 180 s. Always set the checkpoint interval and the minimum pause together. Otherwise a 30 s interval still gives one checkpoint every 3 minutes.
Step 5: Make sure every worker is ready#
Let the job run and catch up with the input first. Then check that every TaskManager pod is Running and ready:
kubectl get pods -n <jobs-namespace> -o wide | grep taskmanager
Trap:
My first spare run was not valid: the spare TaskManager was still pulling its image when the node went away, so there was no spare at all. The lab driver now waits until all expected worker pods are Running and ready, and checks again right before the delete. A spare that is not ready is not a spare.
Step 6: Delete a node, with no spare yet#
Pick the node of an active TaskManager (one that does not host the JobManager) and delete it. Karpenter drains the node: the pods get SIGTERM, then the instance ends. That is the same path as a real node disruption.
NODE=$(kubectl get pod <taskmanager-pod> -n <jobs-namespace> -o jsonpath='{.spec.nodeName}')
kubectl delete node "$NODE" --wait=false
This is what happened, measured from the delete:
| Time after the delete | What happened |
|---|---|
| +2 s | All 12 partitions stop |
| +10 s | Flink restarts the job (fixed-delay 10 s) and asks for one new TaskManager |
| +40 s | Karpenter has a new node ready |
| +111 s | The init container on the new node is done |
| +310 s | The engine image pull is still running, and Flink’s default slot.request.timeout (300 s) fails the job once more |
| +380 s | The next TaskManager registers |
| +383 to +391 s | Output starts again, partition by partition |
| +439 s | Caught up: lag and latency are back to normal |
The bill for one node: 7 min 19 s until caught up, new results up to 398 s late, a peak lag of 21.8 million records, 3.06 million records replayed, and a catch-up burst of up to 588,000 records per second (11.8 times the normal rate).

Important:
Without a spare, the restart waits for Kubernetes: a new node, an init container and a multi-gigabyte engine image pull. If you run without a spare, keep slot.request.timeout above that time. An earlier run of the same loss with slot.request.timeout: 900000 and a faster image pull measured 3 min 28 s.
Step 7: Add one spare TaskManager#
The fix for the waiting is to have the replacement already running. In Flink, that is one setting, plus the resource allocation strategy. Add both to flinkConf and restart the deployment:
"slotmanager.redundant-taskmanager-num": "1",
"slotmanager.resource-allocation.strategy": "DEFAULT"
Important:
On Ververica Platform 3.1.4 (VERA engine) in application mode, slotmanager.redundant-taskmanager-num: 1 alone does not create the spare. It also needs slotmanager.resource-allocation.strategy: DEFAULT. Without it, the job runs with no spare and no warning.
Now the job has 3 TaskManagers: two active and one spare. After the same node delete, all 12 partitions still stop, because Flink restarts the whole job. But Flink uses the spare instead of waiting for a new node:
- Output came back 13 s to 20 s after the delete.
- The job caught up in 29 s.
- New results were up to 25.2 s late, 1.89 million records were replayed, and the burst was 8.1 times the normal rate.

Key Points:
- A keyed job has an all-to-all shuffle between source and aggregation, so the whole job is one failover region. Every partition stops, with or without a spare.
- The spare does not prevent the stop. It removes the wait for a new node and an image pull.
- What is left after the spare is the replay from the last checkpoint.
Step 8: Shorten the checkpoint interval#
With 180 s checkpoints, the replay depends on where in the checkpoint cycle the loss lands. In my two spare runs, the node went away about 96 s after a checkpoint in the first run and about 38 s after one in the second run:
| Spare run | Loss after the last checkpoint | Replayed | Caught up |
|---|---|---|---|
| Run 1 | about 96 s | 4.82 million records | 38 s |
| Run 2 | about 38 s | 1.89 million records | 29 s |
So I set the checkpoint interval to 30 s with a minimum pause of 10 s, and ran the same delete again:
"execution.checkpointing.interval": "30 s",
"execution.checkpointing.min-pause": "10 s"
The job caught up in 27 s, replayed only 0.36 million records, new results were up to 21.3 s late, and the catch-up burst fell to 4.2 times the normal rate (about 240,000 records per second).
Tip:
Treat the checkpoint interval as your replay budget, not only as a checkpoint cost. It is the upper limit of what is processed and sent again after every failure. With an at-least-once sink, every replayed record is a duplicate downstream.
๐ Results#
All runs at 50,000 records per second with one node deleted, one run per setup:
| Setup | Output again after | Caught up | New results late, max | Replayed | Catch-up burst |
|---|---|---|---|---|---|
| No spare, checkpoint 180 s | 383 to 391 s | 439 s | 398 s | 3.06 M | 11.8x |
| 1 spare, checkpoint 180 s (run 1) | 13 to 21 s | 38 s | not measured | 4.82 M | 10.1x |
| 1 spare, checkpoint 180 s (run 2) | 13 to 20 s | 29 s | 25.2 s | 1.89 M | 8.1x |
| 1 spare, checkpoint 30 s | 13 to 21 s | 27 s | 21.3 s | 0.36 M | 4.2x |
“Caught up” means the total lag is back under the baseline threshold and the new-record p99 latency stays under the larger of 2x baseline or baseline plus 1 s, for 20 s. “Catch-up burst” is the highest 5-second output rate after the loss divided by the normal output rate.
๐ How It Compares With Kafka Streams#
I ran the same logic in Kafka Streams 4.3.2 with the same input, the same worker size and the same failure: 3 instances with 2 stream threads each, 2 CPU and 4 GiB each, a RocksDB store with caching off, and at-least-once.
The two engines fail in different ways:
- Kafka Streams is a consumer group. When an instance is lost, only its partitions stop. The rest keep flowing with normal latency. With the default classic group protocol,
close()does not leave the group, even on a clean SIGTERM, so the group waits forsession.timeout.ms(45 s by default) before the rebalance. A standby replica saves the state restore. - Flink restarts the whole job from the last checkpoint. The spare TaskManager decides how long the job stands still. The checkpoint interval decides how much is replayed.
| Setup | Partitions stopped | Output again after | Caught up | Replayed | Catch-up burst |
|---|---|---|---|---|---|
| Kafka Streams, defaults | 6 of 12 | 48 to 54 s | 62 s | 0 | 4.3x |
| Kafka Streams, 1 standby | 6 of 12 | 46 to 50 s | 57 s | 0 | 4.2x |
| Kafka Streams, 1 standby, 10 s session timeout | 4 of 12 | 11 to 15 s | 28 s | 0 | 1.6x |
| Flink, 1 spare, checkpoint 30 s | 12 of 12 | 13 to 21 s | 27 s | 0.36 M | 4.2x |
The Kafka Streams settings for the tuned run:
num.stream.threads=2
num.standby.replicas=1
consumer.session.timeout.ms=10000


Key Points:
- With the right settings, both engines were back to normal in under 30 seconds: 27 s for Flink, 28 s for Kafka Streams.
- Kafka Streams hides the stop: part of the partitions keep running. The session timeout sets how long the rest waits.
- Kafka Streams replayed nothing here because the clean close committed the offsets. After a hard crash it would replay up to one commit interval.
- With recent Kafka 4.x brokers, the new Streams group protocol (
group.protocol=streams) leaves the group on shutdown. I could not test it here because the lab broker was 3.9.
โ Settings I Would Start With#
Production Best Practices:
- Run one spare TaskManager. On Ververica Platform 3.1.4, set both
slotmanager.redundant-taskmanager-num: 1andslotmanager.resource-allocation.strategy: DEFAULT. - Pick the checkpoint interval as a replay budget, and set the minimum pause with it.
- Without a spare, raise
slot.request.timeoutabove the time a new node needs to start and pull the engine image. - Check that the spare is ready before any failure test.
- Measure the lag and the catch-up burst, not only the downtime.
- Plan headroom downstream. The burst reached up to 12 times the normal rate for several seconds. A sink that cannot take it needs headroom, back pressure or a rate limit.
- For Kafka Streams, use one standby replica once the state restore takes too long, and look at the session timeout. A very low value can cause rebalances during long GC pauses.
โ ๏ธ Limits of This Test#
- One run per setup (two for Flink with a spare and 180 s checkpoints), one workload with small state (1 million keys, about 100 MB), one Kafka broker.
- The node was drained by Karpenter, so the pods got SIGTERM. A hard crash was not tested.
- At-least-once only. Exactly-once changes when results become visible downstream and was not part of this test.
- In this lab both engines had plenty of headroom: about 4 times for Kafka Streams and about 10 times for Flink after the loss. With less headroom, the same backlog takes much longer to drain.
๐ฏ Summary#
A node loss is not only a few minutes of downtime. It is a backlog, a replay and a burst that hits every system downstream. In this lab, two settings turned 7 min 19 s into 27 s:
- One spare TaskManager removed the wait for a new node and an image pull: 439 s became 29 s.
- A 30 s checkpoint interval cut the replay from 1.89 million to 0.36 million records and the burst from 8.1x to 4.2x: 29 s became 27 s.
Measure your own jobs the same way: delete a node on purpose, watch the lag and the output rate from outside the engine, and tune until the catch-up fits what your downstream systems can absorb.
๐ค How Ververica Can Help#
Ververica: Delivery Assurance for mission-critical real-time data. Built by the original creators of Apache Flinkยฎ. Late is the same as never.
A node will fail one day. What matters is that the job is back in time, and that the catch-up does not overload the systems behind it. That is the kind of question this lab answers, and the kind of work Ververica does with teams every day:
- Ververica Platform: one deployment holds the SQL, the resources and the Flink configuration, including the spare TaskManager and the checkpoint settings from this post. Use the console or the REST API, as in step 4.
- Deployment options: run it self-managed, in your own cloud account with Bring Your Own Cloud, or as a managed service.
- VERA: the engine behind Ververica Platform, used for the Flink runs in this lab.
- Professional services: help to test and tune recovery for your own jobs, from failure tests like this one to checkpoint and replay budgets.
- Zero distance: the people who built the engine are the people who answer.
If you want to run this test on your own jobs, or talk about recovery targets for your streaming platform, reach out to me on LinkedIn or through Ververica.







