π Day 6: System Design + DSA Journey
Hello, Iβm continuing my journey of daily learning, focusing on System Design concepts (via the roadmap.sh System Design Roadmap) and then tackling DSA challenges on LeetCode. This is DAY 6! π―
π System Design: Availability Patterns
Todayβs concept was all about Availability Patterns β techniques to keep systems resilient and online even when components fail. These patterns ensure that services stay responsive for users, minimizing downtime and failures.
Hereβs a breakdown of the most important ones π
π 1. Redundancy
- Multiple instances of services running at once.
- Active/Passive (Failover): One active, one standby.
- Active/Active: All active, load balanced.
- N+1 Redundancy: Extra capacity for safety.
π Considerations: monitoring, failover time, data consistency.
π 2. Replication
- Keep multiple copies of data across servers.
- Synchronous: Strong consistency but higher latency.
- Asynchronous: Faster but may show stale data.
β‘ 3. Failover
- Automatic switchover to a backup service when the primary fails.
- Key concerns: split-brain scenarios, automated vs manual, regular testing.
π 4. Load Balancing
- Distribute requests across multiple servers.
- Algorithms: round robin, least connections, IP hash.
- Helps with both availability and performance.
π‘ 5. Circuit Breaker
- Prevent cascading failures by blocking traffic to unhealthy services.
- States: Closed β Open β Half-Open.
- Improves resilience and allows graceful recovery.
π 6. Retry Mechanisms
- Handle transient failures (like network hiccups).
- Use exponential backoff or jitter instead of hammering retries.
- Ensure retried operations are idempotent.
π¦ 7. Rate Limiting
- Control request flow to avoid overload.
- Techniques: token bucket, leaky bucket.
- Protects from abuse, DoS attacks, or resource exhaustion.
β‘ 8. Caching
- Store frequently accessed data in fast storage.
- Types: client-side, server-side, CDN.
- Watch out for cache invalidation and eviction strategies.
π¬ 9. Queues
- Decouple producers and consumers.
- Boosts availability and scalability.
- Tools: RabbitMQ, Kafka, Amazon SQS.
π 10. Database Sharding
- Split a large database into smaller shards.
- Improves performance and availability.
- Must choose the right sharding key and handle cross-shard queries.
π My Thoughts
Availability patterns are like the toolbox of resilience. Each comes with trade-offs (latency vs consistency, performance vs cost), but together they allow us to build systems that donβt just work β they survive real-world failures.
π» DSA Challenge: Roman to Integer
Todayβs DSA problem was the natural reverse of yesterdayβs challenge: 13. Roman to Integer.
β³ Time spent: ~2+ hours (a bit sidetracked but rewarding).
π Understanding the Problem
- Map each Roman numeral to its value.
- Traverse string left to right.
- If current numeral is smaller than the next, subtract it.
- Otherwise, add it.
π¨βπ» Code Snippet
class Solution:
def romanToInt(self, s: str) -> int:
roman_map = {
'I': 1, 'V': 5, 'X': 10,
'L': 50, 'C': 100,
'D': 500, 'M': 1000
}
total = 0
i = 0
while i < len(s):
# If smaller than next, subtract
if i + 1 < len(s) and roman_map[s[i]] < roman_map[s[i + 1]]:
total += roman_map[s[i + 1]] - roman_map[s[i]]
i += 2
else:
total += roman_map[s[i]]
i += 1
return total
β¨ Key Takeaways
- Using a dictionary lookup kept things clean.
- A while loop worked best for checking current + next characters.
- Simplicity beat clever one-liners β easy to read, easy to debug.
π Final Thoughts
Day 6 was a reminder that patterns matter.
- On the System Design side, availability patterns showed me how critical redundancy, failover, and load balancing are in real-world systems.
- On the DSA side, Roman numeral problems highlighted the beauty of simple mapping + conditional logic.
Each day is sharpening my problem-solving muscles and deepening my system design intuition. πͺ
π€ Letβs Connect!
π Six days in a row! Iβm proud of the streak β but I want these posts to spark more learning and discussion.
π If youβve been reading along, Iβd love your engagement:
- Which availability pattern have you implemented in your work?
- Do you prefer Roman β Integer or Integer β Roman problems?
- Or just drop a β‘ to cheer on the streak and keep the motivation alive!
Your comments, shares, and reactions help shape this journey and keep me pushing forward π.
Top comments (0)