GET "/parking_spots/:vehicle_type"
{
parking_spots: [......]
}
POST "/parking_spot/reserve"
{
parking_spot_id: ...,
timestamp: ...
}
POST "/parking_spot/release"
{
parking_spot_id: ...,
timestamp: ...
}
Parking Spot
User
Api gateway. Reservation Service. Load balancer in front of reservation service. Distributed lock(reddison). Postgres DB.
Once a user authenticates and wants to reserve a spot, user will request parking spot based on vehicle type. User will then select the spot which will reserve the spot, authentication will work based on session cookies. We will use a distributed lock(reddison) to ensure the spot is available. If the spot is reserved out reservation service will send an error back to the user and if the spot is available we will update the user record current parking spot attribute with the parking spot id and update the status of the parking spot record to taken and then release our distributed lock. Once the user wants to release the spot they will go through the application, exit the parking lot and click a release button which will update both the user record parking spot id to nil and update the parking spot record to available.
Once a user authenticates and wants to reserve a spot, user will request parking spot based on vehicle type. User will then select the spot which will reserve the spot, authentication will work based on session cookies. We will use a distributed lock(reddison) to ensure the spot is available. If the spot is reserved out reservation service will send an error back to the user and if the spot is available we will update the user record current parking spot attribute with the parking spot id and update the status of the parking spot record to taken and then release our distributed lock. Once the user wants to release the spot they will go through the application, exit the parking lot and click a release button which will update both the user record parking spot id to nil and update the parking spot record to available.
Explain any trade offs you have made and why you made certain tech choices...
We will have a master slave system where we duplicate our current database on a secondary server in case one server fails, we will spin up a replica of the secondary server and make the secondary server take over the master system and the replica be the new secondary server. We will also periodically dump our postgres DB in case it fails. If the postgress db does fail we will use the dump of our database and spin up a new server with the dump image.
What are some future improvements you would make? How would you mitigate the failure scenario(s) you described above?