User data: SQL DB
Tables:
Workouts
Goals
Users
Put a workout: The client sends a PUT request to /workouts with a json payload with the parameters. The request gets routed and arrive to the API Gateway, which forwards it to the LoadBalancer. The LB chooses a server and forwards the request. The server verifies that the client is authenticated, verifying the auth cookie. If not good, the servers sends a response unauthorized. If good, the server creates a new workout entry in the key-value store (e.g. dynamo or mongodb), and replies with success.
All other flows are similar.
The APIGateway receives the HTTP requests, performs basic verification such as DoS attacks, and routes the requests to the LB. A load balancer keeps a list of active servers, and chooses a server based on an algorithm.
The cloud service (like EC2) monitors the health and load of the servers scales up or down (creating new instances or shutting down some) if the load is too high/low or a server is unresponsive.
The key-value store is horizontally scalable and it is good on write requests.
The solution uses 2 database types. While this adds complexity, it fits different use cases for different data access and scalability patterns. The users data is not too large and requires high consistency, thus a relational db is better suited for that. For workouts and goals, a key-value store allows for very high write and reads, scaling horizontally, which is good for the not relational workout data while having eventual consistency.
A
What are some future improvements you would make? How would you mitigate the failure scenario(s) you described above?