RobotGuide
Labs/QoS and Callback Backlog

Lab 10 / 15 · ROS 2 / middleware

QoS and Callback Backlog

Drag publish rate, callback time, and queue depth, and watch latency climb from 3 ms to hundreds of milliseconds.

Math: High school math is enoughNo coding neededNo hardware needed≈ 8 min

Link parameters

Publish rateselect
Callback time0.6 ms
Queue depth10 msgs
QoSselect

Once callback time exceeds the publish period the queue must back up. Only two choices remain: drop data or let latency grow without bound.

Readouts

P50 latency—
P99 latency—
Max latency—
Drop rate—
Effective processing rate—
Verdict—

This model counts queuing only — no network, no retransmission — so what it gives you is a floor. Real systems only get worse, never better.

What problem this lab solves

The most expensive failure in ROS 2 is not an error — it is «it runs, but latency keeps creeping up». When publish rate exceeds the subscriber's processing capacity, messages pile up in the queue and latency rises linearly; with RELIABLE configured you lose even the pressure-relief valve of dropping, and the backlog grows until memory runs out. This experiment lets you push the system to that point with your own hands.

How to read the figure

Top half is a timeline: thin vertical lines are publish moments, bars are messages being processed, red squares are dropped messages. Bottom half is each message's latency from publish to finished processing. A flat curve means keeping up; a climbing curve means backlog; a curve clipped at the top means the queue is full and everything after is dropped.

Hands-on

First set callback time just past the period (say 1kHz publishing, 1.2ms processing) and watch latency rise linearly; then drop the queue from 10 to 2 and watch the drop rate; finally switch on RELIABLE and watch «no more drops — but unbounded latency».

Related topics

Next labs (in play-learn order)