<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Huzaifa Awan </title>
    <description>The latest articles on DEV Community by Huzaifa Awan  (@mhuzaifaawan).</description>
    <link>https://dev.to/mhuzaifaawan</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F4036228%2Ff3e7bc15-9fdf-4034-b451-133530dd7070.jpg</url>
      <title>DEV Community: Huzaifa Awan </title>
      <link>https://dev.to/mhuzaifaawan</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/mhuzaifaawan"/>
    <language>en</language>
    <item>
      <title>How I Hit a 95% Redis Cache Hit Rate Under Real Load</title>
      <dc:creator>Huzaifa Awan </dc:creator>
      <pubDate>Sun, 19 Jul 2026 07:56:57 +0000</pubDate>
      <link>https://dev.to/mhuzaifaawan/how-i-hit-a-95-redis-cache-hit-rate-under-real-load-4eo6</link>
      <guid>https://dev.to/mhuzaifaawan/how-i-hit-a-95-redis-cache-hit-rate-under-real-load-4eo6</guid>
      <description>&lt;p&gt;On a multi-tenant SaaS dashboard I work on, response times climbed as concurrency grew. The fix was not a bigger server. It was a &lt;strong&gt;Redis caching strategy&lt;/strong&gt; layered onto a .NET Core API. The result: a &lt;strong&gt;95% cache hit rate&lt;/strong&gt; and &lt;strong&gt;sub-50ms responses&lt;/strong&gt; under 100+ concurrent users. Here is the actual process, not the highlight reel.&lt;/p&gt;

&lt;h2&gt;
  
  
  Measure before you cache
&lt;/h2&gt;

&lt;p&gt;Caching the wrong thing hides problems and creates new ones. I started by profiling the API under realistic load to find the true hotspots: the endpoints that were both &lt;strong&gt;frequently hit&lt;/strong&gt; and &lt;strong&gt;expensive&lt;/strong&gt; to compute. Almost all the pain came from a handful of dashboard reads that ran heavy SQL Server aggregations on every request.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Frequent + expensive = cache it.&lt;/li&gt;
&lt;li&gt;Frequent + cheap = probably leave it.&lt;/li&gt;
&lt;li&gt;Rare + expensive = optimize the query, do not cache.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Cache-key design is the whole game
&lt;/h2&gt;

&lt;p&gt;A cache is only as good as its keys. For a multi-tenant app, every key has to be &lt;strong&gt;scoped to the tenant&lt;/strong&gt; and to the exact parameters that change the result: date range, filters, locale. Get this wrong and you either leak data across tenants or get a hit rate near zero because no two keys ever match.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;dashboard:{tenantId}:kpis:{from}:{to}:{locale}
dashboard:{tenantId}:queue:live
catalog:{tenantId}:lowstock
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Flat, predictable, and self-documenting. When a key names exactly what it holds, invalidation becomes obvious instead of guesswork.&lt;/p&gt;

&lt;h2&gt;
  
  
  Invalidation without the footguns
&lt;/h2&gt;

&lt;p&gt;The famous hard problem. I leaned on two techniques: &lt;strong&gt;short, tuned TTLs&lt;/strong&gt; for data that is allowed to be a few seconds stale (KPI roll-ups), and &lt;strong&gt;event-driven invalidation&lt;/strong&gt; for data that must be fresh: when a write happens, the specific keys it affects are evicted immediately. Mixing the two keeps the hit rate high without ever showing a user stale-but-important data.&lt;/p&gt;

&lt;h2&gt;
  
  
  Verify the hit rate is real
&lt;/h2&gt;

&lt;p&gt;A 95% hit rate only means something if you measure it under production-like concurrency, not a single-user test. I tracked hits, misses, and p95 latency while ramping concurrent users, and watched the cache warm and hold. That is also how you catch a key that looks cached but never actually matches.&lt;/p&gt;

&lt;h2&gt;
  
  
  The takeaways
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;Profile first. Cache the endpoints that are frequent and expensive, nothing else.&lt;/li&gt;
&lt;li&gt;Scope keys to the tenant and every parameter that changes the result.&lt;/li&gt;
&lt;li&gt;Combine tuned TTLs with event-driven eviction so fresh data stays fresh.&lt;/li&gt;
&lt;li&gt;Prove the hit rate under real concurrency, not on your laptop.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Performance work like this, turning a slow app that scales poorly into a fast one, is a big part of what I do. See more of my &lt;a href="https://huzaifaawan.com/#projects" rel="noopener noreferrer"&gt;work&lt;/a&gt; or &lt;a href="https://huzaifaawan.com/#contact" rel="noopener noreferrer"&gt;reach out&lt;/a&gt; if your app is starting to feel the load.&lt;/p&gt;




&lt;p&gt;&lt;em&gt;Originally published at &lt;a href="https://huzaifaawan.com/blog/95-percent-redis-cache-hit-rate" rel="noopener noreferrer"&gt;huzaifaawan.com&lt;/a&gt;. I am Muhammad Huzaifa Awan, a Senior Full Stack Developer building SaaS, AI products, and MCP servers. More writing and my portfolio live at &lt;a href="https://huzaifaawan.com" rel="noopener noreferrer"&gt;huzaifaawan.com&lt;/a&gt;.&lt;/em&gt;&lt;/p&gt;

</description>
      <category>redis</category>
      <category>dotnet</category>
      <category>performance</category>
    </item>
  </channel>
</rss>
