User interface for translating language
Able to translate inputted language into target language
Supports multiple languages
Able to detect input language
Able to serve thousands of request per second.
Able to support offline translation mode.
For this application, I would say the number of users would be in the millions, but daily usage would not be as high as other popular type of applications.
Even considering peak usage, where millions of request are made in short span, scaling this horizontally would not be a problem with auto scaling.
I am going to focus on storage calculations.
Assume daily active users of 10 million, peak usage could be 30,000 concurrent request.
Assume each request contains an average of 200 words and each word is around 10 bytes then 200 words would be 200 * 10 = 2000 bytes
So during peak time it would need to process 2000 * 30,000 = 60 mb of data.
This is should be within the bounds of an above average cpu spec. We can set the specs of our CPU instance accordingly.
translate(words, targetLanguage)
The translate APIs will take in an array of words and target language and returns the translated array of words.
We will assume that we have an existing translation engine that would perform the translation for us. The main place where we would use a store would be to cache common translations. We can store frequently translated phrases or sentences in a data store, and improve response time by quickly retrieving commonly requested translations.
User interface for user to submit their input for translation. This could be web or mobile.
The load balancer is responsible for balancing request between different instances of the backend service.
This is where the backend service take the request and direct it to the appropriate service. This is essentially a BFF.
Translation service is where it looks up the cache for existing translation or direct the request to the translation engine.
The translation engine is responsible for translation on the fly. This could be a third party service such as amazon translate or google translation service.
The translation engine decides whether to store the response into the Redis cache. The translation service grabs data from the Redis cache is it's able to find 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...
The most interesting component is probably the translation engine and translation service.
If we are using third party solution such as amazon translation or google translation then the translation engine would be pretty trivial as we would implement integrate with these services. However if we are rolling our solution we would have incorporate advanced technologies and techniques such as machine learning to translate different languages.
I won't go into detail on how these ML models are implemented, we will assume that we can implement them if needed.
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?