<?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: Miahlouge</title>
    <description>The latest articles on DEV Community by Miahlouge (@smiah).</description>
    <link>https://dev.to/smiah</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.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F3045563%2F4606dc0e-69ab-488d-bacf-7f1b153e26cd.png</url>
      <title>DEV Community: Miahlouge</title>
      <link>https://dev.to/smiah</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/smiah"/>
    <language>en</language>
    <item>
      <title>Redundancy vs. Replication in a Distributed System</title>
      <dc:creator>Miahlouge</dc:creator>
      <pubDate>Tue, 22 Apr 2025 18:16:21 +0000</pubDate>
      <link>https://dev.to/smiah/redundancy-vs-replication-4phh</link>
      <guid>https://dev.to/smiah/redundancy-vs-replication-4phh</guid>
      <description>&lt;p&gt;𝗥𝗲𝗱𝘂𝗻𝗱𝗮𝗻𝗰𝘆 - backup systems to avoid downtime.&lt;br&gt;
𝗥𝗲𝗽𝗹𝗶𝗰𝗮𝘁𝗶𝗼𝗻 - backup data to avoid data loss.&lt;/p&gt;

&lt;p&gt;Redundancy and replication are both strategies for increasing the reliability and availability of systems.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Redundancy&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Duplicating resources to ensure uninterrupted operation in case of failure.&lt;/p&gt;

&lt;p&gt;Redundancy is the practice of duplicating critical components or systems to increase reliability and availability. If one part fails, another seamlessly takes over. This applies to servers, databases, network devices, and even entire data centers.&lt;/p&gt;

&lt;p&gt;𝗕𝗲𝗻𝗲𝗳𝗶𝘁𝘀&lt;br&gt;
→ Prevents downtime by switching to backup systems.&lt;br&gt;
→ Keeps system running even during component failure.&lt;br&gt;
→ Enables recovery in case of hardware or regional outages.&lt;br&gt;
→ Often combined with load balancing to handle traffic across redundant systems.&lt;/p&gt;

&lt;p&gt;𝗪𝗵𝗲𝗻 𝗧𝗼 𝗨𝘀𝗲 𝗥𝗲𝗱𝘂𝗻𝗱𝗮𝗻𝗰𝘆&lt;br&gt;
• You’re building systems that must run 24/7.&lt;br&gt;
• User experience and trust are tightly tied to uptime e.g. banking, trading etc.&lt;br&gt;
• Legal or SLA (Service Level Agreement) requirements demand.&lt;br&gt;
• Preparation for hardware failures, data center outages, or regional disasters.&lt;br&gt;
• Maintenance without downtime ensures availability during updates or changes.&lt;/p&gt;

&lt;p&gt;𝗘𝘅𝗮𝗺𝗽𝗹𝗲: 𝗣𝗮𝘆𝗺𝗲𝗻𝘁 𝗦𝗲𝗿𝘃𝗶𝗰𝗲&lt;/p&gt;

&lt;p&gt;A payment platform has two payment processing servers in the same data center. If one server fails during a credit card transaction, the load balancer automatically reroutes the request to the backup server.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F7f5w4fkgkrdno6myixkd.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F7f5w4fkgkrdno6myixkd.png" alt="Redundancy vs. Replication" width="800" height="800"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Replication&lt;/strong&gt;&lt;br&gt;
Creating multiple, identical copies of data or resources.&lt;/p&gt;

&lt;p&gt;Replication ensures that data exists in more than one place whether across databases, servers, or regions. It helps systems stay available even when part of the infrastructure becomes unreachable.&lt;/p&gt;

&lt;p&gt;𝗕𝗲𝗻𝗲𝗳𝗶𝘁𝘀&lt;/p&gt;

&lt;p&gt;→ Provides high availability of data, even during failures&lt;br&gt;
→ Improves read performance by allowing distributed access&lt;br&gt;
→ Supports disaster recovery and backup strategies&lt;br&gt;
→ Enables data locality for global applications&lt;br&gt;
→ Protects against data loss&lt;/p&gt;

&lt;p&gt;𝗪𝗵𝗲𝗻 𝗧𝗼 𝗨𝘀𝗲 𝗥𝗲𝗽𝗹𝗶𝗰𝗮𝘁𝗶𝗼𝗻&lt;/p&gt;

&lt;p&gt;• You need data access across multiple regions or data centers.&lt;br&gt;
• You want to scale reads across replicas.&lt;br&gt;
• You’re building fault-tolerant and distributed databases.&lt;br&gt;
• Regulatory requirements demand backups or geo-redundancy.&lt;br&gt;
• Real-time analytics or reporting systems require up-to-date data from production.&lt;/p&gt;

&lt;p&gt;𝗘𝘅𝗮𝗺𝗽𝗹𝗲: 𝗣𝗮𝘆𝗺𝗲𝗻𝘁 𝗦𝗲𝗿𝘃𝗶𝗰𝗲&lt;br&gt;
The platform stores user balances and transaction records in a database that is replicated across multiple regions (e.g., Frankfurt and Amsterdam). If the primary database becomes unavailable, the system can read from the replica.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Conclusion&lt;/strong&gt;&lt;br&gt;
Redundancy is like an insurance policy in system design. Replication, on the other hand, ensures that data stays accessible and consistent across systems, enhancing availability, performance, and disaster recovery.&lt;/p&gt;

</description>
      <category>redundancy</category>
      <category>replication</category>
      <category>distributedsystems</category>
      <category>miahlouge</category>
    </item>
    <item>
      <title>Rate Limiting in Distributed System</title>
      <dc:creator>Miahlouge</dc:creator>
      <pubDate>Wed, 16 Apr 2025 12:40:45 +0000</pubDate>
      <link>https://dev.to/smiah/rate-limiting-in-distributed-system-3h59</link>
      <guid>https://dev.to/smiah/rate-limiting-in-distributed-system-3h59</guid>
      <description>&lt;p&gt;Rate-limiting, or throttling, is a mechanism that rejects a request when a specific quota is exceeded. A technique to control how many requests a client can make to a service over a given time window. When a client exceeds their quota, subsequent requests are rejected or delayed.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F7kf2kxw600emvqhtrv37.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F7kf2kxw600emvqhtrv37.png" alt="Introduction" width="800" height="493"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Throttling Pattern and Rate Limiting Pattern as key strategies for protecting services against overuse and abuse. It ensures fair resource allocation, and maintaining system stability under varying load conditions.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;What is Rate Limiting?&lt;/strong&gt;&lt;br&gt;
Rate limiting defines quotas on resource usage, typically measured by:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Number of requests (e.g., 100 requests per minute)&lt;/li&gt;
&lt;li&gt;Data volume (e.g., 1MB per second)&lt;/li&gt;
&lt;li&gt;Concurrency (e.g., 10 parallel connections)&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fh93y9uzzay7ke7watax7.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fh93y9uzzay7ke7watax7.png" alt="Concurrent request limiters manage resource contention for CPU-intensive API endpoints." width="800" height="411"&gt;&lt;/a&gt;&lt;br&gt;
If a service allows 10 requests per second per API key, and a particular key makes 12 requests, then 2 requests will be rejected on average.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Why Implement Rate Limiting?&lt;/strong&gt;&lt;br&gt;
It helps keep systems fair and available for everyone from single user or a bot that throttles up the requests. By controlling how many requests a user or bot can make, it prevents any single source from overwhelming the service. This ensures that all users get a fair chance to access resources. It also adds a layer of security by blocking brute-force attacks and bot-nets that try to exploit the system through excessive or malicious requests.&lt;/p&gt;

&lt;p&gt;They use brute-force algorithms to attack the system using a single machine or even multiple machines that constitute a network of bots known as a bot-net.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Types fo Rate Limiting&lt;/strong&gt;&lt;br&gt;
Rate limiting can be broadly categorized in two types: Single process rate limiting, and distributed rate limiting. We will start with a single-process implementation first and then extend it to a distributed one.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Single-Process Rate Limiting&lt;/strong&gt;&lt;br&gt;
&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fq4xvu8gfno8x083k2edb.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fq4xvu8gfno8x083k2edb.png" alt="Single-Process Rate Limiting" width="800" height="395"&gt;&lt;/a&gt;&lt;br&gt;
Tracking Timestamps&lt;br&gt;
We could store a list of timestamps for each API key and periodically clean out any that are older than the quota interval (e.g., 1 minute). But as the number of requests grows, this approach becomes memory intensive.&lt;/p&gt;

&lt;p&gt;Memory-Efficient Alternative: Bucketing&lt;br&gt;
A more scalable approach is to divide time into fixed intervals (buckets) such as one-minute buckets and use counters instead of raw timestamps.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fu9ys3u786buryw4blzxw.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fu9ys3u786buryw4blzxw.png" alt="Buckets divide time into 1-minute intervals, which keep track of the number of requests seen." width="800" height="386"&gt;&lt;/a&gt;&lt;br&gt;
How It Works:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Each incoming request is mapped to a time bucket based on its timestamp.&lt;/li&gt;
&lt;li&gt;The corresponding bucket’s counter is incremented.&lt;/li&gt;
&lt;li&gt;Only the relevant bucket windows are retained.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Example:&lt;br&gt;
If a request arrives at 12:00:18, it is counted under the bucket for 12:00.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F4hjodt4kbtrya4760djz.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F4hjodt4kbtrya4760djz.png" alt="When a new request comes in, its timestamp is used to determine the bucket it belongs to." width="800" height="395"&gt;&lt;/a&gt;&lt;br&gt;
This method compresses request information efficiently, using constant space per API key, regardless of the number of requests.&lt;/p&gt;

&lt;p&gt;Now, with this memory-efficient setup, how can we enforce rate limits?&lt;/p&gt;

&lt;p&gt;Enforcing Limits with a Sliding Window&lt;br&gt;
We can implement rate limiting using a sliding window that moves across buckets in real time, tracking the requests within it. The window's length aligns with the quota time unit, like 1 minute. However, because the sliding window can overlap with multiple buckets, we must calculate a weighted sum of bucket counters to determine the requests within the window.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fvg9ia6xkpdwihj1wnnvh.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fvg9ia6xkpdwihj1wnnvh.png" alt="A bucket's weight proportional to its overlap with the sliding window." width="800" height="383"&gt;&lt;/a&gt;&lt;br&gt;
To compute this:&lt;/p&gt;

&lt;p&gt;Calculate a weighted sum of overlapping bucket counters.&lt;/p&gt;

&lt;p&gt;Weigh each bucket based on how much of it falls within the sliding window.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ft1yi4f7txbzf105w9qjr.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ft1yi4f7txbzf105w9qjr.png" alt="sliding window" width="800" height="381"&gt;&lt;/a&gt;&lt;br&gt;
This approximation improves with smaller buckets (e.g., 10-second intervals).&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Distributed Rate Limiting&lt;/strong&gt;&lt;br&gt;
Things get tricky in distributed systems with multiple servers, especially across regions. If each server has its own rate limiter, it can lead to two main issues:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Inconsistent limits&lt;/li&gt;
&lt;li&gt;Race Conditions&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;When multiple processes handle requests, local rate limiting isn’t enough. We need shared state to coordinate limits globally across nodes. A shared data store is needed to track total requests per API key.&lt;br&gt;
&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Flqlxkf9kwkvogvxv2y7r.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Flqlxkf9kwkvogvxv2y7r.jpg" alt="Servers batch bucket updates in memory for some time, and flush them asynchoronously to the data store at the end of it." width="800" height="398"&gt;&lt;/a&gt;&lt;br&gt;
Shared Data Store Approach&lt;br&gt;
A central data store (e.g., Redis, DynamoDB, Memcached) can store counters for each API key and bucket.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Store two counters per API key (current and previous buckets).&lt;/li&gt;
&lt;li&gt;Each request updates the counter via atomic operations like INCR.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F4bud9ardi8p16pr7xjzy.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F4bud9ardi8p16pr7xjzy.png" alt="central data store" width="800" height="712"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Challenges &amp;amp; Optimizations&lt;br&gt;
Concurrency Issues&lt;br&gt;
Simultaneous updates from multiple nodes can lead to race conditions. Using transactions solves this but is slow and resource-heavy. Atomic operations might be a solution (e.g., INCR, GETSET, COMPARE-AND-SWAP) to safely update counters.&lt;/p&gt;

&lt;p&gt;Race Condition Example:&lt;/p&gt;

&lt;p&gt;Without atomic operation&lt;br&gt;
&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F349561ky9v90gs62d6rw.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F349561ky9v90gs62d6rw.png" alt="Without atomic operation" width="800" height="351"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;With Atomic Operation (INCR in Redis)&lt;br&gt;
&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fqzrpoiwrmvc7uwnnwepl.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fqzrpoiwrmvc7uwnnwepl.png" alt="With Atomic Operation" width="800" height="220"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Performance Bottlenecks&lt;br&gt;
Writing to the shared store on every request introduces latency and load.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fz9resju0kww8d7nbl5ls.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fz9resju0kww8d7nbl5ls.png" alt="Without Batching (Write on Every Request)." width="800" height="255"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Solution:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Batch updates in memory.&lt;/li&gt;
&lt;li&gt;Periodically flush them asynchronously to the shared store.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fezh0fhncavf1iejfwpds.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fezh0fhncavf1iejfwpds.png" alt="With Batching (Buffered Updates + Periodic Flush)." width="800" height="335"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Servers batch bucket updates in memory for some time, and flush them asynchronously to the data store at the end of it. This significantly reduces write frequency and improves throughput.&lt;/p&gt;

&lt;p&gt;Store Downtime&lt;br&gt;
What if the central data store becomes unavailable?&lt;/p&gt;

&lt;p&gt;Enter the CAP theorem: you must choose between consistency and availability during network faults.&lt;/p&gt;

&lt;p&gt;Safer fallback:&lt;/p&gt;

&lt;p&gt;Continue to serve requests using the last known state from the data store.&lt;/p&gt;

&lt;p&gt;Avoid outright rejections due to temporary unreachability — especially if the alternative is degraded business operations.&lt;/p&gt;

&lt;p&gt;This compromise favors availability over strict consistency, which is often acceptable in real-world systems.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Rate Limiting Considerations&lt;/strong&gt;&lt;br&gt;
Are you safely hooking rate limiters into your middleware stack?&lt;br&gt;
Make sure failures (like bugs or Redis downtime) don’t break your API—catch exceptions and let requests pass through if needed.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;Are you showing clear rate limit errors to users?&lt;br&gt;
Choose between HTTP 429 or 503 based on context, and return clear, actionable messages.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Can you safely turn off the rate limiters if necessary?&lt;br&gt;
Use feature flags as escape valves and set up alerts to monitor how often limiters trigger.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Did you test each rate limiter in dark mode to see the impact?Ensure your limits keep the API stable without disrupting users. You might need to collaborate with users to adjust their usage patterns.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;strong&gt;When Not to Use Rate Limiting?&lt;/strong&gt;&lt;br&gt;
Rate limiting might not be necessary for internal services within a fully trusted environment where all clients are known, controlled, and operate at predictable loads. In such cases, adding rate limiting could introduce unnecessary complexity and latency without much benefit.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Conclusion&lt;/strong&gt;&lt;br&gt;
Rate limiting and throttling help protect systems from overuse. They make sure users get fair access. In distributed systems, things get more complex. Issues like race conditions and latency can happen. Using buckets, sliding windows, and atomic updates helps. Batching and async writes reduce load. These tools keep systems fast and reliable.&lt;/p&gt;

&lt;p&gt;𝗜𝗻𝘀𝗽𝗶𝗿𝗮𝘁𝗶𝗼𝗻𝘀 𝗮𝗻𝗱 𝗥𝗲𝗳𝗲𝗿𝗲𝗻𝗰𝗲𝘀&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Rate Limiting Pattern, Microsoft&lt;/li&gt;
&lt;li&gt;Scaling your API with rate limiters, Stripe&lt;/li&gt;
&lt;li&gt;Understanding Distributed Systems by Roberto Vitillo&lt;/li&gt;
&lt;/ol&gt;

</description>
      <category>distributedsystems</category>
      <category>ratelimiting</category>
      <category>miahlouge</category>
    </item>
    <item>
      <title>𝗖𝗼𝗺𝗯𝗶𝗻𝗲 𝗕𝗼𝘁𝗵: 𝗠𝗼𝘀𝘁 𝗦𝘂𝗰𝗰𝗲𝘀𝘀𝗳𝘂𝗹 𝗔𝗿𝗰𝗵𝗶𝘁𝗲𝗰𝘁𝘂𝗿𝗲𝘀 𝗗𝗼</title>
      <dc:creator>Miahlouge</dc:creator>
      <pubDate>Mon, 14 Apr 2025 14:53:07 +0000</pubDate>
      <link>https://dev.to/smiah/-5cn0</link>
      <guid>https://dev.to/smiah/-5cn0</guid>
      <description>&lt;div class="ltag__link--embedded"&gt;
  &lt;div class="crayons-story "&gt;
  &lt;a href="https://dev.to/smiah/streaming-vs-queuing-what-happens-if-you-choose-wrong-2h6e" class="crayons-story__hidden-navigation-link"&gt;Streaming vs Queuing: What Happens If You Choose Wrong?&lt;/a&gt;


  &lt;div class="crayons-story__body crayons-story__body-full_post"&gt;
    &lt;div class="crayons-story__top"&gt;
      &lt;div class="crayons-story__meta"&gt;
        &lt;div class="crayons-story__author-pic"&gt;

          &lt;a href="/smiah" class="crayons-avatar  crayons-avatar--l  "&gt;
            &lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F3045563%2F4606dc0e-69ab-488d-bacf-7f1b153e26cd.png" alt="smiah profile" class="crayons-avatar__image"&gt;
          &lt;/a&gt;
        &lt;/div&gt;
        &lt;div&gt;
          &lt;div&gt;
            &lt;a href="/smiah" class="crayons-story__secondary fw-medium m:hidden"&gt;
              Miahlouge
            &lt;/a&gt;
            &lt;div class="profile-preview-card relative mb-4 s:mb-0 fw-medium hidden m:inline-block"&gt;
              
                Miahlouge
                
              
              &lt;div id="story-author-preview-content-2402860" class="profile-preview-card__content crayons-dropdown branded-7 p-4 pt-0"&gt;
                &lt;div class="gap-4 grid"&gt;
                  &lt;div class="-mt-4"&gt;
                    &lt;a href="/smiah" class="flex"&gt;
                      &lt;span class="crayons-avatar crayons-avatar--xl mr-2 shrink-0"&gt;
                        &lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F3045563%2F4606dc0e-69ab-488d-bacf-7f1b153e26cd.png" class="crayons-avatar__image" alt=""&gt;
                      &lt;/span&gt;
                      &lt;span class="crayons-link crayons-subtitle-2 mt-5"&gt;Miahlouge&lt;/span&gt;
                    &lt;/a&gt;
                  &lt;/div&gt;
                  &lt;div class="print-hidden"&gt;
                    
                      Follow
                    
                  &lt;/div&gt;
                  &lt;div class="author-preview-metadata-container"&gt;&lt;/div&gt;
                &lt;/div&gt;
              &lt;/div&gt;
            &lt;/div&gt;

          &lt;/div&gt;
          &lt;a href="https://dev.to/smiah/streaming-vs-queuing-what-happens-if-you-choose-wrong-2h6e" class="crayons-story__tertiary fs-xs"&gt;&lt;time&gt;Apr 12 '25&lt;/time&gt;&lt;span class="time-ago-indicator-initial-placeholder"&gt;&lt;/span&gt;&lt;/a&gt;
        &lt;/div&gt;
      &lt;/div&gt;

    &lt;/div&gt;

    &lt;div class="crayons-story__indention"&gt;
      &lt;h2 class="crayons-story__title crayons-story__title-full_post"&gt;
        &lt;a href="https://dev.to/smiah/streaming-vs-queuing-what-happens-if-you-choose-wrong-2h6e" id="article-link-2402860"&gt;
          Streaming vs Queuing: What Happens If You Choose Wrong?
        &lt;/a&gt;
      &lt;/h2&gt;
        &lt;div class="crayons-story__tags"&gt;
            &lt;a class="crayons-tag  crayons-tag--monochrome " href="/t/streaming"&gt;&lt;span class="crayons-tag__prefix"&gt;#&lt;/span&gt;streaming&lt;/a&gt;
            &lt;a class="crayons-tag  crayons-tag--monochrome " href="/t/queuing"&gt;&lt;span class="crayons-tag__prefix"&gt;#&lt;/span&gt;queuing&lt;/a&gt;
            &lt;a class="crayons-tag  crayons-tag--monochrome " href="/t/eventdriven"&gt;&lt;span class="crayons-tag__prefix"&gt;#&lt;/span&gt;eventdriven&lt;/a&gt;
            &lt;a class="crayons-tag  crayons-tag--monochrome " href="/t/miahlouge"&gt;&lt;span class="crayons-tag__prefix"&gt;#&lt;/span&gt;miahlouge&lt;/a&gt;
        &lt;/div&gt;
      &lt;div class="crayons-story__bottom"&gt;
        &lt;div class="crayons-story__details"&gt;
            &lt;a href="https://dev.to/smiah/streaming-vs-queuing-what-happens-if-you-choose-wrong-2h6e#comments" class="crayons-btn crayons-btn--s crayons-btn--ghost crayons-btn--icon-left flex items-center"&gt;
              Comments


              &lt;span class="hidden s:inline"&gt;Add Comment&lt;/span&gt;
            &lt;/a&gt;
        &lt;/div&gt;
        &lt;div class="crayons-story__save"&gt;
          &lt;small class="crayons-story__tertiary fs-xs mr-2"&gt;
            1 min read
          &lt;/small&gt;
            
              &lt;span class="bm-initial"&gt;
                

              &lt;/span&gt;
              &lt;span class="bm-success"&gt;
                

              &lt;/span&gt;
            
        &lt;/div&gt;
      &lt;/div&gt;
    &lt;/div&gt;
  &lt;/div&gt;
&lt;/div&gt;

&lt;/div&gt;


</description>
      <category>streaming</category>
      <category>queuing</category>
      <category>eventdriven</category>
    </item>
    <item>
      <title>Load isn’t the problem. Mismanaging it is.</title>
      <dc:creator>Miahlouge</dc:creator>
      <pubDate>Mon, 14 Apr 2025 14:52:15 +0000</pubDate>
      <link>https://dev.to/smiah/load-isnt-the-problem-mismanaging-it-is-3h5b</link>
      <guid>https://dev.to/smiah/load-isnt-the-problem-mismanaging-it-is-3h5b</guid>
      <description>&lt;div class="ltag__link--embedded"&gt;
  &lt;div class="crayons-story "&gt;
  &lt;a href="https://dev.to/smiah/load-balancing-vs-load-shedding-vs-load-leveling-48ff" class="crayons-story__hidden-navigation-link"&gt;Load Balancing vs Load Shedding vs Load Leveling&lt;/a&gt;


  &lt;div class="crayons-story__body crayons-story__body-full_post"&gt;
    &lt;div class="crayons-story__top"&gt;
      &lt;div class="crayons-story__meta"&gt;
        &lt;div class="crayons-story__author-pic"&gt;

          &lt;a href="/smiah" class="crayons-avatar  crayons-avatar--l  "&gt;
            &lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F3045563%2F4606dc0e-69ab-488d-bacf-7f1b153e26cd.png" alt="smiah profile" class="crayons-avatar__image"&gt;
          &lt;/a&gt;
        &lt;/div&gt;
        &lt;div&gt;
          &lt;div&gt;
            &lt;a href="/smiah" class="crayons-story__secondary fw-medium m:hidden"&gt;
              Miahlouge
            &lt;/a&gt;
            &lt;div class="profile-preview-card relative mb-4 s:mb-0 fw-medium hidden m:inline-block"&gt;
              
                Miahlouge
                
              
              &lt;div id="story-author-preview-content-2402841" class="profile-preview-card__content crayons-dropdown branded-7 p-4 pt-0"&gt;
                &lt;div class="gap-4 grid"&gt;
                  &lt;div class="-mt-4"&gt;
                    &lt;a href="/smiah" class="flex"&gt;
                      &lt;span class="crayons-avatar crayons-avatar--xl mr-2 shrink-0"&gt;
                        &lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F3045563%2F4606dc0e-69ab-488d-bacf-7f1b153e26cd.png" class="crayons-avatar__image" alt=""&gt;
                      &lt;/span&gt;
                      &lt;span class="crayons-link crayons-subtitle-2 mt-5"&gt;Miahlouge&lt;/span&gt;
                    &lt;/a&gt;
                  &lt;/div&gt;
                  &lt;div class="print-hidden"&gt;
                    
                      Follow
                    
                  &lt;/div&gt;
                  &lt;div class="author-preview-metadata-container"&gt;&lt;/div&gt;
                &lt;/div&gt;
              &lt;/div&gt;
            &lt;/div&gt;

          &lt;/div&gt;
          &lt;a href="https://dev.to/smiah/load-balancing-vs-load-shedding-vs-load-leveling-48ff" class="crayons-story__tertiary fs-xs"&gt;&lt;time&gt;Apr 12 '25&lt;/time&gt;&lt;span class="time-ago-indicator-initial-placeholder"&gt;&lt;/span&gt;&lt;/a&gt;
        &lt;/div&gt;
      &lt;/div&gt;

    &lt;/div&gt;

    &lt;div class="crayons-story__indention"&gt;
      &lt;h2 class="crayons-story__title crayons-story__title-full_post"&gt;
        &lt;a href="https://dev.to/smiah/load-balancing-vs-load-shedding-vs-load-leveling-48ff" id="article-link-2402841"&gt;
          Load Balancing vs Load Shedding vs Load Leveling
        &lt;/a&gt;
      &lt;/h2&gt;
        &lt;div class="crayons-story__tags"&gt;
            &lt;a class="crayons-tag  crayons-tag--monochrome " href="/t/softwareengineering"&gt;&lt;span class="crayons-tag__prefix"&gt;#&lt;/span&gt;softwareengineering&lt;/a&gt;
            &lt;a class="crayons-tag  crayons-tag--monochrome " href="/t/distributedsystems"&gt;&lt;span class="crayons-tag__prefix"&gt;#&lt;/span&gt;distributedsystems&lt;/a&gt;
            &lt;a class="crayons-tag  crayons-tag--monochrome " href="/t/highavailability"&gt;&lt;span class="crayons-tag__prefix"&gt;#&lt;/span&gt;highavailability&lt;/a&gt;
            &lt;a class="crayons-tag  crayons-tag--monochrome " href="/t/miahlouge"&gt;&lt;span class="crayons-tag__prefix"&gt;#&lt;/span&gt;miahlouge&lt;/a&gt;
        &lt;/div&gt;
      &lt;div class="crayons-story__bottom"&gt;
        &lt;div class="crayons-story__details"&gt;
          &lt;a href="https://dev.to/smiah/load-balancing-vs-load-shedding-vs-load-leveling-48ff" class="crayons-btn crayons-btn--s crayons-btn--ghost crayons-btn--icon-left"&gt;
            &lt;div class="multiple_reactions_aggregate"&gt;
              &lt;span class="multiple_reactions_icons_container"&gt;
                  &lt;span class="crayons_icon_container"&gt;
                    &lt;img src="https://assets.dev.to/assets/sparkle-heart-5f9bee3767e18deb1bb725290cb151c25234768a0e9a2bd39370c382d02920cf.svg" width="18" height="18"&gt;
                  &lt;/span&gt;
              &lt;/span&gt;
              &lt;span class="aggregate_reactions_counter"&gt;1&lt;span class="hidden s:inline"&gt; reaction&lt;/span&gt;&lt;/span&gt;
            &lt;/div&gt;
          &lt;/a&gt;
            &lt;a href="https://dev.to/smiah/load-balancing-vs-load-shedding-vs-load-leveling-48ff#comments" class="crayons-btn crayons-btn--s crayons-btn--ghost crayons-btn--icon-left flex items-center"&gt;
              Comments


              &lt;span class="hidden s:inline"&gt;Add Comment&lt;/span&gt;
            &lt;/a&gt;
        &lt;/div&gt;
        &lt;div class="crayons-story__save"&gt;
          &lt;small class="crayons-story__tertiary fs-xs mr-2"&gt;
            2 min read
          &lt;/small&gt;
            
              &lt;span class="bm-initial"&gt;
                

              &lt;/span&gt;
              &lt;span class="bm-success"&gt;
                

              &lt;/span&gt;
            
        &lt;/div&gt;
      &lt;/div&gt;
    &lt;/div&gt;
  &lt;/div&gt;
&lt;/div&gt;

&lt;/div&gt;


</description>
      <category>softwareengineering</category>
      <category>distributedsystems</category>
      <category>highavailability</category>
    </item>
    <item>
      <title>What Is Database Partitioning?</title>
      <dc:creator>Miahlouge</dc:creator>
      <pubDate>Mon, 14 Apr 2025 05:05:40 +0000</pubDate>
      <link>https://dev.to/smiah/database-partitioning-29cc</link>
      <guid>https://dev.to/smiah/database-partitioning-29cc</guid>
      <description>&lt;p&gt;Partitioning is the process of dividing a large database table into smaller. Database partitioning can be broadly categorized into two types -&lt;/p&gt;

&lt;p&gt;𝗛𝗼𝗿𝗶𝘇𝗼𝗻𝘁𝗮𝗹 𝗣𝗮𝗿𝘁𝗶𝘁𝗶𝗼𝗻𝗶𝗻𝗴 - It divides large tables across multiple storage nodes based on region, such as East, West, and South.&lt;/p&gt;

&lt;p&gt;𝗩𝗲𝗿𝘁𝗶𝗰𝗮𝗹 𝗣𝗮𝗿𝘁𝗶𝘁𝗶𝗼𝗻𝗶𝗻𝗴 - It separates sensitive data from core data based on access patterns.&lt;/p&gt;

&lt;p&gt;𝗣𝗮𝗿𝘁𝗶𝘁𝗶𝗼𝗻𝗶𝗻𝗴 𝗞𝗲𝘆 𝗕𝗲𝗻𝗲𝗳𝗶𝘁𝘀&lt;br&gt;
→ Distributes data across multiple storage nodes for better scalability.&lt;br&gt;
→ Enhances data manageability by segmenting large datasets&lt;br&gt;
→ Enables parallel query execution, improving performance&lt;br&gt;
→ Optimizes physical data storage structure for efficient access&lt;/p&gt;

&lt;p&gt;𝗣𝗮𝗿𝘁𝗶𝘁𝗶𝗼𝗻𝗶𝗻𝗴 𝗗𝗶𝘀𝗮𝗱𝘃𝗮𝗻𝘁𝗮𝗴𝗲𝘀&lt;br&gt;
→ 𝗜𝗻𝗰𝗿𝗲𝗮𝘀𝗲𝗱 𝗰𝗼𝗺𝗽𝗹𝗲𝘅𝗶𝘁𝘆 in schema design and query logic&lt;br&gt;
→ 𝗜𝗺𝗽𝗿𝗼𝗽𝗲𝗿 𝗽𝗮𝗿𝘁𝗶𝘁𝗶𝗼𝗻𝗶𝗻𝗴 can cause data skews or hotspots&lt;br&gt;
→ 𝗖𝗿𝗼𝘀𝘀-𝗽𝗮𝗿𝘁𝗶𝘁𝗶𝗼𝗻 𝗾𝘂𝗲𝗿𝗶𝗲𝘀 may be slower&lt;br&gt;
→ 𝗠𝗮𝗶𝗻𝘁𝗮𝗶𝗻𝗶𝗻𝗴 𝗰𝗼𝗻𝘀𝗶𝘀𝘁𝗲𝗻𝗰𝘆 across partitions is harder&lt;/p&gt;

</description>
      <category>miahlouge</category>
      <category>database</category>
      <category>partitioning</category>
    </item>
    <item>
      <title>What is Database Indexing?</title>
      <dc:creator>Miahlouge</dc:creator>
      <pubDate>Mon, 14 Apr 2025 05:01:21 +0000</pubDate>
      <link>https://dev.to/smiah/what-is-indexing-34dc</link>
      <guid>https://dev.to/smiah/what-is-indexing-34dc</guid>
      <description>&lt;p&gt;Indexing is a database optimization technique that creates specialized lookup structures (B-Trees).&lt;/p&gt;

&lt;p&gt;𝗜𝗻𝗱𝗲𝘅𝗶𝗻𝗴 𝗞𝗲𝘆 𝗕𝗲𝗻𝗲𝗳𝗶𝘁𝘀&lt;br&gt;
→ Fasts data retrieval by reducing search time&lt;br&gt;
→ Enables efficient lookup structures without altering original data&lt;br&gt;
→ Keeps the underlying data intact, ensuring data consistency&lt;br&gt;
→ Optimizes query execution paths for faster access&lt;/p&gt;

&lt;p&gt;𝗜𝗻𝗱𝗲𝘅𝗶𝗻𝗴 𝗗𝗶𝘀𝗮𝗱𝘃𝗮𝗻𝘁𝗮𝗴𝗲𝘀&lt;br&gt;
→ Increases storage requirements due to additional data structures&lt;br&gt;
→ Slows down write operations (INSERT, UPDATE, DELETE)&lt;br&gt;
→ Over-indexing can hurt more than help&lt;/p&gt;

</description>
      <category>database</category>
      <category>indexing</category>
      <category>miahlouge</category>
    </item>
    <item>
      <title>Distributed Transactions: 2PC vs 3PC vs Saga</title>
      <dc:creator>Miahlouge</dc:creator>
      <pubDate>Sun, 13 Apr 2025 12:41:42 +0000</pubDate>
      <link>https://dev.to/smiah/distributed-transactions-2pc-vs-3pc-vs-saga-5c34</link>
      <guid>https://dev.to/smiah/distributed-transactions-2pc-vs-3pc-vs-saga-5c34</guid>
      <description>&lt;p&gt;It's a complex topic in itself. Sometimes even seasoned professionals misunderstand.&lt;/p&gt;

&lt;p&gt;▢ 𝟮𝗣𝗖 - atomic but blocking, commit or abort in two steps.&lt;br&gt;
▢ 𝟯𝗣𝗖 - splits commit into two, reduces blocking and handles partial failures.&lt;br&gt;
▢ 𝗦𝗮𝗴𝗮 - a sequence of local transactions that breaks a transaction into multiple steps.&lt;br&gt;
&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fwyul92nume59zqhn5qok.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fwyul92nume59zqhn5qok.png" alt="𝟮-𝗣𝗵𝗮𝘀𝗲 𝗖𝗼𝗺𝗺𝗶𝘁" width="800" height="800"&gt;&lt;/a&gt;&lt;br&gt;
𝗪𝗵𝗲𝗻 𝘁𝗼 𝘂𝘀𝗲 𝟮-𝗣𝗵𝗮𝘀𝗲 𝗖𝗼𝗺𝗺𝗶𝘁&lt;br&gt;
→ When strict consistency is needed, all participants commit or abort.&lt;br&gt;
→ For simple, low-latency systems with minimal crash risk.&lt;/p&gt;

&lt;p&gt;𝗘𝘅𝗮𝗺𝗽𝗹𝗲: 𝗕𝗮𝗻𝗸 𝗙𝘂𝗻𝗱 𝗧𝗿𝗮𝗻𝘀𝗳𝗲𝗿 𝗕𝗲𝘁𝘄𝗲𝗲𝗻 𝗔𝗰𝗰𝗼𝘂𝗻𝘁𝘀 𝗶𝗻 𝘁𝗵𝗲 𝗦𝗮𝗺𝗲 𝗕𝗮𝗻𝗸&lt;br&gt;
• Transfer involves debiting one account and crediting another.&lt;br&gt;
• If one fails, the entire transaction must rollback.&lt;br&gt;
• Atomicity is a must, and latency is acceptable.&lt;br&gt;
&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fnshugsqwobimlew0th1v.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fnshugsqwobimlew0th1v.png" alt="𝟯-𝗣𝗵𝗮𝘀𝗲 𝗖𝗼𝗺𝗺𝗶𝘁" width="800" height="800"&gt;&lt;/a&gt;&lt;br&gt;
𝗪𝗵𝗲𝗻 𝘁𝗼 𝘂𝘀𝗲 𝟯-𝗣𝗵𝗮𝘀𝗲 𝗖𝗼𝗺𝗺𝗶𝘁&lt;br&gt;
→ When minimizing blocking is key, and partial failures must be avoided.&lt;br&gt;
→ Where fault tolerance takes priority over message overhead and complexity.&lt;/p&gt;

&lt;p&gt;𝗘𝘅𝗮𝗺𝗽𝗹𝗲: 𝗖𝗿𝗼𝘀𝘀-𝗥𝗲𝗴𝗶𝗼𝗻 𝗟𝗲𝗱𝗴𝗲𝗿 𝗦𝘆𝗻𝗰𝗵𝗿𝗼𝗻𝗶𝘇𝗮𝘁𝗶𝗼𝗻&lt;br&gt;
Synchronizing transaction records between European and Asian data centers.&lt;br&gt;
• Each region prepares and pre-commits.&lt;br&gt;
• Final commit is sent when all regions are ready.&lt;br&gt;
• Handles network partition or coordinator crash more gracefully than 2PC.&lt;br&gt;
&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fszgckolrhakc2dmjl11k.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fszgckolrhakc2dmjl11k.png" alt="𝗦𝗮𝗴𝗮" width="800" height="800"&gt;&lt;/a&gt;&lt;br&gt;
𝗪𝗵𝗲𝗻 𝘁𝗼 𝘂𝘀𝗲 𝗦𝗮𝗴𝗮&lt;br&gt;
→ Performance matter more than strict consistency &lt;br&gt;
→ Long-running distributed transactions where full rollback isn't practical&lt;br&gt;
&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fxnnpim7ub511qwlps4kj.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fxnnpim7ub511qwlps4kj.png" alt="𝗦𝗮𝗴𝗮 𝗖𝗵𝗼𝗿𝗲𝗼𝗴𝗿𝗮𝗽𝗵𝘆" width="800" height="800"&gt;&lt;/a&gt;&lt;br&gt;
&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fxcxkulygletvnx3uczd7.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fxcxkulygletvnx3uczd7.png" alt="𝗦𝗮𝗴𝗮 𝗢𝗿𝗰𝗵𝗲𝘀𝘁𝗿𝗮𝘁𝗶𝗼𝗻" width="800" height="800"&gt;&lt;/a&gt;&lt;br&gt;
𝗘𝘅𝗮𝗺𝗽𝗹𝗲: 𝗜𝗻𝘁𝗲𝗿𝗻𝗮𝘁𝗶𝗼𝗻𝗮𝗹 𝗙𝘂𝗻𝗱 𝗧𝗿𝗮𝗻𝘀𝗳𝗲𝗿 (𝗦𝗪𝗜𝗙𝗧)&lt;br&gt;
Transferring funds from a bank in Germany to one in Singapore via SWIFT or similar clearing systems.&lt;br&gt;
• Debit sender → Local transaction &lt;br&gt;
• Notify intermediary → Local transaction&lt;br&gt;
• Credit receiver → Local transaction&lt;br&gt;
• If the final step fails, compensation (e.g., refund sender) is triggered.&lt;/p&gt;

</description>
      <category>distributedsystems</category>
      <category>distributedtransactions</category>
      <category>miahlouge</category>
    </item>
    <item>
      <title>Downstream Resiliency in Distributed System</title>
      <dc:creator>Miahlouge</dc:creator>
      <pubDate>Sun, 13 Apr 2025 01:23:47 +0000</pubDate>
      <link>https://dev.to/smiah/downstream-resiliency-of-distributed-system-12ml</link>
      <guid>https://dev.to/smiah/downstream-resiliency-of-distributed-system-12ml</guid>
      <description>&lt;p&gt;Downstream &lt;a href="https://dev.to/smiah/what-is-resiliency-engineering-3bjc"&gt;resiliency&lt;/a&gt; ensures that a component can continue to function correctly even if the components it relies on experience issues.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F8msg50ua0bi8asj348ym.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F8msg50ua0bi8asj348ym.jpg" alt="Downstream Resiliency" width="800" height="427"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;𝗧𝗶𝗺𝗲𝗼𝘂𝘁&lt;/strong&gt;&lt;br&gt;
Before we start, let’s answer the simple question: "Why timeout?".&lt;/p&gt;

&lt;p&gt;A successful response, even if it takes time, is better than a timeout error. Hmm… not always, it depends.&lt;/p&gt;

&lt;p&gt;When a network call is made, it’s best practice to configure a timeout. If the call is made without a timeout, there is a chance it will never return. Network calls that don’t return lead to resource leaks.&lt;/p&gt;

&lt;p&gt;Modern HTTP clients such as Java, .NET etc do a better job and usually, come with default timeouts. For example, .NET Core HttpClient has a default timeout of 100 seconds. However, some HTTP clients, like Go, do not have a default timeout for network requests. In such cases, it is a best practice to explicitly configure a timeout.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;How to configure timeout and not breach the SLA?
&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fwxhmbhjsork89u80ml8l.jpg" alt="SLA" width="800" height="153"&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Option 1&lt;/strong&gt;: Share Your Time Budget&lt;br&gt;
Divide your SLA between services, e.g., 500ms for Order Service and 500ms for Payment Service. This prevents SLA breaches but may cause false positive timeouts.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Option 2&lt;/strong&gt;: Use a TimeLimiter&lt;br&gt;
Wrap calls in a time limiter, setting a shared max timeout (e.g., 1s) while allowing flexibility (e.g., 700ms per service) to handle varying response times efficiently.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;How do we determine a good timeout duration?
One way is to base it on the desired false timeout rate. For example, if 0.1% of downstream requests can timeout, configure the timeout based on the 99.9th percentile of response time.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Good monitoring tracks the entire lifecycle of a network call. Measure integration points carefully. This helps with debugging production issues.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;𝗥𝗲𝘁𝗿𝘆 𝗦𝘁𝗿𝗮𝘁𝗲𝗴𝗶𝗲𝘀&lt;/strong&gt;&lt;br&gt;
When a network request fails or times out, the client has two options: fail fast or retry the request. If the failure is temporary, retrying with backoff can resolve the issue. However, if the downstream service is overwhelmed, immediate retries can worsen the problem. To prevent this, retries should be delayed with progressively increasing intervals until either a maximum retry limit is reached or sufficient time has passed.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fn1le6l80ll4iisazuw4t.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fn1le6l80ll4iisazuw4t.jpg" alt="𝗥𝗲𝘁𝗿𝘆 𝗦𝘁𝗿𝗮𝘁𝗲𝗴𝗶𝗲𝘀" width="800" height="442"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;This approach incorporates techniques such as Exponential Backoff, Cap, Random Jitter, and Retry Queue, ensuring the system remains resilient while avoiding additional strain on the downstream service.&lt;/p&gt;

&lt;p&gt;𝗘𝘅𝗽𝗼𝗻𝗲𝗻𝘁𝗶𝗮𝗹 𝗕𝗮𝗰𝗸𝗼𝗳𝗳&lt;br&gt;
Exponential backoff is a technique where the retry delay increases exponentially after each failure.&lt;/p&gt;

&lt;p&gt;backoff = backOffMin * (backOffFactor ^ attempt)&lt;/p&gt;

&lt;p&gt;For an initial backoff of 2 seconds and a backoff factor of 2:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;1st retry: 2×2^1=2 seconds&lt;/li&gt;
&lt;li&gt;2nd retry: 2×2^2=4 seconds&lt;/li&gt;
&lt;li&gt;3rd retry: 2×2^3=8 seconds&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;This means that after each failed attempt, the time to wait before retrying increases exponentially. Exponential backoff can cause multiple clients to retry simultaneously, leading to load spikes on the downstream service. To solve this, we can limits the maximum retry delay to prevent excessive waiting times.&lt;/p&gt;

&lt;p&gt;𝗖𝗮𝗽𝗽𝗲𝗱 𝗘𝘅𝗽𝗼𝗻𝗲𝗻𝘁𝗶𝗮𝗹 𝗕𝗮𝗰𝗸𝗼𝗳𝗳&lt;br&gt;
Capped exponential backoff builds upon exponential backoff by introducing a maximum limit (cap) for the retry delay. This prevents the delay from growing indefinitely while ensuring retries happen within a reasonable timeframe.&lt;/p&gt;

&lt;p&gt;backoff = backOffMin * (backOffFactor ^ attempt)&lt;/p&gt;

&lt;p&gt;However, the cap limits the maximum delay. For an initial backoff of 2 seconds, a backoff factor of 2, and a cap of 8 seconds:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;1st retry: 2×2^1=2 seconds&lt;/li&gt;
&lt;li&gt;2nd retry: 2×2^2=4 seconds&lt;/li&gt;
&lt;li&gt;3rd retry: min⁡(2×2^3, 8)=8 seconds (capped)&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Capping the delay ensures retries don't extend indefinitely, striking a balance between efficiency and resilience.&lt;/p&gt;

&lt;p&gt;𝗥𝗮𝗻𝗱𝗼𝗺 𝗝𝗶𝘁𝘁𝗲𝗿 𝘄𝗶𝘁𝗵 𝗖𝗮𝗽𝗽𝗲𝗱 𝗘𝘅𝗽𝗼𝗻𝗲𝗻𝘁𝗶𝗮𝗹 𝗕𝗮𝗰𝗸𝗼𝗳𝗳&lt;br&gt;
This method enhances capped exponential backoff by adding randomness to the delay, preventing synchronized retries and reducing the risk of traffic spikes. Random jitter spreads out retry attempts over time, improving system stability.&lt;/p&gt;

&lt;p&gt;delay = random(0, min(cap, backOffMin * (backOffFactor ^ attempt)))&lt;/p&gt;

&lt;p&gt;For an initial backoff of 2 seconds, a backoff factor of 2, and a cap of 8 seconds:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;1st retry: Random value between 0 and 2×2^1=4 seconds&lt;/li&gt;
&lt;li&gt;2nd retry: Random value between 0 and 2×2^2=8 seconds&lt;/li&gt;
&lt;li&gt;3rd retry: Random value between 0 and 2×2^3=8 seconds (capped)&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The addition of randomness avoids "retry storms," where multiple clients retry at the same time, and spreads out load more evenly to protect the downstream service.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;𝗥𝗲𝘁𝗿𝘆 𝗔𝗺𝗽𝗹𝗶𝗳𝗶𝗰𝗮𝘁𝗶𝗼𝗻&lt;/strong&gt;&lt;br&gt;
Suppose a user request goes through a chain: the client calls Your Awesome Service, which calls Order Service, which then calls Payment Service. If the request from Order Service to Payment Service fails, should Order Service retry? Retrying could delay Your Awesome Service’s response, risking its timeout. If Your Awesome Service retries, the client might timeout too, amplifying retries across the chain. This can overload deeper services like Payment Service. For long chains, retrying at one level and failing fast elsewhere is often better.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fmoy1qtz7s52euiw55w7x.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fmoy1qtz7s52euiw55w7x.jpg" alt="𝗥𝗲𝘁𝗿𝘆 𝗔𝗺𝗽𝗹𝗶𝗳𝗶𝗰𝗮𝘁𝗶𝗼𝗻" width="800" height="127"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;𝗙𝗮𝗹𝗹𝗯𝗮𝗰𝗸 𝗣𝗹𝗮𝗻&lt;/strong&gt;&lt;br&gt;
Fallback plans act as a backup when retries fail. Imagine a courier who can’t deliver your package after trying once. Instead of repeatedly attempting the same thing, they switch to a "Plan B"—like leaving the package in front of door, or at a nearby kiosk or post office. Similarly, in systems, this means using an alternative option, such as cached data or another provider, when the primary service isn’t working. The system then notifies users or logs the change, just like the courier leaving you a note or sending a text. This way, resources aren't wasted on endless retries, and the system remains resilient by relying on a practical backup solution.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fc4100obxhvp7xn6t9ok7.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fc4100obxhvp7xn6t9ok7.jpg" alt="𝗙𝗮𝗹𝗹𝗯𝗮𝗰𝗸 𝗣𝗹𝗮𝗻" width="800" height="350"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;𝗖𝗶𝗿𝗰𝘂𝗶𝘁 𝗕𝗿𝗲𝗮𝗸𝗲𝗿𝘀&lt;/strong&gt;&lt;br&gt;
When a downstream service fails persistently, retries slow down the caller and can spread slowness system-wide. A circuit breaker detects such failures, blocks requests to avoid slowdowns, and fails fast instead. It has three states: closed (passes calls, tracks failures), open (blocks calls), and half-open (tests recovery).&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F0rs2vk7tbeqrovtz3n6o.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F0rs2vk7tbeqrovtz3n6o.jpg" alt="𝗖𝗶𝗿𝗰𝘂𝗶𝘁 𝗕𝗿𝗲𝗮𝗸𝗲𝗿𝘀" width="800" height="541"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;If failures exceed a threshold, it opens; after a delay, it tests in half-open mode. Success closes it; failure reopens it. This protects the system, enabling graceful degradation for non-critical dependencies. Timing and thresholds depend on context and past data.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;𝗖𝗼𝗻𝗰𝗹𝘂𝘀𝗶𝗼𝗻&lt;/strong&gt;&lt;br&gt;
Downstream resiliency is a critical aspect of Resiliency Engineering, ensuring components can adapt and recover gracefully from failures in dependent systems. By implementing effective strategies, systems can remain robust and reliable, even in the face of unforeseen disruptions.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;𝗜𝗻𝘀𝗽𝗶𝗿𝗮𝘁𝗶𝗼𝗻𝘀 𝗮𝗻𝗱 𝗥𝗲𝗳𝗲𝗿𝗲𝗻𝗰𝗲𝘀&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://www.smiah.wiki/p/downstream-resiliency-in-distributed-systems" rel="noopener noreferrer"&gt;𝗗𝗼𝘄𝗻𝘀𝘁𝗿𝗲𝗮𝗺 𝗥𝗲𝘀𝗶𝗹𝗶𝗲𝗻𝗰𝘆&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://engineering.zalando.com/posts/2023/07/all-you-need-to-know-about-timeouts.html" rel="noopener noreferrer"&gt;All you need to know about timeouts&lt;/a&gt;, Zalando Engineering Blog&lt;/li&gt;
&lt;li&gt;Understanding Distributed Systems by Roberto Vitillo.&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>distributedsystems</category>
      <category>performance</category>
      <category>microservices</category>
      <category>miahlouge</category>
    </item>
    <item>
      <title>Resiliency in Distributed Systems</title>
      <dc:creator>Miahlouge</dc:creator>
      <pubDate>Sun, 13 Apr 2025 00:49:43 +0000</pubDate>
      <link>https://dev.to/smiah/what-is-resiliency-engineering-3bjc</link>
      <guid>https://dev.to/smiah/what-is-resiliency-engineering-3bjc</guid>
      <description>&lt;p&gt;Resiliency Engineering is the practice of designing and building systems to achieve resiliency. Ensuring they can handle failures, adapt to disruptions, and recover gracefully without major downtime.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Anything that can go wrong will go wrong.&lt;br&gt;
Murphy’s Law&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;𝗪𝗵𝗮𝘁 𝗶𝘀 𝗥𝗲𝘀𝗶𝗹𝗶𝗲𝗻𝗰𝘆?&lt;br&gt;
Before understanding Resiliency Engineering, it is necessary to understand what Resiliency is. Resiliency is an outcome, not a practice. It is the ability of a system to handle failures, adapt to disruptions, and maintain functionality under pressure.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fg6hapwatcddaqcpsnqre.jpeg" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fg6hapwatcddaqcpsnqre.jpeg" alt="𝗥𝗲𝘀𝗶𝗹𝗶𝗲𝗻𝗰𝘆 𝗘𝗻𝗴𝗶𝗻𝗲𝗲𝗿𝗶𝗻𝗴" width="800" height="420"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;𝗪𝗵𝗮𝘁 𝗶𝘀 𝗥𝗲𝘀𝗶𝗹𝗶𝗲𝗻𝗰𝘆 𝗘𝗻𝗴𝗶𝗻𝗲𝗲𝗿𝗶𝗻𝗴?&lt;br&gt;
Resiliency Engineering is the practice of designing and building systems to achieve resiliency. It involves strategies like fault tolerance, redundancy, self-healing mechanisms, and failure recovery to ensure systems remain stable and reliable even in unpredictable conditions.&lt;/p&gt;

&lt;p&gt;𝗧𝘆𝗽𝗲𝘀 𝗼𝗳 𝗥𝗲𝘀𝗶𝗹𝗶𝗲𝗻𝗰𝘆 𝗘𝗻𝗴𝗶𝗻𝗲𝗲𝗿𝗶𝗻𝗴&lt;br&gt;
Resiliency engineering can be broadly categorized into three types: proactive resiliency, reactive resiliency, adaptive resiliency.&lt;/p&gt;

&lt;p&gt;𝗣𝗿𝗼𝗮𝗰𝘁𝗶𝘃𝗲 𝗥𝗲𝘀𝗶𝗹𝗶𝗲𝗻𝗰𝘆&lt;br&gt;
Proactive resiliency prevents failures before they happen, keeping systems stable and reliable. It ensures smooth operations by distributing traffic, limiting overload, and maintaining backups. All are called Upstream Resiliency.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Load Balancing, Load Shedding &amp;amp; Load Leveling – Distribute traffic efficiently and prevent overload.&lt;/li&gt;
&lt;li&gt;Throttling &amp;amp; Rate Limiting – Control excessive requests to maintain system stability.&lt;/li&gt;
&lt;li&gt;Chaos Engineering – Inject controlled failures to test and improve system resilience.&lt;/li&gt;
&lt;li&gt;Redundancy &amp;amp; Replication – Ensure backup systems are active to prevent downtime.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;𝗥𝗲𝗮𝗰𝘁𝗶𝘃𝗲 𝗥𝗲𝘀𝗶𝗹𝗶𝗲𝗻𝗰𝘆&lt;br&gt;
Reactive Resiliency ensures systems recover quickly with minimal impact when failures occur. All are called Downstream Resiliency.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Timeout - Setting a timeout ensures operations don’t hang indefinitely.&lt;/li&gt;
&lt;li&gt;Retry Strategies &amp;amp; Retry Amplification – Reattempt failed operations with increasing delays to reduce strain and avoid simultaneous retries.&lt;/li&gt;
&lt;li&gt;Fallback Plan &amp;amp; Failover Mechanisms – Offering alternative flows and switch to backup systems seamlessly.&lt;/li&gt;
&lt;li&gt;Circuit Breakers – Prevent repeated failures from overwhelming services while avoiding unnecessary retries.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;𝗔𝗱𝗮𝗽𝘁𝗶𝘃𝗲 𝗥𝗲𝘀𝗶𝗹𝗶𝗲𝗻𝗰𝘆&lt;br&gt;
Adaptive Resiliency bridges Upstream and Downstream Resiliency by learning from failures and continuously improving system resilience.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Observability &amp;amp; Monitoring – Track failures in real time for better insights.&lt;/li&gt;
&lt;li&gt;Chaos Engineering – Identify weaknesses and enhance system robustness.&lt;/li&gt;
&lt;li&gt;Automated Scaling – Dynamically adjust resources based on demand.&lt;/li&gt;
&lt;li&gt;Machine Learning &amp;amp; AI – Predict and prevent failures before they happen.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;𝗖𝗼𝗿𝗲 𝗖𝗼𝗻𝗰𝗲𝗽𝘁𝘀 𝗼𝗳 𝗥𝗲𝘀𝗶𝗹𝗶𝗲𝗻𝗰𝘆 𝗘𝗻𝗴𝗶𝗻𝗲𝗲𝗿𝗶𝗻𝗴&lt;br&gt;
Building resilient systems requires key principles that ensure systems can withstand failures, adapt to disruptions, and recover quickly. These core concepts provide the foundation for designing resilient architectures.&lt;/p&gt;

&lt;blockquote&gt;
&lt;ul&gt;
&lt;li&gt;To engineer resiliency, systems must be built with key principles:&lt;/li&gt;
&lt;li&gt;Fault Tolerance – The ability to operate even when components fail&lt;/li&gt;
&lt;li&gt;Redundancy – Backup systems that take over in case of failure.&lt;/li&gt;
&lt;li&gt;Failover &amp;amp; Recovery – Mechanisms to switch to a working state quickly.&lt;/li&gt;
&lt;li&gt;Observability &amp;amp; Monitoring – Real-time insights into system health.&lt;/li&gt;
&lt;li&gt;Chaos Testing – Simulating failures to test system robustness.&lt;/li&gt;
&lt;/ul&gt;
&lt;/blockquote&gt;

&lt;p&gt;𝗖𝗼𝗻𝗰𝗹𝘂𝘀𝗶𝗼𝗻&lt;br&gt;
A truly resilient system integrates all three—proactively preventing failures, reacting gracefully when they occur, and continuously adapting to become stronger over time.&lt;/p&gt;

&lt;p&gt;𝗜𝗻𝘀𝗽𝗶𝗿𝗮𝘁𝗶𝗼𝗻𝘀 𝗮𝗻𝗱 𝗥𝗲𝗳𝗲𝗿𝗲𝗻𝗰𝗲𝘀&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://www.smiah.wiki/p/what-is-resilency-engineering" rel="noopener noreferrer"&gt;What is resiliency engineering?&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://youtu.be/td4AIKYr16Q" rel="noopener noreferrer"&gt;Resiliency Engineering myth-busting&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>distributedsystems</category>
      <category>microservices</category>
      <category>miahlouge</category>
    </item>
    <item>
      <title>Database Optimization: Partitioning vs Indexing</title>
      <dc:creator>Miahlouge</dc:creator>
      <pubDate>Sun, 13 Apr 2025 00:33:36 +0000</pubDate>
      <link>https://dev.to/smiah/partitioning-vs-indexing-ddd</link>
      <guid>https://dev.to/smiah/partitioning-vs-indexing-ddd</guid>
      <description>&lt;p&gt;𝗣𝗮𝗿𝘁𝗶𝘁𝗶𝗼𝗻𝗶𝗻𝗴 - Horizontal partitioning divides large tables across multiple storage nodes based on region, such as East, West, and South.&lt;/p&gt;

&lt;p&gt;Vertical partitioning, on the other hand, separates sensitive data from core data based on access patterns.&lt;br&gt;
&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F3jafnjuxc9ui0rp3yr8m.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F3jafnjuxc9ui0rp3yr8m.jpg" alt="Partitioning" width="800" height="450"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;𝗜𝗻𝗱𝗲𝘅𝗶𝗻𝗴 - Creates specialized lookup structures (B-Trees)&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Faw0922lavnab9ofpgev9.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Faw0922lavnab9ofpgev9.jpg" alt="𝗜𝗻𝗱𝗲𝘅𝗶𝗻𝗴" width="800" height="450"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;𝗣𝗮𝗿𝘁𝗶𝘁𝗶𝗼𝗻𝗶𝗻𝗴 𝗞𝗲𝘆 𝗕𝗲𝗻𝗲𝗳𝗶𝘁𝘀&lt;br&gt;
→ Distributes data across multiple storage nodes for better scalability.&lt;br&gt;
→ Enhances data manageability by segmenting large datasets&lt;br&gt;
→ Enables parallel query execution, improving performance&lt;br&gt;
→ Optimizes physical data storage structure for efficient access&lt;/p&gt;

&lt;p&gt;𝗜𝗻𝗱𝗲𝘅𝗶𝗻𝗴 𝗞𝗲𝘆 𝗕𝗲𝗻𝗲𝗳𝗶𝘁𝘀&lt;br&gt;
→ Fasts data retrieval by reducing search time&lt;br&gt;
→ Enables efficient lookup structures without altering original data&lt;br&gt;
→ Keeps the underlying data intact, ensuring data consistency&lt;br&gt;
→ Optimizes query execution paths for faster access&lt;/p&gt;

</description>
      <category>database</category>
      <category>partitioning</category>
      <category>indexing</category>
      <category>miahlouge</category>
    </item>
    <item>
      <title>Streaming vs Queuing: What Happens If You Choose Wrong?</title>
      <dc:creator>Miahlouge</dc:creator>
      <pubDate>Sat, 12 Apr 2025 20:56:12 +0000</pubDate>
      <link>https://dev.to/smiah/streaming-vs-queuing-what-happens-if-you-choose-wrong-2h6e</link>
      <guid>https://dev.to/smiah/streaming-vs-queuing-what-happens-if-you-choose-wrong-2h6e</guid>
      <description>&lt;p&gt;𝗦𝘁𝗿𝗲𝗮𝗺𝗶𝗻𝗴 - sequential movements, processed in real-time.&lt;br&gt;
𝗤𝘂𝗲𝘂𝗶𝗻𝗴 - stored in a queue, processed sequentially.&lt;/p&gt;

&lt;p&gt;Choosing between streaming and queuing isn’t just about picking Kafka over RabbitMQ. It’s about making an architectural decision that will define how your system scales, evolves, and handles data over time.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F9g2ht1iw4b2twmhpx0hp.jpeg" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F9g2ht1iw4b2twmhpx0hp.jpeg" alt="Streaming vs Queuing" width="800" height="523"&gt;&lt;/a&gt; &lt;/p&gt;

&lt;p&gt;Pick the wrong one, and you’ll feel the consequences for years.&lt;/p&gt;

&lt;p&gt;𝗪𝗵𝗲𝗻 𝗧𝗼 𝗖𝗵𝗼𝗼𝘀𝗲 𝗦𝗧𝗥𝗘𝗔𝗠𝗜𝗡𝗚:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;You need historical data replay (e.g., debugging or analytics).&lt;/li&gt;
&lt;li&gt;Your system requires event order guarantees (e.g., processing transactions sequentially).&lt;/li&gt;
&lt;li&gt;Multiple consumers need to read the same event independently.&lt;/li&gt;
&lt;li&gt;You’re handling high-throughput data flows that need efficient processing.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;𝗪𝗵𝗲𝗻 𝗧𝗼 𝗖𝗵𝗼𝗼𝘀𝗲 𝗤𝗨𝗘𝗨𝗜𝗡𝗚:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;You need guaranteed task completion (e.g., order processing or background jobs).&lt;/li&gt;
&lt;li&gt;Each task must be processed by only one consumer (e.g., no need for data replay).&lt;/li&gt;
&lt;li&gt;The message should be consumed once and discarded after processing.&lt;/li&gt;
&lt;li&gt;Built-in retries and dead-letter queues offer automatic failure handling.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;𝗖𝗼𝗺𝗯𝗶𝗻𝗲 𝗕𝗼𝘁𝗵: 𝗠𝗼𝘀𝘁 𝗦𝘂𝗰𝗰𝗲𝘀𝘀𝗳𝘂𝗹 𝗔𝗿𝗰𝗵𝗶𝘁𝗲𝗰𝘁𝘂𝗿𝗲𝘀 𝗗𝗼&lt;br&gt;
The most powerful systems leverage both—streaming for real-time processing and queuing for task completion. An example might be:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Real-time tracking systems (using streaming for events like user activity or sensor data).&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Task-based systems (using queuing to ensure reliable processing, such as background jobs or transactional workflows).&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;𝗞𝗲𝘆 𝗥𝗲𝗮𝘀𝗼𝗻𝘀 𝗳𝗼𝗿 𝗠𝗶𝘀𝘂𝘀𝗲&lt;br&gt;
 → Events ≠ Tasks – Queues handle tasks (e.g., payments), while streams handle continuous data (e.g., market prices).&lt;/p&gt;

&lt;p&gt;→ Latency Matters – Queues add delays; streams process in real-time.&lt;/p&gt;

&lt;p&gt;→ No Replay – Queues discard messages; streams allow reprocessing.&lt;/p&gt;

&lt;p&gt;→Tooling Bias – Teams stick to familiar queues instead of streaming solutions like Kafka or Pulsar.&lt;/p&gt;

&lt;p&gt;This awesome diagram by &lt;a class="mentioned-user" href="https://dev.to/boyney123"&gt;@boyney123&lt;/a&gt;&lt;/p&gt;

</description>
      <category>streaming</category>
      <category>queuing</category>
      <category>eventdriven</category>
      <category>miahlouge</category>
    </item>
    <item>
      <title>Load Balancing vs Load Shedding vs Load Leveling</title>
      <dc:creator>Miahlouge</dc:creator>
      <pubDate>Sat, 12 Apr 2025 20:42:18 +0000</pubDate>
      <link>https://dev.to/smiah/load-balancing-vs-load-shedding-vs-load-leveling-48ff</link>
      <guid>https://dev.to/smiah/load-balancing-vs-load-shedding-vs-load-leveling-48ff</guid>
      <description>&lt;p&gt;𝗟𝗼𝗮𝗱 𝗕𝗮𝗹𝗮𝗻𝗰𝗶𝗻𝗴 – spreads incoming traffic across nodes to avoid bottlenecks.&lt;br&gt;
𝗟𝗼𝗮𝗱 𝗟𝗲𝘃𝗲𝗹𝗶𝗻𝗴 – smooths out spikes by queuing work for later processing.&lt;br&gt;
𝗟𝗼𝗮𝗱 𝗦𝗵𝗲𝗱𝗱𝗶𝗻𝗴 – drops non-critical requests to keep the core alive.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fjt5gimsfr0a89gft1nmq.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fjt5gimsfr0a89gft1nmq.png" alt="𝗟𝗼𝗮𝗱 𝗕𝗮𝗹𝗮𝗻𝗰𝗶𝗻𝗴 𝘃𝘀 𝗟𝗼𝗮𝗱 𝗦𝗵𝗲𝗱𝗱𝗶𝗻𝗴 𝘃𝘀 𝗟𝗼𝗮𝗱 𝗟𝗲𝘃𝗲𝗹𝗶𝗻𝗴" width="800" height="800"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Pick the wrong one, and you’re either wasting resources or crashing hard.&lt;/p&gt;

&lt;p&gt;𝗪𝗵𝗲𝗻 𝗧𝗼 𝗨𝘀𝗲 𝗟𝗢𝗔𝗗 𝗕𝗔𝗟𝗔𝗡𝗖𝗜𝗡𝗚&lt;br&gt;
→ Evenly distribute requests to ensure consistent response times.&lt;br&gt;
→ Scale horizontally during peak hours (e.g. market open/close).&lt;br&gt;
→ Prevent single points of failure with smart routing.&lt;/p&gt;

&lt;p&gt;Distributes traffic across servers to prevent overload and keep performance steady. Smart routing avoids bottlenecks and single points of failure. Works best when resources are healthy and scalable.&lt;/p&gt;

&lt;p&gt;𝗪𝗵𝗲𝗻 𝗧𝗼 𝗨𝘀𝗲 𝗟𝗢𝗔𝗗 𝗟𝗘𝗩𝗘𝗟𝗜𝗡𝗚&lt;br&gt;
→ Request peaks that come in waves? Buffer them.&lt;br&gt;
→ Use queues to decouple services (e.g., order matching from settlement).&lt;br&gt;
→ Works when a little delay is acceptable for long-term system health.&lt;/p&gt;

&lt;p&gt;A messaging channel is set up between clients and the service. This channel helps manage the flow for requests, allowing the service to handle them at its own pace. But beware of queue growth and latency creep.&lt;/p&gt;

&lt;p&gt;𝗪𝗵𝗲𝗻 𝗧𝗼 𝗨𝘀𝗲 𝗟𝗢𝗔𝗗 𝗦𝗛𝗘𝗗𝗗𝗜𝗡𝗚&lt;br&gt;
→ Market crash? Order spike? Can't handle everything?&lt;br&gt;
→ Prioritize order execution over non-critical analytics or notifications.&lt;br&gt;
→ Drop 20% of traffic if it means saving the core 80%.&lt;/p&gt;

&lt;p&gt;A server can become overwhelmed with requests, leading to slow performance or ever unavailability. To manage this, it can reject excess requests when it reaches its capacity. Better to shed load than go down completely.&lt;/p&gt;

&lt;p&gt;𝗪𝗵𝗲𝗿𝗲 𝗜𝘁 𝗔𝗹𝗹 𝗖𝗼𝗺𝗲𝘀 𝗧𝗼𝗴𝗲𝘁𝗵𝗲𝗿&lt;br&gt;
In a stock exchange system:&lt;br&gt;
 • Balance incoming traffic to keep nodes healthy.&lt;br&gt;
 • Shed non-critical updates during volatile spikes.&lt;br&gt;
 • Level settlement processing using queues to avoid crash.&lt;/p&gt;

&lt;p&gt;𝗪𝗵𝗲𝗿𝗲 𝗧𝗲𝗮𝗺𝘀 𝗢𝗳𝘁𝗲𝗻 𝗚𝗲𝘁 𝗜𝘁 𝗪𝗿𝗼𝗻𝗴&lt;br&gt;
 • Relying only on balancing—when all nodes are overloaded, it fails.&lt;br&gt;
 • Over-shedding—leads to lost revenue and frustrated users.&lt;br&gt;
 • Leveling without limits—queues grow endlessly, latency explodes.&lt;/p&gt;

&lt;p&gt;Load isn’t the problem. Mismanaging it is.&lt;/p&gt;

</description>
      <category>softwareengineering</category>
      <category>distributedsystems</category>
      <category>highavailability</category>
      <category>miahlouge</category>
    </item>
  </channel>
</rss>
