SysPad › Examples › Proximity service
Proximity service
A read-heavy Location-Based Service fans each search into 9 geohash-cell reads on a sharded Redis cache, a small Business Service handles CRUD and detail pages through an info cache, and a nightly batch rebuild is what makes owner edits visible next day.
Read/write asymmetry as an architecture: the search path is cache-first and 9x-amplified, writes skip the caches entirely, and freshness is a scheduled batch job, not cache invalidation.
- Throughput: 6,500 req/sec
- First to saturate: Nothing at this load
- Estimated cost: $3,364/mo
How it works
- Load Balancer
- Path-based routing: /search/nearby goes to the LBS, /businesses to the Business Service. Three AZs so one zone loss never takes the search path down (availability NFR).
- Business Service
- Owner CRUD plus customer detail pages. Sized independently of the LBS: 200M businesses generate tens of writes per second, three orders of magnitude below search reads.
- Location-Based Service
- Stateless and read-only, so it scales horizontally for peak-hour spikes in dense cities. The user location is geohashed in memory and never persisted (privacy NFR).
- Business Info Cache
- business_id -> business object. One MGET hydrates a whole search result page, and detail views read it first. Misses read through to a DB replica.
- Geohash Cache
- geohash -> business IDs at precisions 4/5/6 (roughly 20km/5km/1km search radii). Every search reads its cell plus 8 neighbours, so this tier sees 9x the search rate. Sharded for the 200M-ID keyspace and to spread hot urban cells; a replica per shard covers AZ failure.
- Business DB
- Primary takes owner writes; replicas serve cache-miss geo queries, read-through detail misses, and the nightly rebuild scan. Replica lag is a non-issue because next-day freshness is a stated FR.
- Geo Index Rebuilder
- Chunked Spot jobs page the business table from a replica and rewrite every geohash cell and info entry. This batch path, not cache invalidation, is how an owner edit becomes visible - the write path never touches the caches.
Request flows
Search nearby
- Client
- Load Balancer
- Location-Based Service
- Geohash Cache
- Business DB
- Business Info Cache
View a business
- Client
- Load Balancer
- Business Service
- Business Info Cache
- Business DB
Edit a business
- Client
- Load Balancer
- Business Service
- Business DB
Nightly index rebuild
- Nightly Rebuild Schedule
- Geo Index Rebuilder
- Business DB
- Geohash Cache
- Business Info Cache