<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Omkar Jadhav on Medium]]></title>
        <description><![CDATA[Stories by Omkar Jadhav on Medium]]></description>
        <link>https://medium.com/@omkarj.9900?source=rss-72ffb130a6a3------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*Azu3fSDnEoCCAYhSD5NT4A.jpeg</url>
            <title>Stories by Omkar Jadhav on Medium</title>
            <link>https://medium.com/@omkarj.9900?source=rss-72ffb130a6a3------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Fri, 20 Nov 2026 05:39:49 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@omkarj.9900/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Cache Eviction Policies Explained: TTL, LRU, LFU, MRU & SLRU with Real-World Examples]]></title>
            <link>https://medium.com/@omkarj.9900/cache-eviction-policies-explained-ttl-lru-lfu-mru-slru-with-real-world-examples-065807d92f27?source=rss-72ffb130a6a3------2</link>
            <guid isPermaLink="false">https://medium.com/p/065807d92f27</guid>
            <category><![CDATA[cache]]></category>
            <category><![CDATA[lfu-cache]]></category>
            <category><![CDATA[ttl]]></category>
            <category><![CDATA[lru-cache]]></category>
            <category><![CDATA[cache-eviction-policies]]></category>
            <dc:creator><![CDATA[Omkar Jadhav]]></dc:creator>
            <pubDate>Sat, 03 Oct 2026 03:55:57 GMT</pubDate>
            <atom:updated>2026-10-03T03:55:57.727Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*7ILoUL-Z58cFWFIwwUwMXQ.png" /></figure><p><strong>Imagine you are building a backend application.</strong></p><p>Your database contains millions of records, but your application repeatedly asks for the same data:</p><ul><li>User profiles</li><li>Product details</li><li>Configuration</li><li>Authentication/session information</li><li>Frequently viewed posts</li><li>Exchange rates</li><li>API responses</li><li>Frequently accessed database queries</li></ul><p>If every request goes directly to the database, your application can become slower and the database can become overloaded.</p><p>So you introduce a <strong>cache</strong>.</p><p>The idea is simple:</p><pre>Client<br>   ↓<br>Application<br>   ↓<br>Cache<br>   ↓<br>Database</pre><p>If the data is available in the cache, return it quickly.</p><p>If it isn’t:</p><pre>Cache Miss<br>   ↓<br>Database<br>   ↓<br>Store result in Cache<br>   ↓<br>Return result</pre><p>This can significantly reduce repeated database work.</p><p>But now another problem appears:</p><blockquote><strong><em>What happens when the cache becomes full?</em></strong></blockquote><p>You cannot keep storing data forever.</p><p>At some point, the cache needs to remove existing entries to make room for new ones.</p><p>This is where <strong>Cache Eviction Policies</strong> come into the picture.</p><h3>1. What Is Cache Eviction?</h3><p><strong>Cache eviction</strong> is the process of removing entries from a cache when they are no longer useful, expired, or when the cache needs space for new data.</p><p>For example, suppose our cache can store only 4 items:</p><pre>Cache Capacity = 4</pre><pre>┌─────┬─────┬─────┬─────┐<br>│  A  │  B  │  C  │  D  │<br>└─────┴─────┴─────┴─────┘</pre><p>Now the application wants to cache item E.</p><p>But there is no space.</p><p>So we need to answer:</p><blockquote><em>Which item should we remove?</em></blockquote><p>Possible answers:</p><ul><li>Remove the item that hasn’t been used recently → <strong>LRU</strong></li><li>Remove the item that is accessed least frequently → <strong>LFU</strong></li><li>Remove the item whose lifetime has expired → <strong>TTL</strong></li><li>Remove the most recently used item → <strong>MRU</strong></li><li>Divide entries into segments and protect frequently reused entries → <strong>SLRU</strong></li></ul><p>The choice can affect:</p><ul><li>Cache hit rate</li><li>Database load</li><li>Application latency</li><li>Memory usage</li><li>Infrastructure cost</li><li>Overall system performance</li></ul><h3>2. First Understand Cache Hit and Cache Miss</h3><p>Before understanding eviction policies, let’s understand two important terms.</p><h3>Cache Hit</h3><p>A cache hit occurs when the requested data already exists in the cache.</p><p>For example:</p><pre>User requests Product #101</pre><pre>Application → Cache</pre><pre>Cache contains Product #101</pre><pre>                    ↓<br>                Cache HIT</pre><pre>                    ↓<br>             Return Product</pre><p>The application doesn’t need to query the database.</p><h3>Cache Miss</h3><p>A cache miss happens when the requested data isn’t available in the cache.</p><pre>User requests Product #101</pre><pre>Application → Cache</pre><pre>Product #101 not found</pre><pre>                    ↓<br>                Cache MISS</pre><pre>                    ↓<br>                Database</pre><pre>                    ↓<br>          Store result in Cache</pre><pre>                    ↓<br>              Return Product</pre><p>A good cache strategy generally tries to maximize useful cache hits while keeping memory usage under control.</p><h3>3. Why Can’t We Simply Keep Everything in Cache?</h3><p>Because memory is limited.</p><p>Suppose your application has:</p><pre>Available Cache Memory = 1 GB</pre><p>Your application keeps adding:</p><pre>User data<br>Product data<br>API responses<br>Session data<br>Configuration<br>Search results</pre><p>Eventually:</p><pre>Used Memory<br>████████████████████ 100%</pre><pre>Cache Full 🚨</pre><p>Now a new item needs to be inserted.</p><p>Something has to leave.</p><p>This is the <strong>eviction problem</strong>.</p><h3>4. Cache Eviction Is Similar to Managing a Small Room</h3><p>Imagine you have a small storage room with space for only 4 boxes.</p><p>Initially:</p><pre>┌─────┬─────┬─────┬─────┐<br>│ A   │ B   │ C   │ D   │<br>└─────┴─────┴─────┴─────┘</pre><p>Someone brings another box:</p><pre>E</pre><p>You need to remove one box.</p><p>How do you decide?</p><h3>Option 1</h3><p>Remove the box nobody has opened recently.</p><p>→ <strong>LRU</strong></p><h3>Option 2</h3><p>Remove the box that has been opened the fewest times.</p><p>→ <strong>LFU</strong></p><h3>Option 3</h3><p>Remove the box whose expiration date has passed.</p><p>→ <strong>TTL</strong></p><h3>Option 4</h3><p>Remove the box that was opened most recently.</p><p>→ <strong>MRU</strong></p><h3>Option 5</h3><p>Keep frequently reused boxes in a protected area.</p><p>→ <strong>SLRU</strong></p><p>This simple example is basically what cache eviction policies are trying to solve.</p><h3>5. TTL — Time-To-Live</h3><p>Let’s start with one of the easiest policies.</p><p><strong>TTL means Time-To-Live.</strong></p><p>The idea is:</p><blockquote><em>Every cache entry has a lifetime. Once that lifetime expires, the entry is no longer considered valid.</em></blockquote><p>For example:</p><pre>User Session</pre><pre>TTL = 30 minutes</pre><p>The application stores:</p><pre>session:user:101</pre><p>with:</p><pre>Created: 10:00 AM<br>TTL:     30 minutes</pre><p>At:</p><pre>10:30 AM</pre><p>the entry expires.</p><h3>Real-Life Example: OTP</h3><p>Suppose you generate an OTP:</p><pre>OTP = 482913</pre><p>You don’t want this OTP to remain valid forever.</p><p>You might store:</p><pre>otp:user:101 → 482913<br>TTL → 5 minutes</pre><p>After 5 minutes:</p><pre>OTP expired</pre><p>This is a perfect use case for TTL.</p><h3>Another Example: Product Price</h3><p>Suppose an e-commerce application stores product prices.</p><pre>product:101:price → ₹999<br>TTL → 10 minutes</pre><p>After 10 minutes, the cache entry expires.</p><p>The next request can fetch the latest price from the database/service and refresh the cache.</p><h3>6. Why TTL Is Useful</h3><p>TTL is especially useful when data has a natural expiration period.</p><p>Examples:</p><pre>OTP              → 5 minutes<br>Session          → 30 minutes<br>Temporary token  → 15 minutes<br>API response     → 5 minutes<br>Weather data     → 10 minutes<br>Exchange rate    → 1 minute</pre><p>The important idea is:</p><blockquote><strong><em>The data doesn’t necessarily become useless because it hasn’t been accessed. It becomes invalid because enough time has passed.</em></strong></blockquote><p>That’s different from LRU.</p><h3>7. TTL’s Problem</h3><p>Imagine:</p><pre>TTL = 10 minutes</pre><p>Suppose a product is extremely popular.</p><p>During those 10 minutes:</p><pre>Product A → accessed 100,000 times</pre><p>But the TTL expires.</p><p>The cache removes it even though users are still requesting it.</p><p>Then:</p><pre>Request<br>   ↓<br>Cache MISS<br>   ↓<br>Database<br>   ↓<br>Cache</pre><p>This can create unnecessary database requests.</p><p>So TTL is not based on popularity or recent access.</p><p>It is based on <strong>time</strong>.</p><h3>8. LRU — Least Recently Used</h3><p>Now let’s look at one of the most common cache eviction concepts.</p><p><strong>LRU = Least Recently Used</strong></p><p>The basic rule is:</p><blockquote><em>Remove the item that has not been accessed for the longest time.</em></blockquote><p>Imagine the cache contains:</p><pre>A<br>B<br>C<br>D</pre><p>And their last-access times are:</p><pre>A → 10 minutes ago<br>B → 5 minutes ago<br>C → 2 minutes ago<br>D → 10 seconds ago</pre><p>If the cache is full and a new item arrives:</p><pre>E</pre><p>LRU says:</p><pre>Evict A</pre><p>because A was used least recently.</p><h3>9. Real-Life Example of LRU</h3><p>Imagine your browser has limited memory for recently visited pages.</p><p>You recently opened:</p><pre>Google<br>YouTube<br>GitHub<br>LinkedIn<br>Amazon</pre><p>But you haven’t opened Google for several hours.</p><p>Meanwhile:</p><pre>GitHub → opened 2 minutes ago<br>LinkedIn → opened 5 minutes ago<br>Amazon → opened 10 minutes ago</pre><p>If the system needs to remove something, Google becomes a logical candidate because it hasn’t been used recently.</p><p>That’s the basic intuition behind LRU.</p><h3>10. Why LRU Works</h3><p>LRU relies on an important assumption:</p><blockquote><strong><em>If something was used recently, there is a good chance it will be used again soon.</em></strong></blockquote><p>This is called <strong>temporal locality</strong>.</p><p>For example:</p><pre>User opens Product A</pre><pre>Product A<br>Product A<br>Product A</pre><p>There is a good chance that recently accessed data will be requested again.</p><p>LRU tries to keep those recently used items.</p><h3>11. LRU Example Step-by-Step</h3><p>Suppose cache capacity is:</p><pre>3</pre><p>Initially:</p><pre>Cache:</pre><pre>[A] [B] [C]</pre><p>Access:</p><pre>A</pre><p>Now A becomes most recently used.</p><p>Conceptually:</p><pre>[B] [C] [A]</pre><p>Then access:</p><pre>B</pre><p>Now:</p><pre>[C] [A] [B]</pre><p>Now a new item D arrives.</p><p>The least recently used item is:</p><pre>C</pre><p>So:</p><pre>[C] ← Evicted</pre><pre>[A] [B] [D]</pre><p>The important point is that eviction depends on <strong>recency</strong>, not frequency.</p><h3>12. LRU’s Limitation</h3><p>Consider this access pattern:</p><pre>A B C D E F G H I J</pre><p>Suppose the cache can store only 3 items.</p><p>Every new request may push an old item out.</p><p>LRU can perform poorly when the workload repeatedly scans through a dataset larger than the cache.</p><p>For example:</p><pre>Cache size = 3</pre><pre>Access:<br>A → B → C → D → E → F → A → B → C</pre><p>By the time A is requested again, it may already have been evicted.</p><p>This is sometimes called a <strong>scan-like workload</strong>.</p><p>So LRU is not automatically optimal for every workload.</p><h3>13. LFU — Least Frequently Used</h3><p>Now let’s change the question.</p><p>LRU asks:</p><blockquote><em>“When was this item used?”</em></blockquote><p>LFU asks:</p><blockquote><em>“How many times was this item used?”</em></blockquote><p><strong>LFU = Least Frequently Used</strong></p><p>Suppose we have:</p><pre>A → accessed 2 times<br>B → accessed 50 times<br>C → accessed 100 times<br>D → accessed 5 times</pre><p>If the cache is full and something needs to be evicted:</p><pre>A</pre><p>is a candidate because it has the lowest access frequency.</p><h3>14. Real-Life Example: YouTube / Netflix-Type Content</h3><p>Imagine a video platform.</p><p>Suppose these videos are accessed:</p><pre>Video A → 5 requests<br>Video B → 10 requests<br>Video C → 100,000 requests<br>Video D → 3 requests</pre><p>Video C is extremely popular.</p><p>You would probably want to keep it cached because many users are requesting it.</p><p>LFU captures this idea:</p><pre>Popular data → Keep<br>Rarely accessed data → Evict</pre><h3>15. LFU vs LRU</h3><p>This is an important interview question.</p><p>Suppose:</p><pre>A → accessed 10,000 times yesterday<br>B → accessed 10 times recently</pre><p>A has a much higher frequency.</p><p>LFU may prefer:</p><pre>A</pre><p>But LRU might prefer:</p><pre>B</pre><p>if B was accessed more recently.</p><p>So:</p><pre>LRU → cares about recency</pre><pre>LFU → cares about frequency</pre><h3>16. LFU’s Problem</h3><p>Frequency alone can also be misleading.</p><p>Imagine:</p><pre>A → accessed 1,000,000 times</pre><p>But all those accesses happened six months ago.</p><p>Currently:</p><pre>A → not accessed recently</pre><p>LFU may still consider A important because its historical frequency is high.</p><p>This is why practical LFU implementations often need additional mechanisms such as aging, frequency decay, or recency information.</p><p>The general lesson is:</p><blockquote><em>Historical popularity doesn’t always mean current popularity.</em></blockquote><h3>17. MRU — Most Recently Used</h3><p>Now comes the strategy that initially feels strange.</p><p><strong>MRU = Most Recently Used</strong></p><p>Instead of removing the least recently used item, we remove:</p><blockquote><strong><em>The item that was accessed most recently.</em></strong></blockquote><p>At first, this sounds completely wrong.</p><p>Why would we remove something we just used?</p><p>Because some workloads behave differently.</p><h3>18. Real-Life Example of MRU</h3><p>Imagine a system processing a sequence of records:</p><pre>A → B → C → D → E</pre><p>Suppose the application reads each item once and moves forward.</p><p>Once the application has processed:</p><pre>E</pre><p>there may be little reason to immediately process E again.</p><p>In workloads like certain sequential scans, streaming, or batch-processing patterns, the most recently used item may actually have a lower probability of immediate reuse than older items.</p><p>In those specific situations, MRU can make sense.</p><h3>19. LRU vs MRU</h3><p>The difference is simple:</p><pre>LRU:<br>Remove → least recently accessed</pre><pre>MRU:<br>Remove → most recently accessed</pre><p>Example:</p><pre>A → accessed 10 minutes ago<br>B → accessed 5 minutes ago<br>C → accessed 1 minute ago</pre><p>LRU:</p><pre>Evict A</pre><p>MRU:</p><pre>Evict C</pre><p>The important point is:</p><blockquote><em>MRU is not a “better LRU.” It is useful for a different access pattern.</em></blockquote><h3>20. SLRU — Segmented LRU</h3><p>Now let’s look at a more interesting strategy.</p><p><strong>SLRU = Segmented Least Recently Used</strong></p><p>Instead of putting every cache entry into one LRU list, SLRU divides the cache into multiple segments.</p><p>A common conceptual model is:</p><pre>┌───────────────────────┬─────────────────┐<br>│      Protected        │   Probationary  │<br>│       Segment         │     Segment     │<br>└───────────────────────┴─────────────────┘</pre><p>The idea is:</p><blockquote><em>New entries don’t immediately receive full protection.</em></blockquote><p>They first enter a probationary area.</p><p>If they prove that they are frequently reused, they can be promoted to the protected area.</p><h3>21. Real-Life Example of SLRU</h3><p>Imagine a library.</p><p>When a new book arrives, it goes to:</p><pre>New / Probationary Shelf</pre><p>If nobody reads it:</p><pre>Remove it</pre><p>But if many people start borrowing it:</p><pre>Move → Popular Shelf</pre><p>Now the popular book is protected from being removed too quickly.</p><p>This is similar to SLRU.</p><h3>22. SLRU Step-by-Step</h3><p>Suppose:</p><pre>Cache capacity = 6</pre><p>We divide it into:</p><pre>Protected = 4<br>Probationary = 2</pre><p>New entries:</p><pre>A<br>B<br>C<br>D</pre><p>start in the probationary area depending on the implementation and policy configuration.</p><p>Suppose C is repeatedly accessed.</p><p>C can be promoted:</p><pre>Probationary<br>      ↓<br>Protected</pre><p>Now the cache is effectively saying:</p><blockquote><em>“C has demonstrated that it is worth keeping.”</em></blockquote><p>This gives the cache more information than simple LRU.</p><h3>23. Why SLRU Can Be Useful</h3><p>Consider a cache receiving many one-time requests:</p><pre>A<br>B<br>C<br>D<br>E<br>F<br>G<br>H<br>I<br>J</pre><p>If everything is treated equally, frequently reused entries can get pushed out by temporary traffic.</p><p>SLRU attempts to separate:</p><pre>New / uncertain data</pre><p>from:</p><pre>Data that has demonstrated reuse</pre><p>This can improve cache behavior for workloads containing a mixture of one-time and repeatedly accessed data.</p><h3>24. Let’s Compare All Five</h3><p>Here is the simplest way to remember them:</p><p>PolicyMain QuestionEviction CandidateTTLHas its lifetime expired?Expired entryLRUWhen was it last used?Least recently usedLFUHow often was it used?Least frequently usedMRUWhat was used most recently?Most recently usedSLRUHas this entry demonstrated reuse?Less valuable segment entries</p><p>Think of them like different decision-making systems.</p><pre>TTL  → Time<br>LRU  → Recency<br>LFU  → Frequency<br>MRU  → Reverse Recency<br>SLRU → Recency + Segmentation</pre><h3>25. Real-World E-Commerce Example</h3><p>Let’s design a simple e-commerce cache.</p><p>Suppose an application has:</p><pre>Product Service</pre><p>and millions of products.</p><p>A request comes in:</p><pre>GET /products/101</pre><p>Without caching:</p><pre>Client<br>  ↓<br>Spring Boot Application<br>  ↓<br>Database<br>  ↓<br>Return Product</pre><p>Every request hits the database.</p><p>Now imagine 100,000 users requesting the same popular product.</p><p>That’s unnecessary repeated work.</p><p>With caching:</p><pre>Client<br>   ↓<br>Spring Boot<br>   ↓<br>Redis<br>   ↓<br>Product found?<br>   ↓<br>YES<br>   ↓<br>Return product</pre><p>The database doesn’t need to handle every repeated request.</p><h3>26. What If Redis Is Full?</h3><p>Suppose Redis has limited memory.</p><p>You have:</p><pre>Product A<br>Product B<br>Product C<br>Product D</pre><p>and another product needs to be cached.</p><p>Which product should leave?</p><p>That’s where your eviction policy becomes important.</p><p>If your workload is based heavily on recently viewed products:</p><pre>LRU</pre><p>might be suitable.</p><p>If certain products are consistently much more popular:</p><pre>LFU</pre><p>might be useful.</p><p>If product data should only remain cached for a limited period:</p><pre>TTL</pre><p>becomes important.</p><p>In real systems, these concepts can also work together rather than being mutually exclusive.</p><h3>27. TTL and LRU Are Not Always Alternatives</h3><p>This is an important concept.</p><p>Developers sometimes think:</p><pre>TTL OR LRU</pre><p>But in a real caching system, you can have both concepts.</p><p>For example:</p><pre>Product Cache</pre><pre>TTL = 10 minutes<br>Eviction policy = LRU</pre><p>Now two different rules exist:</p><h3>Rule 1 — TTL</h3><p>The entry should not remain valid beyond 10 minutes.</p><h3>Rule 2 — LRU</h3><p>If the cache needs space before that, less recently used entries can be selected for eviction.</p><p>So:</p><pre>TTL → How long can this data remain valid?</pre><pre>LRU → Which entry should be removed when space is needed?</pre><p>These solve related but different problems.</p><h3>28. Cache Expiration vs Cache Eviction</h3><p>Another important distinction.</p><h3>Expiration</h3><p>The entry becomes invalid because its lifetime has ended.</p><pre>TTL expires<br>      ↓<br>Entry is expired</pre><h3>Eviction</h3><p>The system removes an entry, often because memory or capacity constraints require space.</p><pre>Cache full<br>    ↓<br>Choose victim<br>    ↓<br>Evict entry</pre><p>So:</p><pre>Expiration → Time/validity problem</pre><pre>Eviction → Capacity/memory problem</pre><p>Some cache systems may remove expired entries lazily when they are accessed, or proactively through background cleanup. The exact behavior depends on the cache implementation.</p><h3>29. Cache Eviction and Cache Hit Rate</h3><p>One of the most important metrics when evaluating a cache is:</p><h3>Cache Hit Rate</h3><p>Suppose your application receives:</p><pre>1,000 requests</pre><p>and:</p><pre>800 → Cache Hit<br>200 → Cache Miss</pre><p>Then:</p><pre>Cache Hit Rate = 800 / 1000</pre><pre>               = 80%</pre><p>A higher hit rate is often desirable, but <strong>the highest hit rate is not automatically the only goal</strong>.</p><p>You also need to consider:</p><ul><li>Memory consumption</li><li>Data freshness</li><li>Latency</li><li>Cache maintenance cost</li><li>Database load</li><li>Consistency requirements</li></ul><h3>30. Why Eviction Policy Can Affect Database Load</h3><p>Imagine:</p><pre>100,000 requests</pre><p>If your cache hit rate is:</p><pre>95%</pre><p>then approximately:</p><pre>95,000 → handled by cache<br>5,000  → cache misses</pre><p>But if poor eviction behavior reduces the hit rate to:</p><pre>70%</pre><p>then approximately:</p><pre>70,000 → cache<br>30,000 → backend/database</pre><p>That is a huge difference.</p><p>More cache misses can mean:</p><pre>More DB queries<br>       ↓<br>More DB CPU<br>       ↓<br>Higher latency<br>       ↓<br>More connection usage<br>       ↓<br>Potential scalability problems</pre><p>That’s why cache eviction isn’t just a memory-management detail.</p><p>It can influence the behavior of the entire architecture.</p><h3>31. Cache Eviction in a Microservices Architecture</h3><p>Imagine an application with multiple microservices:</p><pre>┌───────────────┐<br>                 │   API Gateway │<br>                 └───────┬───────┘<br>                         ↓<br>              ┌─────────────────────┐<br>              │   Product Service   │<br>              └─────────┬───────────┘<br>                        ↓<br>                    ┌───────┐<br>                    │ Redis │<br>                    └───┬───┘<br>                        ↓<br>                   ┌─────────┐<br>                   │ MySQL   │<br>                   └─────────┘</pre><p>Suppose Product Service frequently requests:</p><pre>Product details</pre><p>Redis can absorb many repeated reads.</p><p>But when Redis reaches its configured memory limit, its eviction behavior matters.</p><p>If the policy doesn’t match the application’s access pattern, you can experience:</p><pre>More cache misses<br>        ↓<br>More database requests<br>        ↓<br>Higher latency<br>        ↓<br>Higher infrastructure load</pre><p>Therefore, cache design is part of system design.</p><h3>32. Cache Eviction Is Also About Data Characteristics</h3><p>Instead of asking:</p><blockquote><em>“Which eviction policy is the best?”</em></blockquote><p>A better question is:</p><blockquote><em>“What does my data access pattern look like?”</em></blockquote><p>Consider these examples.</p><h3>Scenario 1 — OTP</h3><pre>Data lifetime matters</pre><p>TTL is a natural fit.</p><h3>Scenario 2 — Recently viewed products</h3><pre>Recent access matters</pre><p>LRU can be useful.</p><h3>Scenario 3 — Popular products</h3><pre>Access frequency matters</pre><p>LFU may be useful.</p><h3>Scenario 4 — Sequential processing</h3><pre>Recently processed data may not be reused</pre><p>MRU can make sense in specific workloads.</p><h3>Scenario 5 — Mixed workload</h3><pre>Some entries are temporary.<br>Some entries become highly reused.</pre><p>A segmented approach such as SLRU can be useful.</p><h3>33. A Simple Mental Model</h3><p>If you’re preparing for system design or backend interviews, remember this:</p><pre>CACHE EVICTION<br>                       │<br>        ┌──────────────┼──────────────┐<br>        │              │              │<br>       TIME          RECENCY       FREQUENCY<br>        │              │              │<br>       TTL          LRU / MRU         LFU<br>                                     <br>                       │<br>                  SEGMENTATION<br>                       │<br>                      SLRU</pre><p>Or even simpler:</p><pre>TTL  → &quot;Is it too old?&quot;</pre><pre>LRU  → &quot;When was it last used?&quot;</pre><pre>LFU  → &quot;How often is it used?&quot;</pre><pre>MRU  → &quot;What was used most recently?&quot;</pre><pre>SLRU → &quot;Has it proven that it deserves protection?&quot;</pre><h3>34. How to Choose an Eviction Policy</h3><p>There is no universal answer.</p><p>Start by understanding your workload.</p><p>Ask:</p><h3>Question 1</h3><p>Does the data become invalid after a specific amount of time?</p><p>If yes:</p><pre>TTL</pre><h3>Question 2</h3><p>Are recently accessed items likely to be accessed again?</p><p>If yes:</p><pre>LRU</pre><h3>Question 3</h3><p>Are some items consistently much more popular than others?</p><p>If yes:</p><pre>LFU</pre><h3>Question 4</h3><p>Does the workload process data sequentially where recently used data is unlikely to be reused?</p><p>In certain cases:</p><pre>MRU</pre><h3>Question 5</h3><p>Do you have a mix of new/uncertain entries and entries that have demonstrated repeated reuse?</p><p>Consider:</p><pre>SLRU</pre><h3>35. What Happens If We Choose the Wrong Policy?</h3><p>Imagine your application has:</p><pre>Cache capacity = 1,000 items</pre><p>But your workload repeatedly accesses only:</p><pre>100 popular items</pre><p>If the cache keeps evicting those popular items because of a mismatch between the workload and policy, you’ll get:</p><pre>Cache Miss<br>   ↓<br>Database<br>   ↓<br>Cache<br>   ↓<br>Eviction<br>   ↓<br>Cache Miss<br>   ↓<br>Database</pre><p>The cache still exists, but it isn’t providing the benefit you expected.</p><p>This is why:</p><blockquote><strong><em>Adding a cache does not automatically make an application faster.</em></strong></blockquote><p>The cache must be designed around the application’s workload.</p><h3>36. Cache Eviction in Interview Questions</h3><p>Cache eviction is a common system-design topic.</p><p>If an interviewer asks:</p><blockquote><em>“Design a caching system.”</em></blockquote><p>Don’t immediately say:</p><blockquote><em>“I’ll use Redis.”</em></blockquote><p>Think about:</p><h3>1. What data are we caching?</h3><pre>User?<br>Product?<br>Session?<br>API response?</pre><h3>2. How long should it remain valid?</h3><pre>Seconds?<br>Minutes?<br>Hours?</pre><h3>3. How frequently is it accessed?</h3><pre>Rarely?<br>Frequently?<br>Extremely popular?</pre><h3>4. What happens when memory is full?</h3><pre>LRU?<br>LFU?<br>TTL?<br>Another policy?</pre><h3>5. What happens when the cache misses?</h3><pre>Database?<br>Another service?<br>External API?</pre><h3>6. How do we handle stale data?</h3><pre>TTL?<br>Explicit invalidation?<br>Event-based invalidation?<br>Write-through?<br>Write-behind?</pre><p>This demonstrates that you understand caching as an architectural concept rather than just knowing Redis commands.</p><h3>37. One More Important Concept: Cache Invalidation</h3><p>You may have heard the famous saying:</p><blockquote><em>“There are only two hard things in Computer Science: cache invalidation and naming things.”</em></blockquote><p>Eviction and invalidation are related but different.</p><h3>Eviction</h3><p>The cache removes data because of:</p><pre>Capacity<br>Policy<br>Expiration</pre><h3>Invalidation</h3><p>The application explicitly says:</p><blockquote><em>“This cached data is no longer valid.”</em></blockquote><p>For example:</p><pre>Product price = ₹999</pre><p>Cache:</p><pre>product:101 → ₹999</pre><p>Now the database changes:</p><pre>₹999 → ₹1,099</pre><p>If the old cache entry remains:</p><pre>Cache → ₹999<br>Database → ₹1,099</pre><p>You have stale data.</p><p>So the application may invalidate:</p><pre>DELETE product:101 FROM CACHE</pre><p>Then the next request can fetch the latest value.</p><p>This is a separate concern from choosing an eviction policy.</p><h3>38. The Bigger Picture</h3><p>A cache isn’t simply:</p><pre>Database → Redis</pre><p>A production caching strategy involves several decisions:</p><pre>CACHING<br>                    │<br>       ┌────────────┼─────────────┐<br>       │            │             │<br>   What to cache?  How long?   How to evict?<br>       │            │             │<br>    Product       TTL          LRU/LFU<br>    Session       Expiry       SLRU<br>    API response<br>       │<br>       └──────────────┐<br>                      ↓<br>                 How to invalidate?<br>                      │<br>               Events / TTL /<br>               Explicit deletion</pre><p>And then there are additional concerns such as:</p><ul><li>Cache stampede</li><li>Cache penetration</li><li>Cache breakdown</li><li>Hot keys</li><li>Distributed caching</li><li>Cache consistency</li><li>Serialization</li><li>Memory limits</li><li>Monitoring</li><li>Observability</li></ul><p>That is where caching becomes a real system-design topic.</p><h3>39. Final Cheat Sheet</h3><p>If you remember only one section from this article, remember this:</p><p>StrategyThink AboutExample<strong>TTL</strong>TimeOTP, session, temporary API response<strong>LRU</strong>Recent usageRecently viewed products<strong>LFU</strong>Usage frequencyHighly popular content<strong>MRU</strong>Most recent usageCertain sequential/streaming workloads<strong>SLRU</strong>Proven reuseMixed workloads with one-time + frequently reused data</p><p>The core idea is:</p><pre>Cache has limited memory<br>          ↓<br>New data needs space<br>          ↓<br>Choose something to remove<br>          ↓<br>Eviction Policy<br>          ↓<br>Different policies use different signals</pre><h3>Conclusion</h3><p>Caching is often introduced with a simple goal:</p><blockquote><strong><em>Make frequently needed data faster to access.</em></strong></blockquote><p>But storing data is only half of the caching problem.</p><p>The other half is deciding:</p><blockquote><strong><em>What should stay, and what should leave?</em></strong></blockquote><p>That’s exactly what cache eviction policies help us answer.</p><p><strong>TTL</strong> thinks about time.</p><p><strong>LRU</strong> thinks about recency.</p><p><strong>LFU</strong> thinks about frequency.</p><p><strong>MRU</strong> reverses the usual recency assumption for specific workloads.</p><p><strong>SLRU</strong> separates entries based on how much reuse they have demonstrated.</p><p>The important lesson isn’t to memorize which policy is “best.”</p><p>Instead, understand your application’s <strong>access pattern, data lifetime, memory constraints, and consistency requirements</strong>.</p><p>Because in system design:</p><blockquote><strong><em>The right cache eviction strategy is the one that matches the workload.</em></strong></blockquote><p>And once you understand that, caching stops being just a Redis configuration and becomes a powerful system-design tool. 🚀</p><p>Which cache eviction strategy have you used in your projects?</p><p><strong>LRU, LFU, TTL, SLRU — or something else?</strong></p><p>Have you ever faced a real production issue caused by cache eviction or stale cache data?</p><p>Share your experience in the comments. 👇</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=065807d92f27" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Think Every Telegram Chat Is End-to-End Encrypted? Here’s the Truth.]]></title>
            <link>https://medium.com/@omkarj.9900/think-every-telegram-chat-is-end-to-end-encrypted-heres-the-truth-ae3f12c60aaf?source=rss-72ffb130a6a3------2</link>
            <guid isPermaLink="false">https://medium.com/p/ae3f12c60aaf</guid>
            <category><![CDATA[social-media]]></category>
            <category><![CDATA[software-engineering]]></category>
            <category><![CDATA[software-development]]></category>
            <category><![CDATA[telegram]]></category>
            <category><![CDATA[medium]]></category>
            <dc:creator><![CDATA[Omkar Jadhav]]></dc:creator>
            <pubDate>Wed, 24 Jun 2026 05:49:58 GMT</pubDate>
            <atom:updated>2026-06-24T05:49:58.285Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*G0iJRZq9HNGKJ42MY5pR8w.jpeg" /></figure><h3>A Deep Dive into Telegram’s Security Architecture, Secret Chats, and What Most Users Get Wrong</h3><p>Telegram has built a reputation as one of the world’s most secure messaging platforms.</p><p>Ask a random user why they use Telegram and you’ll likely hear answers such as:</p><ul><li>“It’s encrypted.”</li><li>“It’s more secure than other messaging apps.”</li><li>“My chats are private.”</li><li>“Nobody can read my messages.”</li></ul><p>But here’s the reality:</p><p><strong>Most Telegram conversations are not end-to-end encrypted.</strong></p><p>That statement surprises many people because Telegram is often discussed alongside privacy-focused messaging platforms such as Signal and WhatsApp.</p><p>The truth is more nuanced.</p><p>Telegram uses a unique security model that prioritizes cloud synchronization, speed, and accessibility across multiple devices. While this model provides significant benefits, it is fundamentally different from the end-to-end encryption approach used by many other messaging applications.</p><p>Let’s break down how Telegram actually works, why the confusion exists, and when Telegram is genuinely secure.</p><h3>First, What Does “Secure” Actually Mean?</h3><p>When cybersecurity professionals talk about a “secure” messaging application, they usually refer to <strong>End-to-End Encryption (E2EE).</strong></p><p>In an E2EE system:</p><ol><li>A message is encrypted on the sender’s device.</li><li>The encrypted message travels across the internet.</li><li>Only the intended recipient possesses the key required to decrypt it.</li><li>Even the service provider cannot read the contents.</li></ol><p>Think of it like sending a letter inside a locked box where only the recipient has the key.</p><p>The delivery company can transport the box.</p><p>But it cannot open it.</p><p>This is the security model used by apps such as Signal and the default mode of WhatsApp.</p><h3>The Common Misconception About Telegram</h3><p>Many users assume Telegram works exactly the same way.</p><p>It doesn’t.</p><p>Telegram uses two different types of chats:</p><h3>1. Cloud Chats (Default)</h3><p>These include:</p><ul><li>Normal one-to-one chats</li><li>Group chats</li><li>Channels</li></ul><p>These chats are encrypted between your device and Telegram’s servers, but they are <strong>not end-to-end encrypted.</strong> Telegram refers to this as server-client encryption.</p><h3>2. Secret Chats</h3><p>These chats are fully end-to-end encrypted.</p><p>Only the sender and recipient can decrypt the messages.</p><p>Telegram’s servers cannot access the contents.</p><p>The distinction is important because most Telegram users never use Secret Chats.</p><p>They use Cloud Chats.</p><h3>How Telegram’s Default Encryption Works</h3><p>Telegram’s standard chats use a cloud-based architecture.</p><p>When you send a message:</p><ol><li>Your device encrypts the message.</li><li>The message travels securely to Telegram’s infrastructure.</li><li>Telegram stores the encrypted data in its cloud.</li><li>The recipient retrieves the message from Telegram’s servers.</li></ol><p>Telegram states that message data and encryption components are distributed across different jurisdictions and infrastructure locations to increase security.</p><p>This design provides several advantages:</p><p>✅ Access chats from multiple devices</p><p>✅ Instant synchronization</p><p>✅ Cloud backups</p><p>✅ Fast message retrieval</p><p>✅ Device-independent conversation history</p><p>This is one reason Telegram feels seamless whether you’re using:</p><ul><li>Android</li><li>iPhone</li><li>Windows</li><li>macOS</li><li>Linux</li><li>Web Browser</li></ul><p>Your entire message history follows you everywhere.</p><p>But convenience always comes with trade-offs.</p><h3>The Security Trade-Off</h3><p>Because Telegram’s cloud chats are stored on Telegram’s infrastructure, the system must manage the encryption process required to synchronize messages across devices. This is different from pure end-to-end encrypted systems where only the communicating devices possess message decryption capabilities.</p><p>For everyday conversations, this may not be a concern.</p><p>For highly sensitive conversations, however, security professionals generally prefer end-to-end encrypted systems where service providers cannot access message contents.</p><p>This doesn’t mean Telegram is insecure.</p><p>It simply means Telegram prioritizes a different balance between:</p><ul><li>Privacy</li><li>Convenience</li><li>Multi-device functionality</li><li>Cloud accessibility</li></ul><h3>Enter Secret Chats: Telegram’s True End-to-End Encryption</h3><p>If you want maximum privacy inside Telegram, you must manually create a Secret Chat.</p><p>Secret Chats provide:</p><h3>End-to-End Encryption</h3><p>Messages are encrypted on your device and decrypted only on the recipient’s device. Telegram cannot read them.</p><h3>Self-Destruct Timers</h3><p>Messages can automatically disappear after a specified period.</p><h3>No Forwarding</h3><p>Secret Chat messages cannot be forwarded like normal messages.</p><h3>Device-Specific Storage</h3><p>Messages remain only on the participating devices and are not stored in Telegram’s cloud.</p><h3>The Limitations of Secret Chats</h3><p>Secret Chats sound ideal.</p><p>So why doesn’t everyone use them?</p><p>Because they come with significant limitations.</p><h3>No Group Chats</h3><p>Telegram does not support end-to-end encrypted groups.</p><p>All group chats operate using Telegram’s cloud architecture.</p><h3>No Multi-Device Sync</h3><p>Start a Secret Chat on one phone and it stays there.</p><p>Open Telegram on another device and the conversation won’t appear.</p><h3>No Cloud Backup</h3><p>If the device is lost, reset, or deleted, the Secret Chat disappears permanently.</p><h3>Must Be Enabled Manually</h3><p>Secret Chats are not activated automatically.</p><p>Users must intentionally start them.</p><p>This is one reason many users unknowingly spend years using Telegram without ever utilizing its strongest privacy feature.</p><h3>Why Doesn’t Telegram Use E2EE Everywhere?</h3><p>This is one of the most debated questions in cybersecurity.</p><p>Telegram argues that cloud chats provide a superior user experience:</p><ul><li>Better synchronization</li><li>Faster access</li><li>Multi-device support</li><li>Easier recovery of chat history</li></ul><p>The company believes fully end-to-end encrypted multi-device messaging introduces usability challenges and feature limitations.</p><p>Privacy advocates often disagree and argue that end-to-end encryption should be enabled by default.</p><p>This debate has continued for years and remains one of the biggest discussions surrounding Telegram’s security model.</p><h3>Is Telegram Actually Safe?</h3><p>The answer depends on your threat model.</p><h3>For Average Users</h3><p>Telegram is generally secure enough for:</p><ul><li>Family chats</li><li>Friends</li><li>Communities</li><li>Business discussions</li><li>Content sharing</li></ul><p>Its encryption and infrastructure provide substantial protection against common cyber threats.</p><h3>For Journalists, Activists, Researchers, and High-Risk Users</h3><p>You should understand exactly which type of Telegram chat you’re using.</p><p>If the conversation involves:</p><ul><li>Sensitive business information</li><li>Whistleblowing</li><li>Political activism</li><li>Investigative journalism</li><li>Confidential client data</li></ul><p>Secret Chats or dedicated end-to-end encrypted platforms may be more appropriate.</p><h3>The Bigger Lesson: Encryption Is Not Binary</h3><p>One of the biggest mistakes people make is thinking:</p><p>“Encrypted = Completely Private.”</p><p>Reality is more complicated.</p><p>Security exists on a spectrum.</p><p>Questions that matter include:</p><ul><li>Who controls the encryption keys?</li><li>Where are messages stored?</li><li>Can messages be recovered?</li><li>Are conversations synchronized across devices?</li><li>Can the service provider access message contents?</li></ul><p>Understanding these differences is far more important than simply knowing whether an app uses encryption.</p><h3>Final Thoughts</h3><p>Telegram is not insecure.</p><p>But it is also not the same as fully end-to-end encrypted messaging platforms by default.</p><p>The key takeaway is simple:</p><p><strong>Most Telegram chats are protected by cloud-based encryption, while only Secret Chats provide true end-to-end encryption.</strong></p><p>Understanding that distinction helps you make better decisions about what information you share, where you share it, and how much privacy you actually have.</p><p>In cybersecurity, assumptions are often the biggest vulnerability.</p><p>And when it comes to Telegram, the assumption that “all chats are end-to-end encrypted” is one of the most common misconceptions on the internet.</p><p>What surprised you most about Telegram’s security model? Share your thoughts in the comments.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=ae3f12c60aaf" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Optimistic Locking vs Pessimistic Locking: The Silent Battle Behind Every Scalable System]]></title>
            <link>https://medium.com/@omkarj.9900/optimistic-locking-vs-pessimistic-locking-the-silent-battle-behind-every-scalable-system-3b27996445f9?source=rss-72ffb130a6a3------2</link>
            <guid isPermaLink="false">https://medium.com/p/3b27996445f9</guid>
            <category><![CDATA[data-science]]></category>
            <category><![CDATA[system-design-concepts]]></category>
            <category><![CDATA[artificial-intelligence]]></category>
            <category><![CDATA[java]]></category>
            <category><![CDATA[medium]]></category>
            <dc:creator><![CDATA[Omkar Jadhav]]></dc:creator>
            <pubDate>Thu, 28 May 2026 03:49:26 GMT</pubDate>
            <atom:updated>2026-05-28T03:49:26.413Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/800/1*Htept_lQlqLcB3a3ahk80w.gif" /></figure><p>Most developers spend years learning APIs, frameworks, cloud deployment, and databases.</p><p>But one of the most important engineering problems often stays invisible until production traffic exposes it:</p><blockquote><strong><em>What happens when two users try to update the same data at the exact same time?</em></strong></blockquote><p>At small scale, you rarely notice it.</p><p>At large scale, it becomes one of the biggest causes of:</p><ul><li>data corruption,</li><li>inconsistent systems,</li><li>lost updates,</li><li>performance bottlenecks,</li><li>and production incidents.</li></ul><p>This is where locking strategies become critical.</p><p>Behind every banking transaction, ticket booking system, payment gateway, inventory platform, or collaborative app lies an important architectural decision:</p><h3>Should the system prevent conflicts before they happen?</h3><p>OR</p><h3>Should the system allow conflicts and detect them later?</h3><p>This is the core difference between:</p><ul><li><strong>Optimistic Locking</strong></li><li><strong>Pessimistic Locking</strong></li></ul><p>Understanding these two concepts can completely change how you design scalable systems.</p><h3>The Real Problem: Concurrent Updates</h3><p>Imagine this scenario.</p><p>Two users — Sarah and Alex — open the same bank account record.</p><p>At that moment:</p><ul><li>Account Balance = $40</li><li>Version = 1</li></ul><p>Both users see the same data.</p><p>Now:</p><ul><li>Sarah updates the balance</li><li>Alex updates the balance too</li></ul><p>Without proper concurrency handling, one update may silently overwrite the other.</p><p>This is called a:</p><h3>Lost Update Problem</h3><p>And in real-world systems, this can become extremely dangerous.</p><p>Imagine:</p><ul><li>double-selling inventory,</li><li>incorrect account balances,</li><li>duplicate payments,</li><li>overwritten medical records,</li><li>or inconsistent analytics data.</li></ul><p>The database must decide how to coordinate these updates safely.</p><p>That’s where locking strategies come in.</p><h3>Optimistic Locking</h3><h3>“Trust first. Verify later.”</h3><p>Optimistic locking assumes:</p><blockquote><em>Conflicts are rare.</em></blockquote><p>Instead of locking data immediately, the system allows multiple users to read and attempt updates simultaneously.</p><p>The conflict is checked only during the update operation.</p><h3>How Optimistic Locking Works</h3><p>Each database row contains a:</p><ul><li>version number,</li><li>timestamp,</li><li>or update counter.</li></ul><p>Example:</p><p>IDBalanceVersion1401</p><h3>Step 1</h3><p>Sarah reads:</p><ul><li>Balance = 40</li><li>Version = 1</li></ul><h3>Step 2</h3><p>Alex also reads:</p><ul><li>Balance = 40</li><li>Version = 1</li></ul><p>No locks are placed.</p><p>Both continue working independently.</p><h3>Step 3</h3><p>Alex updates balance to 20.</p><p>Database query:</p><pre>UPDATE accounts<br>SET balance = 20,<br>    version = 2<br>WHERE id = 1<br>AND version = 1;</pre><p>This succeeds because the current version is still 1.</p><p>Now database state becomes:</p><p>IDBalanceVersion1202</p><h3>Step 4</h3><p>Sarah now tries to update balance to 30 using version 1.</p><pre>UPDATE accounts<br>SET balance = 30,<br>    version = 2<br>WHERE id = 1<br>AND version = 1;</pre><p>But the current version is already 2.</p><p>So:</p><ul><li>affected rows = 0</li><li>update rejected</li><li>version mismatch detected</li></ul><p>Sarah’s transaction fails.</p><h3>Why It’s Called “Optimistic”</h3><p>Because the system is optimistic enough to believe:</p><blockquote><em>“Conflicts probably won’t happen.”</em></blockquote><p>And in many applications, that assumption is correct.</p><p>Most systems are:</p><ul><li>read-heavy,</li><li>write-light,</li><li>and have low collision probability.</li></ul><h3>Advantages of Optimistic Locking</h3><h3>1. Better Performance</h3><p>No database locks means:</p><ul><li>higher throughput,</li><li>better concurrency,</li><li>improved scalability.</li></ul><h3>2. No Long Waiting</h3><p>Transactions don’t block each other.</p><p>Users can continue working simultaneously.</p><h3>3. Excellent for Distributed Systems</h3><p>Modern architectures like:</p><ul><li>microservices,</li><li>REST APIs,</li><li>cloud-native applications,</li><li>and NoSQL systems</li></ul><p>often prefer optimistic locking because distributed locks are expensive and difficult to manage.</p><h3>Disadvantages of Optimistic Locking</h3><h3>1. Update Failures</h3><p>Conflicts can happen.</p><p>One transaction may fail and require retry logic.</p><h3>2. Complex Conflict Resolution</h3><p>What should happen when two users edit the same profile simultaneously?</p><ul><li>overwrite?</li><li>merge changes?</li><li>ask user to retry?</li></ul><p>Business rules become important.</p><h3>3. Poor Choice for High-Conflict Systems</h3><p>If many users constantly modify the same rows:</p><ul><li>retries increase,</li><li>failures increase,</li><li>performance degrades.</li></ul><h3>Real-World Use Cases of Optimistic Locking</h3><p>Optimistic locking is commonly used in:</p><h3>Social Media Platforms</h3><p>Millions of reads, fewer writes.</p><h3>E-commerce Product Browsing</h3><p>Users mostly read product data.</p><h3>REST APIs</h3><p>Version-based concurrency control is extremely common.</p><h3>Mobile Applications</h3><p>Offline sync systems often use optimistic concurrency.</p><h3>Microservices</h3><p>Avoiding distributed locks improves scalability.</p><h3>Pessimistic Locking</h3><h3>“Prevent conflicts before they happen.”</h3><p>Pessimistic locking assumes:</p><blockquote><em>Conflicts are likely and dangerous.</em></blockquote><p>Instead of allowing concurrent modifications, the first transaction locks the data immediately.</p><p>Other transactions must wait.</p><h3>How Pessimistic Locking Works</h3><h3>Step 1</h3><p>Sarah requests to edit Account #1.</p><p>Database places a lock:</p><pre>SELECT * FROM accounts<br>WHERE id = 1<br>FOR UPDATE;</pre><p>Now the row is locked.</p><h3>Step 2</h3><p>Alex tries to update the same row.</p><p>Database response:</p><blockquote><em>Wait until lock is released.</em></blockquote><p>Alex’s transaction is blocked.</p><h3>Step 3</h3><p>Sarah updates balance to 20.</p><h3>Step 4</h3><p>Sarah commits transaction.</p><p>Lock released.</p><p>Now Alex can continue.</p><h3>Why It’s Called “Pessimistic”</h3><p>Because the system assumes:</p><blockquote><em>“Conflicts are inevitable.”</em></blockquote><p>So it prevents them before they occur.</p><h3>Advantages of Pessimistic Locking</h3><h3>1. Strong Data Consistency</h3><p>Only one transaction modifies data at a time.</p><p>Very safe for critical operations.</p><h3>2. No Version Conflict Logic</h3><p>No retries.<br>No version mismatch handling.</p><h3>3. Predictable for High-Conflict Workloads</h3><p>Works well when many users update the same records frequently.</p><h3>Disadvantages of Pessimistic Locking</h3><h3>1. Reduced Performance</h3><p>Transactions block each other.</p><p>Concurrency decreases.</p><h3>2. Risk of Deadlocks</h3><p>Two transactions waiting for each other can freeze the system.</p><p>Example:</p><ul><li>Transaction A locks Row 1</li><li>Transaction B locks Row 2</li><li>Both try to access the other row</li></ul><p>Now neither can continue.</p><h3>3. Poor Scalability</h3><p>Large-scale distributed systems struggle with heavy locking.</p><h3>Real-World Use Cases of Pessimistic Locking</h3><h3>Banking Systems</h3><p>You cannot risk balance inconsistencies.</p><h3>Payment Gateways</h3><p>Financial correctness matters more than speed.</p><h3>Inventory Management</h3><p>Prevents overselling limited stock.</p><h3>Airline or Movie Ticket Booking</h3><p>Two users cannot purchase the same seat simultaneously.</p><h3>Performance vs Safety</h3><p>This is the real tradeoff.</p><p>Optimistic LockingPessimistic LockingHigher performanceHigher safetyBetter scalabilityStrong consistencyConflicts detected laterConflicts prevented earlyNo blockingBlocking occursRetry logic neededWaiting logic needed</p><h3>The Most Important Engineering Lesson</h3><p>Junior developers often think:</p><blockquote><em>“The database will handle everything automatically.”</em></blockquote><p>Senior engineers know:</p><blockquote><em>Concurrency control is architecture.</em></blockquote><p>The choice between optimistic and pessimistic locking affects:</p><ul><li>scalability,</li><li>latency,</li><li>throughput,</li><li>user experience,</li><li>infrastructure cost,</li><li>and business reliability.</li></ul><p>This decision influences how your entire system behaves under pressure.</p><h3>Which One Should You Choose?</h3><p>There is no universally “best” approach.</p><p>The correct answer depends on:</p><ul><li>traffic patterns,</li><li>business requirements,</li><li>failure tolerance,</li><li>and concurrency frequency.</li></ul><h3>Use Optimistic Locking When:</h3><p>✅ Reads are much higher than writes<br>✅ Conflicts are rare<br>✅ Scalability matters most<br>✅ Retry logic is acceptable<br>✅ Distributed architecture is used</p><h3>Use Pessimistic Locking When:</h3><p>✅ Data integrity is critical<br>✅ Conflicts are frequent<br>✅ Lost updates are unacceptable<br>✅ Business operations are high risk<br>✅ Consistency matters more than speed</p><h3>The Hidden Reality of Modern Systems</h3><p>Interestingly, most large-scale systems combine both approaches.</p><p>For example:</p><ul><li>optimistic locking for profile updates,</li><li>pessimistic locking for payment processing.</li></ul><p>Modern engineering is rarely about choosing one technology forever.</p><p>It’s about applying the right strategy to the right problem.</p><h3>Final Thoughts</h3><p>Concurrency problems are among the hardest bugs in software engineering.</p><p>They:</p><ul><li>appear randomly,</li><li>are difficult to reproduce,</li><li>and often emerge only under production load.</li></ul><p>But understanding locking strategies gives you a huge architectural advantage.</p><p>Because scalable systems are not built only with:</p><ul><li>better frameworks,</li><li>faster databases,</li><li>or bigger servers.</li></ul><p>They are built with correct concurrency control.</p><p>And sometimes, the difference between a reliable system and a catastrophic production bug is just one lock.</p><h3>What would you choose for:</h3><ul><li>a banking application?</li><li>an e-commerce cart?</li><li>a real-time collaborative editor?</li><li>or a social media platform?</li></ul><p>The answer says a lot about how you think as an engineer.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=3b27996445f9" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[ Inside Apache Kafka: The Invisible Engine Running the Internet in Real-Time]]></title>
            <link>https://medium.com/@omkarj.9900/inside-apache-kafka-the-invisible-engine-running-the-internet-in-real-time-e930d95f57c8?source=rss-72ffb130a6a3------2</link>
            <guid isPermaLink="false">https://medium.com/p/e930d95f57c8</guid>
            <category><![CDATA[java-development]]></category>
            <category><![CDATA[software-engineering]]></category>
            <category><![CDATA[software-development]]></category>
            <category><![CDATA[kafka]]></category>
            <category><![CDATA[system-design-concepts]]></category>
            <dc:creator><![CDATA[Omkar Jadhav]]></dc:creator>
            <pubDate>Mon, 20 Apr 2026 06:39:57 GMT</pubDate>
            <atom:updated>2026-04-20T06:39:57.384Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/800/1*C-EsYeW6qLNFOnydhK3C-g.gif" /></figure><p>Imagine this.</p><p>You open an app, click a button, make a payment, or scroll a feed — and within milliseconds, everything updates. No lag. No data loss. No crash.</p><p>But behind the scenes, millions of such events are happening <em>simultaneously</em>.</p><p>So how do systems handle this massive, continuous stream of data?</p><p>The answer is <strong>Apache Kafka</strong> — the backbone of modern real-time data systems.</p><p>In this deep dive, we’ll break down Kafka <strong>step-by-step</strong>, exactly like the architecture shown in the diagram — from producers to consumers — and understand <em>why it’s so powerful</em>.</p><h3>🧠 What is Apache Kafka (In Simple Terms)?</h3><p>Kafka is not just a messaging queue.</p><p>It’s a <strong>distributed event streaming platform</strong> designed to:</p><ul><li>Handle massive data streams</li><li>Process data in real-time</li><li>Ensure fault tolerance</li><li>Scale horizontally without limits</li></ul><p>Think of Kafka as a <strong>high-speed data highway</strong>, where:</p><ul><li>Producers send data</li><li>Kafka stores and organizes it</li><li>Consumers read and process it</li></ul><h3>⚡ Step 1: Producer — The Data Creator</h3><p>Everything starts with the <strong>Producer</strong>.</p><p>A producer is any application or service that generates data:</p><ul><li>Web apps (user clicks)</li><li>Payment systems (transactions)</li><li>IoT devices (sensor data)</li><li>Logs from servers</li></ul><p>Instead of directly sending data to databases or services, producers send it to Kafka.</p><p>👉 Why?<br>Because Kafka acts as a <strong>buffer + pipeline</strong>, making systems more scalable and decoupled.</p><h3>🔄 Step 2: Serializer — Data Translator</h3><p>Before data enters Kafka, it must be converted into a format Kafka understands — <strong>bytes</strong>.</p><p>This is done by the <strong>Serializer</strong>.</p><p>Common formats include:</p><ul><li>JSON</li><li>Avro</li><li>Protobuf</li></ul><p>👉 Why this matters:<br>Serialization ensures data can be efficiently transmitted and understood across distributed systems.</p><h3>🎯 Step 3: Partitioner — Smart Routing</h3><p>Kafka doesn’t store all data in one place. Instead, it splits data into <strong>Partitions</strong>.</p><p>The <strong>Partitioner</strong> decides:<br>👉 Which partition a message should go to</p><p>This decision can be based on:</p><ul><li>Message key</li><li>Round-robin</li><li>Custom logic</li></ul><h3>💡 Why partitions are important:</h3><ul><li>Enable <strong>parallel processing</strong></li><li>Maintain <strong>order within a partition</strong></li><li>Improve <strong>scalability</strong></li></ul><p>Think of partitions as <strong>lanes on a highway</strong> — more lanes = more traffic handled.</p><h3>🏗️ Step 4: Kafka Cluster — The Core Engine</h3><p>This is where the magic happens.</p><p>A <strong>Kafka Cluster</strong> consists of multiple <strong>Brokers</strong> (servers).</p><h3>🔹 Brokers — Storage Units</h3><p>Each broker stores data in partitions.</p><p>For example:</p><ul><li>Topic → Orders</li><li>Partitions → P0, P1, P2</li></ul><p>Each partition stores messages in <strong>ordered sequence</strong> (like a log).</p><h3>🔁 Replication — Fault Tolerance</h3><p>Kafka doesn’t store data in just one place.</p><p>Each partition is <strong>replicated across brokers</strong>.</p><p>👉 Example:</p><ul><li>Broker 1 → Leader</li><li>Broker 2 → Follower (Replica)</li></ul><p>If the leader fails, a follower becomes the new leader.</p><h3>💡 Why this matters:</h3><ul><li>No data loss</li><li>High availability</li><li>System resilience</li></ul><p>This is one of the reasons Kafka is trusted by companies handling <strong>critical data systems</strong>.</p><h3>📌 Leader &amp; Followers</h3><p>Each partition has:</p><ul><li><strong>Leader</strong> → Handles reads &amp; writes</li><li><strong>Followers</strong> → Sync data from leader</li></ul><p>Consumers always read from the <strong>leader</strong>, ensuring consistency.</p><h3>📥 Step 5: Consumers — Data Readers</h3><p>Now comes the other side of the pipeline — <strong>Consumers</strong>.</p><p>Consumers read data from Kafka topics and process it.</p><p>Examples:</p><ul><li>Analytics systems</li><li>Notification services</li><li>Machine learning pipelines</li></ul><h3>👥 Consumer Groups — Parallel Power</h3><p>Instead of a single consumer, Kafka uses <strong>Consumer Groups</strong>.</p><p>👉 Key idea:</p><ul><li>Each partition is consumed by <strong>only one consumer in a group</strong></li><li>Different groups can read the same data independently</li></ul><h3>💡 Benefits:</h3><ul><li>Parallel processing</li><li>Load distribution</li><li>No duplicate processing</li></ul><h3>⚡ End-to-End Flow (Putting It All Together)</h3><p>Let’s summarize the complete flow:</p><ol><li>Producer sends data</li><li>Serializer converts it into bytes</li><li>Partitioner decides destination partition</li><li>Kafka stores data in partitions across brokers</li><li>Data is replicated for safety</li><li>Consumers (in groups) read and process data</li></ol><p>👉 This entire process happens in <strong>milliseconds</strong></p><h3>🚀 Why Kafka is So Powerful</h3><p>Kafka isn’t popular by accident. It solves real-world problems at scale.</p><h3>🔥 Key Advantages:</h3><p>✔️ <strong>High Throughput</strong><br>Handles millions of messages per second</p><p>✔️ <strong>Scalability</strong><br>Add more brokers → increase capacity</p><p>✔️ <strong>Fault Tolerance</strong><br>Replication ensures zero data loss</p><p>✔️ <strong>Decoupling Systems</strong><br>Producers and consumers don’t depend on each other</p><p>✔️ <strong>Real-Time Processing</strong><br>Perfect for streaming applications</p><h3>🧠 Real-World Use Cases</h3><p>Kafka is used everywhere:</p><ul><li>🎬 Netflix → Real-time recommendations</li><li>🚗 Uber → Ride tracking &amp; matching</li><li>💳 Banking → Transaction processing</li><li>📊 Analytics → Live dashboards</li></ul><h3>⚠️ Common Misconception</h3><p>👉 “Kafka is just a message queue”</p><p>❌ Wrong</p><p>Kafka is much more:</p><ul><li>Event streaming platform</li><li>Distributed log system</li><li>Real-time processing backbone</li></ul><h3>🎯 Final Thoughts</h3><p>Kafka transforms chaotic streams of data into <strong>structured, scalable, and reliable pipelines</strong>.</p><p>It’s not just a tool — it’s a <strong>foundation for modern distributed systems</strong>.</p><p>If you’re a developer, understanding Kafka is a <strong>game-changer</strong> for:</p><ul><li>System design interviews</li><li>Backend architecture</li><li>Building scalable applications</li></ul><h3>🔥 One-Line Summary</h3><p>👉 <em>Kafka is the invisible engine that powers real-time data flow across the internet.</em></p><p>If you found this useful, share it with someone learning <strong>System Design</strong> 🚀</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=e930d95f57c8" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[ Login Once, Access Everything — The Hidden Magic Behind SSO (Step-by-Step Deep Dive)]]></title>
            <link>https://medium.com/@omkarj.9900/login-once-access-everything-the-hidden-magic-behind-sso-step-by-step-deep-dive-6fe9a4d05ac1?source=rss-72ffb130a6a3------2</link>
            <guid isPermaLink="false">https://medium.com/p/6fe9a4d05ac1</guid>
            <category><![CDATA[youtube]]></category>
            <category><![CDATA[social-media]]></category>
            <category><![CDATA[java-developer]]></category>
            <category><![CDATA[ai]]></category>
            <category><![CDATA[system-design-concepts]]></category>
            <dc:creator><![CDATA[Omkar Jadhav]]></dc:creator>
            <pubDate>Fri, 17 Apr 2026 03:24:29 GMT</pubDate>
            <atom:updated>2026-04-17T03:24:29.403Z</atom:updated>
            <content:encoded><![CDATA[<p>Imagine starting your workday and logging into your email… then your chat app… then your dashboard… then your CRM… then your analytics tool.</p><p>Sounds exhausting, right?</p><p>Now imagine logging in just <strong>once</strong> — and magically accessing everything without entering your password again.</p><p>That’s not magic.<br>That’s <strong>Single Sign-On (SSO)</strong> 🚀</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/800/1*kZcEvplVgadTrS36VizH8Q.gif" /></figure><h3>🤔 What is SSO (In Simple Words)?</h3><p><strong>Single Sign-On (SSO)</strong> is an authentication mechanism that allows users to log in once and gain access to multiple applications without logging in repeatedly.</p><p>Instead of every app asking for your credentials, <strong>one trusted system handles authentication for all of them</strong>.</p><p>Think of it like:</p><blockquote><em>🎟️ </em>One ticket → access to multiple rides in an amusement park</blockquote><h3>🧠 Core Components You Must Understand</h3><p>Before we dive into the flow, you need to understand three key players:</p><h3>1. 👤 User</h3><p>You — the person trying to access apps.</p><h3>2. 🖥️ Service Provider (SP)</h3><p>Applications like:</p><ul><li>Email systems</li><li>Chat tools</li><li>Dashboards</li></ul><p>These apps <strong>don’t authenticate you directly</strong> — they rely on another system.</p><h3>3. 🔐 Identity Provider (IdP)</h3><p>The central authority that:</p><ul><li>Verifies your identity</li><li>Issues authentication tokens</li><li>Maintains your login session</li></ul><h3>🔄 SSO Flow — Step-by-Step Breakdown</h3><p>Let’s walk through the exact flow shown in your diagram.</p><h3>🟢 First Login (Initial Authentication Flow)</h3><p>This is the <strong>most important part</strong>, because everything starts here.</p><h3>1️⃣ You Open an Application</h3><p>You visit an app (for example, your email platform).</p><p>👉 The app checks:<br>“Is this user already logged in?”</p><p>❌ No session found.</p><h3>2️⃣ Redirect to Identity Provider</h3><p>Since the app doesn’t handle authentication, it redirects your browser to the Identity Provider.</p><p>👉 This is called an <strong>Authentication Request</strong></p><h3>3️⃣ Browser Forwards Request</h3><p>Your browser carries that request to the Identity Provider.</p><h3>4️⃣ Login Page Appears</h3><p>The Identity Provider now shows you a login screen.</p><p>You enter:</p><ul><li>Username</li><li>Password</li><li>(Maybe MFA like OTP)</li></ul><h3>5️⃣ Identity Provider Authenticates You</h3><p>Now the important part happens:</p><p>✔ Credentials are verified<br>✔ A <strong>session is created</strong><br>✔ A <strong>secure token</strong> is generated</p><p>This token is proof that:</p><blockquote><em>“Yes, this user is authenticated.”</em></blockquote><h3>6️⃣ Token Sent Back to Application</h3><p>The Identity Provider sends the token back to the application via your browser.</p><h3>7️⃣ Application Validates Token</h3><p>The app checks:</p><ul><li>Is the token valid?</li><li>Was it issued by a trusted IdP?</li><li>Has it expired?</li></ul><p>✔ If valid → Access granted</p><p>🎉 You are now logged in!</p><h3>🔁 Accessing Another App (SSO in Action)</h3><p>Now comes the real power of SSO.</p><h3>8️⃣ You Open Another Application</h3><p>Let’s say you open a different app (like a chat platform).</p><h3>9️⃣ App Redirects to Identity Provider Again</h3><p>Same process starts — but something is different now.</p><h3>🔟 Browser Reaches Identity Provider</h3><p>Your browser sends another authentication request.</p><h3>1️⃣1️⃣ Identity Provider Detects Active Session</h3><p>Here’s the magic ✨</p><p>The Identity Provider checks:<br>👉 “Is this user already logged in?”</p><p>✔ YES — session exists</p><p>So it <strong>skips the login screen completely</strong> 🔥</p><h3>1️⃣2️⃣ New Token is Generated</h3><p>Instead of asking for credentials again, the IdP:</p><ul><li>Generates a fresh token</li><li>Tailored for the new application</li></ul><h3>1️⃣3️⃣ Token Sent to Second App</h3><p>Browser forwards this token to the new application.</p><h3>1️⃣4️⃣ Application Validates Token</h3><p>The second app verifies the token just like before.</p><h3>1️⃣5️⃣ Access Granted Instantly</h3><p>🎉 No login required.<br>🎉 No password entered again.<br>🎉 Seamless experience.</p><h3>🔐 What is This “Token” Actually?</h3><p>A <strong>token</strong> is a secure piece of data that contains:</p><ul><li>User identity</li><li>Authentication status</li><li>Expiry time</li><li>Issuer details</li></ul><p>Common token formats:</p><ul><li>JWT (JSON Web Token)</li><li>SAML Assertions</li></ul><p>Think of it like:</p><blockquote><em>🪪 A digital ID card issued after login</em></blockquote><h3>🔍 Behind the Scenes — What Makes SSO Secure?</h3><p>SSO is not just convenient — it’s also highly secure when implemented properly.</p><h3>🛡️ 1. Centralized Authentication</h3><p>Instead of multiple login systems:</p><ul><li>Only one system handles credentials</li><li>Reduces attack surface</li></ul><h3>🔑 2. Strong Token Validation</h3><p>Apps never trust blindly. They always verify:</p><ul><li>Signature</li><li>Expiry</li><li>Issuer</li></ul><h3>🔄 3. Short-Lived Tokens</h3><p>Tokens expire quickly, reducing misuse risk.</p><h3>🔐 4. Multi-Factor Authentication (MFA)</h3><p>SSO systems often enforce:</p><ul><li>OTP</li><li>Biometrics</li><li>Device verification</li></ul><h3>⚡ Why SSO is Powerful</h3><h3>🚀 1. Seamless User Experience</h3><ul><li>No repeated logins</li><li>Faster access to apps</li></ul><h3>⏳ 2. Saves Time</h3><p>Multiply login time × number of apps = huge productivity loss.</p><p>SSO eliminates that.</p><h3>🔐 3. Better Security</h3><ul><li>Central control</li><li>Easier monitoring</li><li>Faster revocation</li></ul><h3>🏢 4. Enterprise Standard</h3><p>Almost every large organization uses SSO for:</p><ul><li>Internal tools</li><li>Employee portals</li><li>Cloud services</li></ul><h3>⚠️ Are There Any Downsides?</h3><p>SSO is powerful — but not perfect.</p><h3>❗ Single Point of Failure</h3><p>If the Identity Provider goes down:<br>👉 All connected apps become inaccessible</p><h3>❗ High Dependency</h3><p>Everything depends on one system.</p><h3>❗ Initial Setup Complexity</h3><p>Implementing SSO requires:</p><ul><li>Protocol knowledge</li><li>Security configurations</li></ul><h3>🔄 SSO vs Traditional Login</h3><p>FeatureTraditional LoginSSOLogin CountMultipleOneUser ExperienceFrustratingSeamlessSecurityDistributedCentralizedTimeHighLow</p><h3>🧠 Real-Life Analogy</h3><p>Think of SSO like a <strong>hotel key card</strong> 🏨</p><ul><li>You check in once at reception (Identity Provider)</li><li>You get a key card (Token)</li><li>That card opens:</li><li>Your room</li><li>Gym</li><li>Pool</li><li>Lounge</li></ul><p>No need to verify identity again at every door.</p><h3>💭 Final Thought</h3><p>Without SSO, modern digital life would feel like:</p><blockquote><em>Logging into every app… every day… multiple times.</em></blockquote><p>SSO removes that friction and creates a <strong>smooth, secure, and scalable authentication experience</strong>.</p><h3>🚀 In One Line</h3><blockquote><strong><em>SSO = One Login → Unlimited Access (Securely)</em></strong></blockquote><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=6fe9a4d05ac1" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[ Designing Secure Systems: A Practical Guide Every Developer Must Follow]]></title>
            <link>https://medium.com/@omkarj.9900/designing-secure-systems-a-practical-guide-every-developer-must-follow-c416c827d869?source=rss-72ffb130a6a3------2</link>
            <guid isPermaLink="false">https://medium.com/p/c416c827d869</guid>
            <category><![CDATA[secure-system]]></category>
            <category><![CDATA[system-design-concepts]]></category>
            <category><![CDATA[software-engineering]]></category>
            <category><![CDATA[software-development]]></category>
            <category><![CDATA[design]]></category>
            <dc:creator><![CDATA[Omkar Jadhav]]></dc:creator>
            <pubDate>Wed, 15 Apr 2026 04:36:59 GMT</pubDate>
            <atom:updated>2026-04-15T04:36:59.442Z</atom:updated>
            <content:encoded><![CDATA[<p>In today’s digital world, <strong>security is no longer optional</strong> — it’s a necessity.</p><p>From fintech platforms to social media apps, every system handles <strong>sensitive data, user identities, and critical transactions</strong>. A single vulnerability can lead to <strong>data breaches, financial loss, and loss of user trust</strong>.</p><p>Yet, many developers still treat security as an <em>afterthought</em>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/800/1*_wIItD0jZrlodZBEAgyt9A.gif" /></figure><p>👉 The reality?<br><strong>Secure systems are designed — not patched later.</strong></p><h3>🚀 Why Secure System Design Matters</h3><p>Designing secure systems ensures:</p><ul><li>Protection of <strong>sensitive user data</strong></li><li>Prevention of <strong>unauthorized access</strong></li><li>System <strong>stability under attacks</strong></li><li>Compliance with <strong>legal and regulatory standards</strong></li><li>Long-term <strong>trust and reliability</strong></li></ul><p>A strong system is not just scalable and performant — it is <strong>secure by design</strong>.</p><h3>🧠 The 12 Pillars of Secure System Design</h3><p>Let’s break down a practical framework that every engineer should follow:</p><h3>1️⃣ Authentication — Who are you?</h3><p>Authentication verifies user identity.</p><p>🔹 Best Practices:</p><ul><li>Strong password policies</li><li>Multi-Factor Authentication (MFA)</li><li>Secure login mechanisms</li></ul><p>💡 <em>Never rely on passwords alone.</em></p><h3>2️⃣ Authorization — What can you access?</h3><p>Authorization defines user permissions.</p><p>🔹 Best Practices:</p><ul><li>Role-Based Access Control (RBAC)</li><li>Least Privilege Principle</li><li>Regular access reviews</li></ul><p>💡 <em>Users should only access what they absolutely need.</em></p><h3>3️⃣ Encryption — Protect data everywhere</h3><p>Encryption ensures data is unreadable to attackers.</p><p>🔹 Best Practices:</p><ul><li>TLS for data in transit</li><li>Encryption for sensitive data at rest</li><li>Secure key management</li></ul><p>💡 <em>If data isn’t encrypted, assume it’s exposed.</em></p><h3>4️⃣ Vulnerability Management — Find before hackers do</h3><p>🔹 Best Practices:</p><ul><li>Regular security scans</li><li>Timely patching</li><li>Continuous monitoring</li></ul><p>💡 <em>Security is an ongoing process, not a one-time task.</em></p><h3>5️⃣ Audit &amp; Compliance — Be accountable</h3><p>🔹 Best Practices:</p><ul><li>Maintain logs</li><li>Regular audits</li><li>Follow standards like GDPR, HIPAA</li></ul><p>💡 <em>If you can’t track it, you can’t secure it.</em></p><h3>6️⃣ Network Security — Protect your infrastructure</h3><p>🔹 Best Practices:</p><ul><li>Firewalls</li><li>Network segmentation</li><li>Intrusion detection systems</li></ul><p>💡 <em>Don’t expose everything to the internet.</em></p><h3>7️⃣ Terminal Security — Secure endpoints</h3><p>🔹 Best Practices:</p><ul><li>Antivirus protection</li><li>Device management</li><li>Disk encryption</li></ul><p>💡 <em>Endpoints are often the weakest link.</em></p><h3>8️⃣ Emergency Response — Be ready for the worst</h3><p>🔹 Best Practices:</p><ul><li>Incident response plans</li><li>Security operations center (SOC)</li><li>Regular drills</li></ul><p>💡 <em>Preparation reduces damage.</em></p><h3>9️⃣ Container Security — Secure modern deployments</h3><p>🔹 Best Practices:</p><ul><li>Use trusted base images</li><li>Scan containers</li><li>Secure runtime environments</li></ul><p>💡 <em>Containers are powerful, but not inherently secure.</em></p><h3>🔟 API Security — Protect your interfaces</h3><p>🔹 Best Practices:</p><ul><li>OAuth2 authentication</li><li>Rate limiting</li><li>Input validation</li></ul><p>💡 <em>APIs are the most exposed attack surface.</em></p><h3>1️⃣1️⃣ 3rd-Party Vendor Management — Trust carefully</h3><p>🔹 Best Practices:</p><ul><li>Vendor risk assessment</li><li>Secure integrations</li><li>Monitor third-party access</li></ul><p>💡 <em>Your security is only as strong as your weakest partner.</em></p><h3>1️⃣2️⃣ Disaster Recovery — Plan for failure</h3><p>🔹 Best Practices:</p><ul><li>Data backups</li><li>Redundancy</li><li>Failover systems</li></ul><p>💡 <em>Hope for the best, plan for the worst.</em></p><h3>🔥 Final Thoughts</h3><p>Security is not just a checklist.</p><p>It’s a <strong>mindset</strong>, a <strong>culture</strong>, and a <strong>responsibility</strong>.</p><p>The best engineers don’t just build features — <br>they build systems that are:</p><p>✅ Secure<br>✅ Reliable<br>✅ Resilient</p><h3>💬 Your Turn</h3><p>Which area do you think is most ignored in real-world systems?</p><p>Let’s discuss in the comments 👇</p><h3>📌 If you found this helpful:</h3><p>Follow for more insights on <strong>System Design, Backend Engineering &amp; Real-World Tech</strong></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=c416c827d869" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>