List functional requirements for the system (Ask the chat bot for hints if stuck.)...
List non-functional requirements for the system...
Estimate the scale of the system you are going to design...
Num weather queries per second per location = 1 million
Storage Estimation:
Amount of weather data for a location = 700 bytes per day (data about hourly temp, rain, daily wind speed, precipitation chance) + any warnings
Amount of weather data for a location for 10 days = 7KB
Num locations served by the app = 25000 (50 States in USA * 500 aggregate zip codes per state)
Total data stored for 10 days = 25000 * 7KB = 200MB
Old data is archived to tape backup.
Define what APIs are expected from the system...
Gives weather data for a given location for the next n days:
GET https://
Response: 200 OK
{
day:
max temp:
min temp:
rain:
wind speed:
precipitation:
}
......
Gives weather data per hour for given day within next 10 days
GET https://
Response: 200 OK
{
time:
temp:
rain:
},
......
Gives all advisories for given day or future days
GET https://
Response: 200 OK
{
id:
text:
time:
},
....
Internal APIs: Add/Update weather information to the system
POST/PUT https://
{
date:
hour:
max temp:
min te mp:
rain:
}
Response: 201 created
Defining the system data model early on will clarify how data will flow among different components of the system. Also you could draw an ER diagram using the diagramming tool to enhance your design...
At any time, active(useful) data in the system is for 10 days only. As explained in capacity estimation, this is 200 MB. This much data can be accommodated in a single SQL Database.
Multiple database instances can be used for storing global data, if required.
Weather Table
============
Date:
Time: (every hour)
Zip Codes: (multiple zip codes which are close by will have same weather)
Max Temp:
Min Temp:
Wind Speed:
Precipitation Chance:
Advisory Table
=============
AdvisoryId:
Date:
Time:
Zip Codes:
Content:
Start:
End:
Notifications Table
================
NotificationId:
AdvisoryId:
You should identify enough components that are needed to solve the actual problem from end to end. Also remember to draw a block diagram using the diagramming tool to augment your design. If you are unfamiliar with the tool, you can simply describe your design to the chat bot and ask it to generate a starter diagram for you to modify...
CDN (Content Distribution Network): Caches latest weather data so that the server is not loaded. CDNs are kept according to the geography, e.g., a CDN in New York hosts data for all eastern states on USA.
API Server: Requests which cannot get served from the CDN reach the main API server.
Cache: API server also maintains a cache of frequently queried data
External Data Source: Source of weather data like satellite systems and data maintained by local weather department. This component is external to our system.
Data Collection: Collects data from the external source through a nightly job and updates Weather DB. It also sends Alerts and Advisories to Notifications System.
Weather DB: Written/updated by Data Collection service and read by API server to service queries.
Notification Service: Sends Push Notifications or emails to the users.
Archiver: Archives old data(> 10 days old) to tape backup.
User: Can be a web user or mobile app. If mobile app, web socket (wss) connection is maintained and Notifications are sent on it.
Explain how the request flows from end to end in your high level design. Also you could draw a sequence diagram using the diagramming tool to enhance your explanation...
CDN (Content Distribution Network): Caches latest weather data so that the server is not loaded. CDNs are kept according to the geography, e.g., a CDN in New York hosts data for all eastern states on USA.
API Server: Requests which cannot get served from the CDN reach the main API server.
Cache: API server also maintains a cache of frequently queried data. Mobile app also maintains a cache locally.
External Data Source: Source of weather data like satellite systems and data maintained by local weather department. This component is external to our system.
Data Collection: Collects data from the external source through a nightly job and updates Weather DB. It also sends Alerts and Advisories to Notifications System.
Weather DB: Written/updated by Data Collection service and read by API server to service queries.
Notification Service: Sends Push Notifications or emails to the users.
User: Can be a web user or mobile app. If mobile app, web socket (wss) connection is maintained and Notifications are sent on it.
Mobile app can query the server every night to get the updated info and cache it locally.
Dig deeper into 2-3 components and explain in detail how they work. For example, how well does each component scale? Any relevant algorithm or data structure you like to use for a component? Also you could draw a diagram using the diagramming tool to enhance your design...
Explain any trade offs you have made and why you made certain tech choices...
Try to discuss as many failure scenarios/bottlenecks as possible.
What are some future improvements you would make? How would you mitigate the failure scenario(s) you described above?
Future Improvement: