My fix:
• Namespace every ID (agency1:1, agency2:1)
• Keep shared stops separate
• Link them with a near-zero-cost transfer edge
• Then route with RAPTOR
Stack:
• Go → routing, search, realtime (latency-critical paths)
• Python → GTFS ingestion (messy feed parsing)
• Kong + Postgres + Redis, all on Kubernetes
Why polyglot? Use each language where it’s strongest.
Python for ingestion (pandas, validation libraries, offline batch). Go for routing, search and realtime, where latency matters.
Push complexity out of the query path and into an offline job.
How do you handle ID collisions across feeds?
Ingestion Service, Part 5: Most transit apps fail before the first route is calculated.
They fail at ingestion.
Here’s how the ingestion service in City Connector, our multi-agency routing platform, keeps bad data away from the router. 🧵
Schedule updates: the Routing Service builds the new in-memory timetable in the background, then swaps it in atomically.
In-flight queries finish on the old version. Zero downtime, no dropped requests.
Shared transit hubs: we don’t merge stops across agencies. Merging risks false matches and corrupted schedules.
They stay separate, joined by a near-zero-cost transfer edge. Riders still switch operators smoothly.
The pipeline:
1. Validate structure and references in staging
2. Namespace every ID as {agency}:{id}
3. Load into PostgreSQL + PostGIS with version tags
4. Precompute walking footpaths
Routing never does spatial math at query time.
The problem: every agency publishes its own GTFS feed, and IDs are only unique within that feed.
Agency A’s stop “1001” and agency B’s stop “1001” can be different places. One collision and the router sends riders to the wrong stop.
Stop And Search Service, Part 4: Transit apps live or die on how fast the map shows nearby stops. Here’s how I designed the search service for City Connector 🧵
The sneaky bug: Routing hot-swaps its timetable, but Search reads Postgres directly. Without a shared active-version pointer, riders can tap stops the router doesn’t know. Version goes in every cache key too.
Nearby stops use a two-stage PostGIS query: ST_DWithin bounds the candidates, then KNN ordering ranks them. Short statement timeouts keep slow queries from draining the pool.
Why a separate service? Journey planning is CPU-bound (RAPTOR). Stop discovery is I/O-bound (spatial queries). Split them so a rush-hour routing spike can’t freeze the map.
Next problem: applying live delays AFTER the search can hide a missed transfer.
Are you applying delays before or after routing? Curious what others do.
New schedule? Build a fresh snapshot in the background, then swap one pointer.
In-flight queries finish on the old copy. Zero downtime, zero dropped requests.
The timetable lives in memory, not in the database.
One query reads it thousands of times, and even a 1ms DB round trip per read would blow the budget. Postgres stays the source of truth.