Design App Version Targeting for User Groups
Design a service and its database for releasing app versions. It registers versions, tags a version to groups of users, and tells each app which version a user should run.
Problem statement
Design a service that lets a company release different versions of its apps to different groups of users. The service tells each app which version a user should run. Pay particular attention to the database design: the tables, the keys, and the rules the database enforces.
For this exercise, assume the company has about 500 apps. Each app has many versions. A version has a number such as 4.12.3 that orders it among the versions of its app. It also has a link to its build and release notes. The number, build link and notes never change after the version is registered. A release manager can withdraw a version, which means it is never offered again. Users are put into groups, such as internal staff, beta testers or one country. A user can be in many groups. A built-in group named everyone holds every user. A release manager tags a version of an app to a group, which means the group is meant to run that version. A group has at most one tag for each app, and a new tag replaces the old one. The release manager can also clear a tag, or roll a group back by tagging an earlier version. When an app starts, it asks the service which version the signed-in user should run and tells it which version is installed. The answer is the newest version that the user may have. It is not withdrawn, and it is tagged for that app to any group the user is in. Newest means the highest version number. If there is none, or the user already runs that version or a newer one, the answer is none. Apps only move up. Every tag change is recorded with who made it and when. The team must be able to ask what a group's tag was at any past moment.
Also assume about 100 million users, each in about 5 groups on average (never more than 200), and about 100,000 groups. Update checks arrive at about 300 million a day, up to 20,000 a second at peak. An answer should take less than 100 ms at the 99th percentile. Tag changes are rare, at most 100 a minute.
A change should reach update checks within 60 seconds. An admin can add or remove up to 1 million users in one group at a time. Tag history is kept for 2 years. Building and delivering the app files, percentage rollouts and sign-in are out of scope.
So are billing, targeting by device or operating system, forcing users back to an older version, and use in more than one region.
What to build
- A release manager registers an immutable version of an app. Its number orders it among that app's versions. The manager can withdraw it so it is never offered again.
- An admin creates user groups and adds or removes users. One change can cover a single user or up to 1 million at once. A built-in everyone group holds every user.
- A release manager tags a version of an app to a group, clears the tag, or rolls the group back. Every change is recorded with who and when. The tag a group had at any past moment can be read back.
- When an app asks which version a user should run, the service answers with the newest non-withdrawn version tagged to any of the user's groups. If there is none, it answers none.
At scale
- For this exercise, assume about 500 apps, about 100 million users, each in about 5 groups on average and never more than 200, and about 100,000 groups.
- For this exercise, assume update checks arrive at about 300 million a day and up to 20,000 a second at peak. An answer takes less than 100 ms at the 99th percentile.
- For this exercise, assume at most 100 tag changes a minute, and a tag change or a withdrawal reaches update checks within 60 seconds.
- For this exercise, assume an admin can add or remove up to 1 million users in one group in one request. About 500 million memberships exist at once.
- For this exercise, assume tag history is kept for 2 years, and that no app has tags for more than a few hundred groups.