GET /forecast
input params: location, datetime
returns:
{
temperature,
condition
}
Forecast table
The location and eventually the timestamp should be indexed to maximize lookup performance
Two main services:
We need to answer the user even if the exact requested location isn't in the database. To do that we can give the forecast of the closest location.
Efficient geospatial data structure (quadtree for instance) is needed to do that.
We should use a database system that supports geospatial data structure
Data can be cached using a TTL that trigger eviction when the period of the forecast is passed
As the system read-only (from a user perspective), there is no restriction regarding the consistency so we can choose the technology that provides us the best performance and scalability (NoSQL)
There can be peaks of users activity like in the morning when users check for the current day forecast
To handle these peak of activity we can pre-cache the data for the next day during the night (only for the most frequently asked areas)
We will need an analytic service to know which areas are the most requested for our caching strategy