POST /tweet {
"user_id": "456",
"create_time": datetime,
"title": "XXXX",
"content": "YYYYY",
} -> insert a new tweet in the database, and return the unique id
GET /tweet?id=123
-> return the specified tweet and display it to the user
GET /tweet?keywords=abc+efg&author=XXX&time_range=YYYY_ZZZZZ
-> return a list of tweets matching keywords, time range, and/or author.
POST /like {
"tweet_id": "123",
"user_id": "456",
"create_time": datetime,
} -> create a new like for the given tweet.
Database Schema:
User {
"id": str - primary key
"name": str - index,
"create_time": datetime,
"email": str,
"tweet_list": list of tweets }
Tweet {
"id": str - primary key
"create_time": datetime,
"title": str - inverted index,
"content": str - inverted index,
"likes": list of user ids }
With 200M new tweets per day, the total database storage is 200M * 2MB * 365 * 3 = 400PB in 3 years.
Client:
API gateway:
Tweet server:
Elasticsearch:
Cache and CDN:
Elasticsearch:
Cache and CDN:
Scalability:
Fault tolerance: