Tagged Table:
Tag (VARCHAR) -> 21 bytes
ItemName (VARCHAR) -> 21 bytes
ItemID (VARCHAR) -> 16 bytes -> MD5 hash
Assuming every document has 5 tags, each document is ~142 bytes
14 200 000 000 bytes -> 14 200 000 KB -> 14 200 MB -> 14.2 GB
14.2 GB of tagging per day -> will need to scale horizontally
User Table:
UserID (INT autoincrement 4.2B should be good for now) -> 4 bytes
First Name (VARCHAR) -> 8 Bytes
Last Name (VARCHAR) -> 8 Bytes
20 bytes per row
Assuming 4 billion users (4b is an overestimation):
20 000 000 000 bytes -> 20 000 000 kb -> 20 000 mb -> 80GB
No need to scale yet
On average DB can hold 8 ZettaBytes
External Endpoints:
POST:
GET:
Use Elastic Search DB to find items more quickly (NoSQL) to search by tag
Index by tag and item name
{
UserID: 123,
items: {
item1ID: {itemName: itemName, tags: []},
item2ID: {itemName: itemName, tags: []},
}
}
MySQL for User Table:
Shard ElasticSearchDB by user ID to scale horizontally
Provide Tag Suggestion
-> option 1: Grab all tags and client-side can implement partial search system
-> option 2: Client side implements debouncing method, send request to serverside to get suggested tags
Use elastic search to optimize for tag searches by indexing on tags, and item name
Too many tags, need to scale horizontally, can shard elasticSearchDB by useID range -> shard by userID because it doesnt matter what other people have as tags or what they have tagged on item, we only want to search for the current user
Can add meta data to tags