Logistics

A last-mile delivery company operates 3,200 vans across 12 metro areas. Each van runs 80-120 stops per day. Customer satisfaction drops 34% when ETAs are off by more than 15 minutes, but static route estimates don't account for real-time traffic, weather, or driver pace.

Static ETAs generated at morning dispatch are 25+ minutes off by afternoon. Customer 'where is my package' calls spike 4x after 2 PM.
LIVEgps_pings
van_idlatlngspeed_mphheadingstops_remainingts
VAN-184739.2904-76.612242.3185342024-03-15T13:30:01.000Z
VAN-184739.2831-76.60988.7190342024-03-15T13:31:01.000Z
VAN-184739.2789-76.60855.2188342024-03-15T13:32:01.000Z
VAN-042233.749-84.38838.1270222024-03-15T13:30:01.000Z
VAN-042233.7488-84.395535.6265222024-03-15T13:31:01.000Z
VAN-311040.758-73.985512.445482024-03-15T13:30:01.000Z
Streaming SQLRunning
Compute segment travel time using real-time speed vs historical
CREATE SOURCE gps_pings WITH (
  connector = 'kafka',
  topic = 'fleet.gps_pings',
  properties.bootstrap.server = 'broker:9092'
) FORMAT PLAIN ENCODE JSON;

CREATE MATERIALIZED VIEW segment_travel_time AS
SELECT
  van_id,
  window_start,
  AVG(speed_mph) AS avg_speed_mph,
  h.historical_avg_speed,
  CASE
    WHEN AVG(speed_mph) < 1 THEN 999
    ELSE ROUND(
      h.segment_distance_mi / AVG(speed_mph) * 60, 1
    )
  END AS est_segment_minutes,
  ROUND(
    h.segment_distance_mi / h.historical_avg_speed * 60, 1
  ) AS historical_segment_minutes,
  ROUND(
    (h.segment_distance_mi / AVG(speed_mph) * 60)
    - (h.segment_distance_mi / h.historical_avg_speed * 60), 1
  ) AS delay_vs_historical_min,
  MAX(stops_remaining) AS stops_remaining
FROM TUMBLE(gps_pings, ts, INTERVAL '60 SECONDS') g
JOIN route_segments h
  ON g.van_id = h.van_id
  AND h.segment_seq = (
    SELECT MAX(segment_seq) FROM route_segments r
    WHERE r.van_id = g.van_id
    AND r.segment_start_lat BETWEEN g.lat - 0.005 AND g.lat + 0.005
  )
GROUP BY van_id, window_start, h.historical_avg_speed, h.segment_distance_mi;
Cascade delay through remaining stop sequence
eta_updatesauto-updating
van_idnext_stoporiginal_etaupdated_etadelay_minconfidence
VAN-1847352024-03-15T13:45:00.000Z2024-03-15T14:03:00.000Z180.55
VAN-1847422024-03-15T14:30:00.000Z2024-03-15T14:52:00.000Z22.10.55
VAN-0422232024-03-15T13:50:00.000Z2024-03-15T13:52:00.000Z1.80.92
VAN-3110482024-03-15T13:55:00.000Z2024-03-15T14:01:00.000Z5.40.78
RisingWave recalculates ETAs for all 3,200 vans every 60 seconds using live GPS + traffic. When VAN-1847 hits I-95 congestion, the remaining 34 stops' ETAs shift forward 18 minutes — customers get proactive SMS updates before they call.
Best-in-Class Event Streaming
for Agents, Apps, and Analytics
GitHubXLinkedInSlackYouTube
Sign up for our to stay updated.