<?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: AGuyWhoBuilds</title>
    <description>The latest articles on DEV Community by AGuyWhoBuilds (@aguywhobuilds).</description>
    <link>https://dev.to/aguywhobuilds</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%2F4280857%2F6bf7bba4-e71b-45cf-9754-77af2e2b81de.jpg</url>
      <title>DEV Community: AGuyWhoBuilds</title>
      <link>https://dev.to/aguywhobuilds</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/aguywhobuilds"/>
    <language>en</language>
    <item>
      <title>Learning System Design? Wanna practice and test your skills?</title>
      <dc:creator>AGuyWhoBuilds</dc:creator>
      <pubDate>Thu, 03 Dec 2026 14:14:21 +0000</pubDate>
      <link>https://dev.to/aguywhobuilds/learning-system-design-wanna-practice-and-test-your-skills-230i</link>
      <guid>https://dev.to/aguywhobuilds/learning-system-design-wanna-practice-and-test-your-skills-230i</guid>
      <description>&lt;p&gt;This is one of the recently asked Amazon SDE-2 / Senior system design questions (order updates, delivery alerts, OTPs, promo pushes).&lt;/p&gt;

&lt;h3&gt;
  
  
  1. Requirements &amp;amp; Scale Targets
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Functional&lt;/strong&gt;:

&lt;ul&gt;
&lt;li&gt;Accept notification requests from internal services (order, shipping, marketing) for &lt;strong&gt;Push, Email, and SMS&lt;/strong&gt;.&lt;/li&gt;
&lt;li&gt;Respect &lt;strong&gt;user preferences and quiet hours&lt;/strong&gt; (don't wake users at 3 AM for promo alerts).&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Non-Functional&lt;/strong&gt;:

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Traffic&lt;/strong&gt;: 25,000 RPS sustained, spiking to &lt;strong&gt;35,000 RPS&lt;/strong&gt; (90% writes / 10% reads)&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Latency&lt;/strong&gt;: p99 &lt;strong&gt;&amp;lt; 80 ms&lt;/strong&gt; for callers submitting a notification&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Availability&lt;/strong&gt;: 99.9%+&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Reliability&lt;/strong&gt;: &lt;strong&gt;Never send duplicates&lt;/strong&gt;; a slow third-party provider (e.g., an SMS gateway lagging at 2s) must &lt;strong&gt;not&lt;/strong&gt; stall Push or Email.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Budget&lt;/strong&gt;: Keep infra lean (~$600/mo).&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  2. Why the Naive Design Fails Immediately
&lt;/h3&gt;

&lt;p&gt;If callers hit &lt;code&gt;API Service -&amp;gt; Check Preferences DB -&amp;gt; Call APNs / Twilio / SES synchronously&lt;/code&gt;:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Tail latency explodes&lt;/strong&gt;: Third-party providers take 200ms–2,000ms. You blow past the 80ms p99 SLA instantly.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Cascading failure (head-of-line blocking)&lt;/strong&gt;: If Twilio (SMS) slows down or rate-limits you, worker threads block waiting on SMS, starving Push and Email traffic.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;DB write saturation&lt;/strong&gt;: Writing every notification synchronously to a single primary DB at 25k–35k RPS (90% writes) saturates IOPS and connection pools.&lt;/li&gt;
&lt;/ol&gt;

&lt;h3&gt;
  
  
  3. The Architecture That Passes
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;Core principle: Accept fast, isolate per channel, deliver asynchronously.&lt;/strong&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Ingestion API (Stateless, behind Load Balancer)&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Validate payload + require an &lt;code&gt;idempotency_key&lt;/code&gt; (e.g., &lt;code&gt;order_123_shipped&lt;/code&gt;).&lt;/li&gt;
&lt;li&gt;Check user preferences &amp;amp; quiet hours from a &lt;strong&gt;Redis cache&lt;/strong&gt; (read-through backed by DynamoDB/PostgreSQL — preferences rarely change, so cache hit rate is ~99%).&lt;/li&gt;
&lt;li&gt;Publish the event to a &lt;strong&gt;channel-specific queue&lt;/strong&gt; and immediately return &lt;code&gt;202 Accepted&lt;/code&gt; -&amp;gt; keeps ingestion p99 &lt;strong&gt;under 20–40ms&lt;/strong&gt;.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Separate Queues per Channel (Bulkhead Pattern)&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Never put Push, Email, and SMS in one shared queue.&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;Split into &lt;code&gt;push-queue&lt;/code&gt;, &lt;code&gt;email-queue&lt;/code&gt;, &lt;code&gt;sms-queue&lt;/code&gt; (and optionally a &lt;code&gt;critical-otp-queue&lt;/code&gt; vs &lt;code&gt;marketing-queue&lt;/code&gt; so promo blasts never delay OTPs).&lt;/li&gt;
&lt;li&gt;If the SMS provider degrades, only &lt;code&gt;sms-queue&lt;/code&gt; backs up; Push and Email stay green.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Channel Workers + Retry &amp;amp; DLQ&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Independent auto-scaling worker pools pull from each queue at each provider's rate limit.&lt;/li&gt;
&lt;li&gt;Exponential backoff with jitter on 429/5xx; poison messages go to a &lt;strong&gt;Dead Letter Queue (DLQ)&lt;/strong&gt; for inspection/replay.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Deduplication (At-Least-Once Queue -&amp;gt; Effectively-Once Delivery)&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Before calling the provider, workers do an atomic &lt;code&gt;SET dedup:&amp;lt;idempotency_key&amp;gt; 1 NX EX 86400&lt;/code&gt; in Redis (or conditional write in DynamoDB).&lt;/li&gt;
&lt;li&gt;If the key exists, skip and ack the message.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;/ol&gt;

&lt;h3&gt;
  
  
  4. Trade-offs Interviewers Love Hearing
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Sync vs Async UX&lt;/strong&gt;: Callers get &lt;code&gt;202 Accepted&lt;/code&gt; (queued), not guaranteed delivery confirmation — delivery happens moments later.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Dedup Window vs Cost&lt;/strong&gt;: Keeping a 24h dedup key in Redis/DynamoDB adds a state lookup on every send, trading a tiny bit of cost for zero user-facing spam.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Crash Mid-Send Edge Case&lt;/strong&gt;: If a worker sends to Twilio and crashes &lt;em&gt;before&lt;/em&gt; marking the key complete, a retry can still cause a rare duplicate unless the third-party provider itself supports idempotency keys. Always mention this!&lt;/li&gt;
&lt;/ul&gt;




&lt;p&gt;If you want to wire this up and test it against a real 25k–35k RPS spike to see the baseline saturate and watch queues + caching bring p99 under 80ms within the $600/mo budget, I built a free interactive simulator problem for it here: &lt;a href="https://designthesystem.dev/problems/a-scalable-notification-service" rel="noopener noreferrer"&gt;https://designthesystem.dev/problems/a-scalable-notification-service&lt;/a&gt; (no signup required).&lt;/p&gt;

</description>
      <category>ai</category>
      <category>programming</category>
      <category>systemdesign</category>
      <category>lld</category>
    </item>
  </channel>
</rss>
