Chapter 10 checkpoint

Twitter timeline and search

Every question from this chapter’s lessons, grouped by the lesson that teaches it. Answer each one right to finish; you can try again whenever you like.

0 of 17 answered right

10.1 Requirements, estimates and the timeline API

0 of 4 answered right
Open the lesson
Question 1
Users post 500 million tweets a day, and each is delivered to 10 followers on average. About how many deliveries per second is that?
deliveries/s

Answers within 5% count.

Question 2
Each home-timeline entry is 17 bytes. Keeping 800 entries for each of 100 million active users, how much RAM is that before replication, in TB?

Answers within 5% count, in any unit you choose.

Question 3
Twitter replicated each timeline entry on 3 machines. How much RAM does the 1.36 TB of timelines need once replicated, in TB?

Answers within 5% count, in any unit you choose.

Question 4
Tweets average 10 KB including media, and 500 million arrive each day. How much new content accumulates in 3 years, in PB?

Answers within 5% count, in any unit you choose.

10.2 Fan-out on write, on read, or both

0 of 5 answered right
Open the lesson
Question 5
What is the main trade-off between fan-out on write (push) and fan-out on read (pull)?

Question 6
How does the hybrid design deal with accounts that have millions of followers?

Question 7
Followers of a celebrity sometimes see a reply to the celebrity’s tweet before the tweet itself. Why, and what mitigates it?

Question 8
Match each timeline strategy to the work it does.

Question 9
A user returns after 40 days away, and the cache holds timelines only for users active in the last 30 days. What does the primer do?

10.3 Storage, sharding and the timeline cache

0 of 4 answered right
Open the lesson
Question 10
Snowflake gives each generator a 12-bit sequence per millisecond. At most how many IDs can one generator produce per second?
IDs/s

Answers within 1% count.

Question 11
How does Snowflake make IDs that are roughly time ordered without a central counter?

Question 12
You shard the tweet store by user_id. What do you gain and what do you risk?

Question 13
After an NTP correction moves a server’s clock back by two seconds, its Snowflake generator stops returning IDs for about two seconds. Why?

10.4 Real-time search and scatter-gather

0 of 4 answered right
Open the lesson
Question 14
Earlybird hash-partitions tweets across its servers. Why must each search query go to every server?

Question 15
Put the steps of the primer’s search request in order.
  1. 1
    Send the query to every server in the search cluster
  2. 2
    Merge, rank and sort the results
  3. 3
    Return the results to the user
  4. 4
    Each server returns its best matches
  5. 5
    Parse and tokenize the query, normalizing terms

Question 16
The postings list for “raft” is [1042, 1089, 2104], and for “consensus” it is [1042, 1520, 2104]. Which documents match raft AND consensus?

Question 17
Each of 8 shards returns its top 10 matches, and the front end merges them. Assume a document scores the same whichever shard holds it. Is the merged top 10 the same as searching one big index would give?