Why Computers Can't Count Sometimes

Tom Scott
12 Nov 201808:44

Summary

TLDRThe video explains why view and subscriber counts can be inconsistent on sites like YouTube and Twitter. It comes down to race conditions when requests collide, eventual consistency where updates are batched, and caching where different servers supply slightly outdated information. Calculating accurately at scale is difficult. So while the final counts will be correct, there can be lag and fluctuations before the dust settles.

Q & A

  • Why can view counts and subscriber counts sometimes fluctuate or be inaccurate on sites like YouTube?

    -This can happen due to race conditions when requests collide, as well as caching, where different caches store slightly different view counts that get served to users randomly. Overall it takes time for the eventual consistency to resolve across the distributed system.

  • What is a race condition and how does it cause issues with accuracy?

    -A race condition happens when multiple threads try to read, update and write data at the same time, and the final result depends on the order those operations occur in. This can result in lost updates.

  • How does queueing requests help accuracy?

    -Putting all requests in a queue and processing them one by one ensures updates cannot collide. However, this does not scale well to sites with enormous traffic volumes.

  • What is eventual consistency?

    -Eventual consistency is where distributed databases sync up less frequently to reduce load, allowing counts to be slightly wrong temporarily before resolving. This scales better but accuracy lags.

  • What is caching and how does it help sites handle traffic?

    -Caching is keeping commonly requested data in fast memory to avoid hitting the main database every time. This improves performance dramatically but can cause inconsistent results.

  • Why can buying something like concert tickets require stronger consistency?

    -For buying tickets, it would be very problematic if race conditions allowed the same seat to be sold twice. So stronger consistency guarantees are needed, even if it reduces scalability.

  • Why is scaling database systems to handle massive traffic difficult?

    -Every request takes time to process. At large scale the volume can overwhelm a single database. Solutions like caching and eventual consistency help but reduce accuracy.

  • How could the issues explained impact something like tracking ad revenue?

    -Inaccurate counts could lead to incorrect ad revenue tracking. However important metrics usually use stronger consistency. Caching and lagging mostly impacts secondary data like page views.

  • What are some ways sites balance consistency and scalability?

    -They prioritize stronger guarantees for important things like financial data, while allowing lags and inaccuracies temporarily for secondary metrics. Different tradeoffs per metric.

  • Why is accurate counting harder than it may appear at first glance?

    -Even simple incrementing relies on separate read, calculate and write steps. At scale these collide across threads and servers, with caching adding further complexity on large systems.

Outlines

plate

This section is available to paid users only. Please upgrade to access this part.

Upgrade Now

Mindmap

plate

This section is available to paid users only. Please upgrade to access this part.

Upgrade Now

Keywords

plate

This section is available to paid users only. Please upgrade to access this part.

Upgrade Now

Highlights

plate

This section is available to paid users only. Please upgrade to access this part.

Upgrade Now

Transcripts

plate

This section is available to paid users only. Please upgrade to access this part.

Upgrade Now