System Design Concepts Part:-3 Caching Strategies
Caching Strategies

System Design Concepts Part:-3 Caching Strategies

Content Studio Naveen chandrawanshi

Read the full newsletter here :- link

Join our free newsltter here

Read Strategies:

  1. Cache Aside (Lazy Loading): How it Works: Prioritizing cache access, this strategy retrieves data from the database only when the cache misses. Usage: Ideal for scenarios where cache misses are infrequent, and the acceptable latency of a miss plus database read is feasible.
  2. Read Through: How it Works: The cache autonomously manages database reads, seamlessly fetching absent data on cache miss. Usage: Abstracting database logic from application code, this strategy ensures a consistently populated cache by handling misses automatically.

Write Strategies:

  1. Write Around: How it Works: Skips the cache and directly writes data to the database. Usage: Suitable for situations where newly written data won't be immediately read back from the cache.
  2. Write Back (Delayed Write): How it Works: Initially writes data to the cache, with subsequent asynchronous writes to the database. Usage: Appropriate for environments with heavy write traffic, where minimal data loss is acceptable.
  3. Write Through: How it Works: Ensures immediate writes to both cache and database. Usage: Crucial for scenarios where data consistency is of utmost importance.

Real-Life Usage:

Cache Aside + Write Through: This strategy ensures a synchronized cache and database while granting control over cache population during reads. However, the immediate database writes might strain the system in situations with frequent writes.

Read Through + Write Back: Abstracting database logic and efficiently handling bursts of write traffic, this strategy delays synchronization. However, there's a risk of increased data loss if the cache goes down before syncing buffered writes to the database.

Caching strategies are not only vital for optimizing database performance but are also indispensable in improving the speed and responsiveness of web applications. Specifically, caching strategies for images play a crucial role in reducing latency and enhancing user experience.

Common Image Caching Strategies:

Browser Caching: This strategy involves storing images in the user's browser cache, reducing the need for repeated downloads and significantly improving page load times for returning visitors.

Content Delivery Networks (CDNs): Utilizing CDNs allows images to be stored on servers closer to users, reducing latency and improving page load times based on users' geographical locations.

Edge Caching: Storing images closer to the user's ISP at the edge of the network further reduces latency, enhancing page load times and user experience.

Memcached and Redis: These in-memory data stores offer faster caching than traditional databases, making them ideal for caching frequently accessed resources like images.

Join our newsletter for free

Join our newsletter for free

Varnish Cache: An HTTP caching proxy that caches both static and dynamic content, offering image optimization and load balancing capabilities.

Reverse Proxy Caching: Employing a server as a reverse proxy can cache images and other static content, optimizing performance for users.

Object Caching: Storing images as objects in cloud storage services like Amazon S3 or Google Cloud Storage provides scalability and durability for image storage.

Server-Side, Database, and Hybrid Caching: Various strategies involving caching images on the server, in databases, or through hybrid approaches offer tailored solutions for different applications and requirements.

Understanding these caching strategies for images and their application scenarios empowers developers and database managers to make informed choices, optimizing overall system performance and delivering a seamless user experience.

Also read the previous newsletters:-

Part:-1



Part:-2

Join our Newsletter for free



Poornesh Singh

Software Consultant at YDM ?????? | Mentor ?? | Tech Career Counsellor ?? | Content Creator ?? | Talks on AI, ML, Cloud ?? | Resource Sharing ?? | DSA Cheatsheets

10 个月

Great Share

回复

要查看或添加评论,请登录

社区洞察

其他会员也浏览了