10m suggestions per day * 70b = 700 MB a day
255.5 GB a year.
since I am caching the prefixes we will have to increase the amount of data by the binomial coefficient. 60 + 50 + 40 + 30 + 20 + 10 = 210b
2.10 GB a day and 765GB a year
If users continue to search for the same things we shouldn't have to create too many more records. The first year will create the most data giving 10m suggestions per day.
getSuggestions(string search, string locale, {lat,long} location): string[]
query on each new word added to the search query
We will use mongoDB for storing the search queries in tries.
With the prefix being the ket and the values being the suggestions.
For each prefix, we will create a separate record
ex: How many baseball fields are in Kansas?
k: how v: [text: many baseball fields are in Kansas, w: 1, text: many people like apples, w: 7]
k: how many v: baseball fields are in Kansas, w:3
k: how baseball v: fields are in Kansas, w: 101
The db will have weight values allowing us to rank which.
Reranking the values will have to be don once the user has chosen a suggestion
LB is round robin
API gateway will rate limit
Suggestion Service gets the highest-ranked suggestion from the cache
Consistency issues with DB. You will get different suggestions
Issues doing any complex queries that may be user-specific. So we can't tailor suggestions to a specific user efficiently.
The bottlenecks would be updating prefix trie records that have very common 2-word starts?
How many
Where is
How do
...
What are some future improvements you would make? How would you mitigate the failure scenario(s) you described above?