Caching Strategies & CDN Design Interview Questions Hindi mein

Caching Strategies & CDN Design कोर्स के 25 सवाल, हर सवाल के सही जवाब और explanation के साथ। जवाब देखने से पहले ख़ुद सोचें।

Why and Where to Cache

1. Which data is the best candidate for caching?

  1. Product descriptions read thousands of times per minute and edited a few times a day
  2. A wallet balance during payment authorisation
  3. A one-time password
  4. A log line written once and never read
जवाब देखें

जवाब: Product descriptions read thousands of times per minute and edited a few times a day

Frequently read, rarely changed data that tolerates brief staleness benefits most from caching.

पाठ: What Caching Buys You

2. Which cache layer is shared by all application instances but sits inside your own infrastructure?

  1. The browser cache
  2. An in-process hash map
  3. The CPU L1 cache
  4. A distributed cache such as Redis
जवाब देखें

जवाब: A distributed cache such as Redis

A distributed cache is shared across instances, unlike per-process caches.

पाठ: Caching Layers from Browser to Database

3. A cache serving 10,000 requests per second improves from a 95% to a 99% hit ratio. What happens to origin traffic?

  1. It halves
  2. It stays the same
  3. It drops from 500 to 100 requests per second
  4. It increases
जवाब देखें

जवाब: It drops from 500 to 100 requests per second

Misses fall from 5% to 1% of 10,000, so origin load drops from 500 to 100 per second.

पाठ: Hit Ratio, Effective Latency and the Working Set

Read and Write Patterns

4. In cache-aside, what does the application do after updating a record in the database?

  1. Nothing; the TTL handles it
  2. Flushes the entire cache
  3. Deletes (invalidates) the corresponding cache entry
  4. Writes the old value back to the cache
जवाब देखें

जवाब: Deletes (invalidates) the corresponding cache entry

Deleting the key forces the next read to load the fresh value.

पाठ: Cache-Aside (Lazy Loading)

5. Which strategy risks losing recent updates if the cache crashes?

  1. Write-through
  2. Write-behind (write-back)
  3. Write-around
  4. Cache-aside with invalidation
जवाब देखें

जवाब: Write-behind (write-back)

Write-behind acknowledges writes before they reach the database.

पाठ: Read-Through, Write-Through, Write-Behind and Write-Around

6. What problem does negative caching solve?

  1. Repeated lookups for keys that do not exist hitting the database every time
  2. Values that are too large
  3. Keys that never expire
  4. Encrypting cached data
जवाब देखें

जवाब: Repeated lookups for keys that do not exist hitting the database every time

Caching "not found" briefly protects the origin from repeated misses on absent keys.

पाठ: TTLs, Refresh-Ahead and Negative Caching

Invalidation and Consistency

7. Why do most systems combine explicit invalidation with a TTL?

  1. The TTL acts as a safety net that eventually fixes entries whose invalidation was missed
  2. TTLs make caches faster
  3. Explicit invalidation cannot work without a TTL
  4. Redis requires both
जवाब देखें

जवाब: The TTL acts as a safety net that eventually fixes entries whose invalidation was missed

Explicit invalidation keeps data fresh; the TTL bounds how long a missed invalidation can cause staleness.

पाठ: Why Invalidation Is Hard

8. Why is deleting a cache key on write usually safer than writing the new value into the cache?

  1. Deleting is faster in every cache
  2. Writing to caches is not allowed
  3. Deleting also updates the database
  4. Concurrent writers could otherwise leave an older value in the cache last
जवाब देखें

जवाब: Concurrent writers could otherwise leave an older value in the cache last

With concurrent updates, set operations can land out of order; deletes force a fresh reload.

पाठ: Invalidation Strategies

9. In the stale-set race, what causes the cache to hold an old value?

  1. The TTL is too long
  2. Redis loses data
  3. A slow reader writes the value it read before the update, after the writer has deleted the key
  4. The database rolls back
जवाब देखें

जवाब: A slow reader writes the value it read before the update, after the writer has deleted the key

The reader's set lands after the invalidation, reinstating an outdated value.

पाठ: Race Conditions and Stale Sets

Failure Modes Under Load

10. What does request coalescing do during a cache miss on a hot key?

  1. Sends every request to the database in parallel
  2. Deletes the key permanently
  3. Lets one caller recompute the value while others wait for that result
  4. Doubles the TTL of all keys
जवाब देखें

जवाब: Lets one caller recompute the value while others wait for that result

Coalescing collapses many identical misses into one recomputation.

पाठ: Cache Stampede and Request Coalescing

11. Bots request millions of random, non-existent product IDs, and each one hits the database. What is this called and how can it be mitigated?

  1. Cache avalanche; add more replicas
  2. Cache penetration; use negative caching, validation and a Bloom filter
  3. Cache stampede; increase TTL
  4. Write-behind; flush faster
जवाब देखें

जवाब: Cache penetration; use negative caching, validation and a Bloom filter

Lookups for missing keys bypass the cache; negative caching and Bloom filters stop them early.

पाठ: Cache Avalanche and Cache Penetration

12. Why does a single extremely hot key overload one cache node even in a large cluster?

  1. Each key is stored on one node (shard), so all its traffic goes to that node
  2. Clusters cannot store popular keys
  3. Hot keys are always big keys
  4. TTLs do not apply to hot keys
जवाब देखें

जवाब: Each key is stored on one node (shard), so all its traffic goes to that node

Sharding distributes keys, not the traffic to one key; replication or local caching spreads that load.

पाठ: Hot Keys and Big Keys

Eviction and Distributed Caches

13. A cache sees regular full-table scans that pollute it with rarely used entries. Which policy family resists this best?

  1. LFU or TinyLFU-style frequency-based eviction
  2. FIFO
  3. LRU
  4. noeviction
जवाब देखें

जवाब: LFU or TinyLFU-style frequency-based eviction

Frequency-based policies keep popular entries even when a scan touches many one-off keys.

पाठ: Eviction Policies

14. What is a key difference between Memcached and Redis?

  1. Memcached supports sorted sets and streams
  2. Redis cannot be used as a cache
  3. Memcached uses 16,384 hash slots
  4. Redis offers rich data structures, replication and optional persistence; Memcached is a simple key-value cache
जवाब देखें

जवाब: Redis offers rich data structures, replication and optional persistence; Memcached is a simple key-value cache

Redis is a data-structure server with replication and persistence; Memcached focuses on simple caching.

पाठ: Redis, Memcached and Cache Clusters

15. What is the main drawback of an in-process cache in a service with ten instances?

  1. It is slower than Redis
  2. It cannot have a TTL
  3. Each instance holds its own copy, so instances can briefly serve different values
  4. It requires a database
जवाब देखें

जवाब: Each instance holds its own copy, so instances can briefly serve different values

Per-instance copies can diverge after updates until TTLs expire or invalidations arrive.

पाठ: In-Process and Two-Level Caches

HTTP Caching

16. Which directive lets a CDN cache a response for longer than browsers do?

  1. private
  2. no-store
  3. s-maxage
  4. must-revalidate
जवाब देखें

जवाब: s-maxage

s-maxage applies to shared caches and overrides max-age there.

पाठ: Cache-Control and Friends

17. What does a 304 Not Modified response mean?

  1. The resource was deleted
  2. The cached copy is still valid and can be reused; no body is sent
  3. The server is down
  4. The client must not cache the response
जवाब देखें

जवाब: The cached copy is still valid and can be reused; no body is sent

304 confirms the validator still matches, so the cache reuses its stored body.

पाठ: Validation: ETag, Last-Modified and Vary

18. What does stale-if-error allow a cache to do?

  1. Serve stale content for a limited time if the origin is failing
  2. Delete content when the origin errors
  3. Ignore Cache-Control headers
  4. Return errors faster
जवाब देखें

जवाब: Serve stale content for a limited time if the origin is failing

stale-if-error keeps serving the last good copy during origin failures, within the stated window.

पाठ: Stale-While-Revalidate, Stale-If-Error and Asset Fingerprinting

CDN Design

19. What is the purpose of an origin shield (tiered cache)?

  1. Collapsing misses from many edge PoPs into fewer requests to the origin
  2. Encrypting data at the origin
  3. Blocking all bots
  4. Hosting the database
जवाब देखें

जवाब: Collapsing misses from many edge PoPs into fewer requests to the origin

A shield tier absorbs edge misses so the origin sees far fewer requests.

पाठ: How CDNs Work

20. Marketing links add different utm_ parameters to the same URL, and the CDN hit ratio drops. What is the best fix?

  1. Disable the CDN
  2. Set no-store on all pages
  3. Shorten every TTL to one second
  4. Exclude tracking parameters from the cache key
जवाब देखें

जवाब: Exclude tracking parameters from the cache key

Removing irrelevant parameters from the key lets all variants share one cached object.

पाठ: Cache Keys and Purging

21. A news site gets a sudden spike on its home page, which changes every minute. What edge setting helps most?

  1. Cache-Control: no-store
  2. Removing the CDN
  3. Micro-caching with a short s-maxage plus stale-while-revalidate
  4. Varying the cache on the User-Agent header
जवाब देखें

जवाब: Micro-caching with a short s-maxage plus stale-while-revalidate

Even a few seconds of shared caching collapses a spike into a handful of origin requests.

पाठ: Dynamic Content, Edge Compute and Security

Operating Caches, Security and Revision

22. Why should load tests include a cold-cache scenario?

  1. Cold caches are faster
  2. It removes the need for warm-cache tests
  3. It shows how the origin copes after a deploy or cache failure when the hit ratio is near zero
  4. Caches cannot be tested warm
जवाब देखें

जवाब: It shows how the origin copes after a deploy or cache failure when the hit ratio is near zero

Cold-cache tests reveal whether the origin survives when caching suddenly stops helping.

पाठ: Monitoring and Testing Caches

23. What is the most important header setting for a personalised account page?

  1. Cache-Control: public, max-age=3600
  2. Cache-Control: private or no-store
  3. Cache-Control: s-maxage=600
  4. Vary: User-Agent only
जवाब देखें

जवाब: Cache-Control: private or no-store

Personalised responses must never be stored in shared caches.

पाठ: Caching and Security

24. In the case study, why does checkout read price and stock directly from the database?

  1. Decisions that charge money or commit stock must use current data, even if pages show slightly stale values
  2. Redis cannot store prices
  3. CDNs block checkout pages
  4. Databases are faster than Redis
जवाब देखें

जवाब: Decisions that charge money or commit stock must use current data, even if pages show slightly stale values

Display may tolerate staleness; transactions must use the source of truth.

पाठ: Case Study: Caching an E-Commerce Catalogue

25. Which header value tells caches they may store a response but must revalidate it before every use?

  1. no-store
  2. immutable
  3. public, max-age=31536000
  4. no-cache
जवाब देखें

जवाब: no-cache

no-cache permits storage but requires revalidation; no-store forbids storage.

पाठ: Revision and Interview Questions

← कोर्स पर वापस जाएँ