SysPadExamples › 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.

Client Users Load Balancer ALB Business Service Fargate Location-Based Serv… Fargate Business Info Cache ElastiCache Geohash Cache ElastiCache Business DB Aurora Nightly Rebuild Sch… EB Scheduler Geo Index Rebuilder Batch

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

  1. Client
  2. Load Balancer
  3. Location-Based Service
  4. Geohash Cache
  5. Business DB
  6. Business Info Cache

View a business

  1. Client
  2. Load Balancer
  3. Business Service
  4. Business Info Cache
  5. Business DB

Edit a business

  1. Client
  2. Load Balancer
  3. Business Service
  4. Business DB

Nightly index rebuild

  1. Nightly Rebuild Schedule
  2. Geo Index Rebuilder
  3. Business DB
  4. Geohash Cache
  5. Business Info Cache

Other interview practice

Open this architecture in SysPad · All examples