India’s Leading Domain & Web Hosting Provider
Ride-hailing platform moves trip and payments ledger to Spanner with zero data loss
Ride-hailing and auto-rickshaw aggregator, 22 cities, 1.8 million trips a day · Pan-India · 14 weeks
As-is situation
Trips, fares, driver payouts and wallet transactions lived in a sharded MySQL estate of 16 primaries on Compute Engine, split by city. Cross-city riders and drivers broke the sharding model, forcing application-level two-phase commits for wallet transfers. Evening peaks reached 9,500 writes per second and shard primaries in the three largest cities ran above 85% CPU. Resharding to add cities took a six-hour maintenance window. Asynchronous replicas in a second region lagged up to 90 seconds, so the payments team could not guarantee zero loss of settled fares during a regional failure.
- Application-managed cross-shard transactions causing about 0.04% of wallet transfers to need manual reconciliation
- Shard primaries above 85% CPU at evening peak in three metros
- Six-hour maintenance windows for each resharding exercise
- Up to 90 seconds of replication lag, unacceptable under RBI payment data and settlement expectations
Selected Google Cloud services and architecture
NTSPL designed a single Spanner database in dual-region-india1 on Enterprise Plus edition, with the leader in Mumbai and a full replica set in Delhi. Trips use UUIDv4 primary keys with trip events and fare components interleaved beneath them, and wallet ledger entries use a bit-reversed sequence key to avoid hotspots. Cross-city wallet transfers became ordinary read-write transactions. The managed autoscaler scales processing units between 18,000 and 42,000 on CPU utilization. Change streams feed Dataflow into BigQuery for finance reporting, and driver location pings stay in Memorystore rather than the ledger.
Implementation approach
Measured results
Operational improvements
- No more resharding projects; capacity follows load through the managed autoscaler
- Finance closes daily settlement from BigQuery without querying production shards
- Regional failover is handled by Spanner itself instead of a manual MySQL promotion runbook
Cost considerations
Enterprise Plus pricing for a dual-region configuration was the main cost driver and was accepted because RPO zero was a business requirement. A three-year committed use discount covers the 18,000 processing-unit floor, with autoscaled capacity above it billed on demand. Driver location data stays in Memorystore to avoid paying Spanner write costs for high-churn, low-value data.
Return on investment
Eliminating reconciliation effort and resharding windows saves an indicative INR 1.2-1.6 crore a year in operations and lost-trip revenue. Spanner costs about 25% more than the self-managed shards on raw infrastructure, but removing three DBA positions' worth of shard maintenance makes the total cost broadly neutral within the first year.