1:3 write/read ratio
10.000 writes per day
30.000 reads per day
parking lot will contains following fields:
Sum - 24 bytes, round to 30 bytes.
Initially we will have 1000 parking lots - 1000*30=30Kb but further we will expect scaling to 100.000 parking lots - 3Mb
get /lots (float latitude, float longitude, string filter) - get closest parking lots to the user
get /spots/{parking_lot_id} () - return available parking spots in selected parking lot
post /reserve_spot/{parking_spot_id} (date start_time, date end_time) - reserving parking spot
post /cancel_spot/{parking_spot_id} () - cancelation of parking spot
In order to store reservation data we will use relational database as PostgreSQL and plugin PostGIS to store geodata such as latitude and longitude
we will have four tables such as user, reservation, parking_lot, parking spot
Geospatial indexes on latitude and longitude, B-tree indexes on startDate, endDate
client sends request to search closest parking lots. After that load balancer with path-based algorithm send to load balancer between closest lots servers. Load balancer between closest lots servers uses round-robin strategy. After that closest lots server according to user's location uses quadtree index in PostgreSQL in order to find closest lots and sort them according to user filter. After that each top parking lot determines how many available parking spots it has.
client sends request to make a reserve or cancel of parking spot. Load balancers as described higher sends to reservation server. After that this server updates reservation table
How we will find closest parking lots with filtration?
Our parking lot location will be stored in quadtree, which allows to find lots nearby. Additionally we calculate distance between user's location and closest lots. After that we can add filters such as cost, rating and delete or sort best options
Database failover: we can replicate database and make asynchronious replication in order to redirect requests if database crash
Adding monitoring and logging for system checking
Database can be partioned by country/city located parking lots
Scale system to the whole world