QuizzesCaching Strategies & Database Patterns
intermediate
system-design
Caching Strategies & Database Patterns
Deep dive into caching patterns, cache invalidation, database indexing, and distributed data patterns.
25 minutes 8 questions Pass at 70%
Time Limit
25 minutes - timer starts when you begin
Change Answers Freely
Revisit and change any answer before submitting
Full Review After Submit
Correct answers and explanations shown for every question
Auto-submit on timeout
Quiz submits automatically when time runs out
Questions in this quiz
8 questions on Caching Strategies & Database Patterns. Work through them here, then start the quiz to answer them and see your score.
1.What is the cache-aside (lazy loading) pattern?
- ARead from DB and update cache in the background asynchronously
- BPopulate the cache on application startup with all data
- CCheck cache → cache miss → read from DB → write to cache → return data
- DWrite to cache and DB simultaneously on every request
2.What is a cache stampede (thundering herd) and how do you prevent it?
- AA cache that returns stale data to all users during a deploy
- BA cache that fills up and starts evicting entries under high load
- CWhen too many cache nodes go down at once, overloading the remaining nodes
- DMany requests hitting the DB simultaneously when a popular cache key expires — prevent with mutex locks or probabilistic early expiry
3.What is write-through caching?
- AWrite to cache only; database is updated asynchronously
- BWrite to database only; cache is updated on the next read
- CWrite to cache and database synchronously — both are always in sync
- DWrite to cache; database is never updated
4.What is a database index and what is the downside of having too many?
- AIndexes compress table data; too many increase disk usage only
- BIndexes replicate data across shards; too many cause synchronisation overhead
- CIndexes enforce uniqueness; too many cause constraint violations
- DIndexes speed up reads by creating a separate data structure; too many slow down writes and waste disk space
5.What is eventual consistency and when is it acceptable?
- AA database that runs in eventual mode, which is stronger than ACID
- BThe system will become consistent over time — acceptable for non-critical, high-scale scenarios like social media counts
- CA consistency model where writes are never acknowledged
- DConsistency that is enforced at the end of the business day
6.What is a bloom filter and what is it used for?
- AA network packet filter that blocks unwanted traffic
- BA probabilistic data structure that can say "definitely not in set" or "possibly in set" — used to avoid expensive lookups
- CA compression algorithm for bloom-shaped data distributions
- DA filter that removes duplicate rows from query results
7.What is the difference between optimistic and pessimistic locking?
- AOptimistic: locks the entire table; Pessimistic: locks individual rows
- BThey are identical concepts used in different database vendors
- COptimistic: no lock on read, validate at write time; Pessimistic: lock the row on read, preventing concurrent writes
- DOptimistic: uses transactions; Pessimistic: uses explicit locks
8.What is connection pooling and why is it critical for database performance?
- AEncrypting database connections for security
- BDistributing database connections across multiple servers
- CMaintaining a pool of pre-opened database connections to avoid the overhead of creating a new connection per request
- DLimiting the number of concurrent database queries