AngoraTek
← Back to Insights
Geospatial · 8 min read

Building Real-Time Fleet Tracking with HERE APIs

Fleet tracking at scale is a data pipeline problem, not a map problem. The map is the easy part. The hard part is ingesting millions of position updates per hour, validating them, keeping hot state low-latency, and rendering only what the user needs to see.

The Problem

A fleet of 10,000 vehicles reporting every 5 seconds produces 2,000 position updates per second. During shift changes, that rate can spike to 3–5×. Each update must be validated, persisted, and made queryable within milliseconds. Miss that window, and the map shows stale data.

The Architecture

A production fleet tracking system has three layers:

  1. Ingestion — Vehicles publish positions via MQTT into a position ingestion service.
  2. State — The service writes current positions to Redis and persists all positions to PostgreSQL.
  3. Presentation — A tile server reads from Redis and serves the frontend.
Data enters through MQTT, branches at the ingestion service, and flows out through the tile server. Redis holds the last-known position for every vehicle with a 5-minute TTL. PostgreSQL stores the full trip history.

Position Ingestion

The ingestion layer is where most systems break. Three design decisions matter:

  1. Use MQTT, not HTTP. MQTT provides persistent connections, low overhead, and built-in QoS. Most fleet telematics devices support it natively. Raw UDP is faster but sacrifices delivery guarantees that compound at scale.
  2. Batch writes to Redis. Accumulate 50–100 positions before writing atomically. One write per position will saturate your connection pool under load.
  3. Implement backpressure. When Redis throughput falls behind ingestion rate, drop stale positions rather than accumulating unbounded lag.
// Batch ingestion in Rust
async fn ingest_positions(batch: Vec<PositionReport>, redis: &RedisClient) {
    let mut pipe = redis.pipeline();

    for report in batch {
        let key = format!("vehicle:{}", report.vehicle_id);
        pipe.set_ex(key, serialize(&report), 300); // 5 min TTL
    }

    pipe.exec_async().await?;
}

HERE Fleet Integration

HERE's Fleet API provides routing, traffic, and geocoding. It is not designed for high-frequency position updates. Use it for what it does well:

  • Route calculation — Optimal paths from origin to destination with live traffic.
  • Geocoding — Address to coordinate conversion for origin and destination resolution.
  • Reverse geocoding — Coordinate to address conversion for delivery confirmation.
For position ingestion and state management, rely on your own Redis and PostgreSQL layers.

Frontend Performance

Three rules keep the frontend responsive at scale:

  1. Debounce position updates. Batch at 60 frames per second maximum. Do not re-render on every WebSocket message.
  2. Interpolate between positions. Smooth vehicle movement with linear interpolation to avoid visual stutter.
  3. Cull outside the viewport. Render only vehicles visible in the current map bounds.
function interpolatePosition(
  prev: Position,
  next: Position,
  progress: number
): Position {
  return {
    lat: prev.lat + (next.lat - prev.lat) * progress,
    lng: prev.lng + (next.lng - prev.lng) * progress,
    heading: prev.heading + (next.heading - prev.heading) * progress,
  };
}

Lessons from Production

After deploying fleet tracking for logistics companies across North America and Europe:

  1. GPS drift is real. Implement snap-to-road algorithms or minimum-movement thresholds that filter positions within 5 meters of the last known.
  2. Store all timestamps in UTC. A vehicle crossing from CET to EET reports timestamps differently. UTC eliminates ambiguity.
  3. Buffer for offline scenarios. Vehicles lose signal in tunnels and parking garages. Buffer positions on the device and replay on reconnect to preserve trip continuity.

Technology Selection

LayerUseAvoid
HERE Fleet APIRouting, traffic, geocodingReal-time position ingestion
RedisLast-known positions, hot stateLong-term storage, analytics
PostgreSQLTrip history, persistent storageReal-time query serving
Mapbox GLInteractive maps, custom stylingServer-side data processing
Get the pipeline right. The map follows. AngoraTek builds fleet tracking systems for enterprises. Talk to us if you are scaling location-aware operations.