Day 4 of Building System Design in Public ๐Ÿš€
โ–ฒ 0 r/midleveldeveloper+1 crossposts

Day 4 of Building System Design in Public ๐Ÿš€

​

Today I implemented a Fixed Window Rate Limiter using Java, Spring Boot, and Redis.

What I learned:

- โœ… How Fixed Window rate limiting works

- โœ… Why it's simple and fast

- โœ… The boundary problem (traffic spikes at window edges)

- โœ… When to use Sliding Window, Token Bucket, and Leaky Bucket instead

Building these concepts from scratch has helped me understand the trade-offs much better than just reading about them.

I'm documenting my journey one topic at a time. Tomorrow I'll be implementing the Sliding Window Counter algorithm.

Feedback is always welcome. What rate-limiting algorithm do you use most in production, and why?

u/FlatwormAdmirable610 โ€” 18 days ago
โ–ฒ 3 r/midleveldeveloper+3 crossposts

๐Ÿšฆ Day 3 of Building System Design Projects in Public

Today's milestone: Implemented the Fixed Window Rate Limiter using Java + Spring Boot.

A simple algorithm, but one of the core building blocks behind protecting APIs from abuse.

What it does

โœ… Tracks requests within a fixed time window
โœ… Allows requests until the configured limit is reached
โœ… Returns HTTP 429 (Too Many Requests) when the limit is exceeded
โœ… Automatically resets the counter when the next time window begins

The screenshots show:

  • Spring Boot API (/api/ping)
  • Custom rate-limiting filter
  • Postman returning 429 Too Many Requests after exceeding the configured limit

Every rate-limiting algorithm solves the same problem differently. Over the next few days, I'll implement and compare:

  • โœ… Fixed Window
  • โณ Sliding Window Log
  • โณ Sliding Window Counter
  • โณ Token Bucket
  • โณ Leaky Bucket
  • โณ Distributed Rate Limiter using Redis

The goal isn't just to know these algorithmsโ€”it's to understand when to use each one and the trade-offs they make.

Which rate-limiting algorithm have you used in production, and why? ๐Ÿ‘‡

#SystemDesign #Java #SpringBoot #BackendEngineering #RateLimiter #LearningInPublic #DistributedSystems #SoftwareEngineering

u/FlatwormAdmirable610 โ€” 19 days ago
โ–ฒ 6 r/midleveldeveloper+3 crossposts

Learning System Design in Public โ€“ Day 2: Designing a Distributed Rate Limiter. Feedback Welcome!

I genuinely never get bored of learning system design.

Instead of passively watching videos, I've started designing systems myself from scratch. It forces me to think about trade-offs instead of memorizing diagrams.

Today I worked on Designing a Distributed Rate Limiter.

Here's what I covered:

  • Functional & non-functional requirements
  • Back-of-the-envelope estimation (users, QPS, memory)
  • High-level architecture
  • API Gateway โ†’ Rate Limiter Service โ†’ Redis โ†’ Application Server
  • Returning HTTP 429 for rate-limited requests
  • Using Redis for fast request counting
  • Thinking about scalability, availability, and low latency

While drawing the design, a few questions came to mind:

  • When should we choose Token Bucket vs Sliding Window?
  • How do companies like Google or Stripe handle rate limiting across multiple regions?
  • What happens if Redis goes down? Do we fail open or fail closed?

I'm trying to understand the reasoning behind every design decision rather than just copying popular architectures.

If you're experienced with distributed systems, I'd love to know:

  1. What's the biggest mistake beginners make while designing a rate limiter?
  2. What would you improve in this design?
  3. Any resources that helped you truly understand rate limiting?

Looking forward to your feedback. I'm planning to keep sharing one system design every day. ๐Ÿš€

u/FlatwormAdmirable610 โ€” 21 days ago

Learning System Design in Public โ€” Day 2: Designing a Distributed Rate Limiter

After my first post, I decided to stop consuming system design content passively and start building every design from scratch.

Instead of jumping directly into the architecture, I followed a structured approach similar to what I'd use in a system design interview.

What I covered today

  • Functional Requirements
  • Non-Functional Requirements
  • Back-of-the-Envelope Capacity Estimation
  • High-Level Design (HLD)

The architecture currently looks like this:

Client
   โ”‚
   โ–ผ
API Gateway
   โ”‚
   โ–ผ
Rate Limiter Service
   โ”‚
   โ”œโ”€โ”€ Allowed โ†’ Load Balancer โ†’ Application Servers
   โ”‚
   โ””โ”€โ”€ Denied โ†’ HTTP 429
           โ”‚
           โ–ผ
      Redis Cluster

Why Redis?

I chose Redis because it provides:

  • Sub-millisecond latency
  • Atomic counter operations
  • Native TTL support
  • Easy horizontal scaling with Redis Cluster

Next Steps

This is just the High-Level Design. Next, I'll dive deeper into:

  • Token Bucket vs Sliding Window vs Leaky Bucket
  • Redis key design
  • Lua scripts for atomic operations
  • Distributed rate limiting
  • Failure handling and trade-offs

I'm treating this as a long-term learning journey. The goal isn't to memorize architectures but to understand why each component exists, what problem it solves, and the trade-offs involved.

If you've designed a rate limiter in production or have suggestions on improving this design, I'd love to hear your feedback.

reddit.com
u/FlatwormAdmirable610 โ€” 23 days ago
โ–ฒ 3 r/midleveldeveloper+1 crossposts

๐ŸšฆThink your API can handle millions of requests? What happens when traffic suddenly spikes?

Without a Rate Limiter:

โŒ Servers get overloaded

โŒ APIs become slow or unavailable

โŒ Bots and abusive users consume resources

โŒ Genuine users suffer

A well-designed Rate Limiter solves these problems by controlling request flow while keeping latency low.

Key algorithms every backend engineer should know:

๐Ÿ“Œ Fixed Window Counter โ€“ Simple and fast

๐Ÿ“Œ Sliding Window Log โ€“ Most accurate, memory intensive

๐Ÿ“Œ Sliding Window Counter โ€“ Great balance of accuracy and performance

๐Ÿ“Œ Token Bucket โ€“ Handles burst traffic efficiently

๐Ÿ“Œ Leaky Bucket โ€“ Smooths traffic at a constant rate

Production Tips:

โœ… Store counters in Redis with TTL

โœ… Use atomic operations or Lua scripts to prevent race conditions

โœ… Return HTTP 429 Too Many Requests when limits are exceeded

โœ… Scale Redis using sharding for high traffic

โœ… Monitor rate-limit metrics and tune limits based on usage patterns

If you're preparing for System Design or building scalable APIs with Java & Spring Boot, understanding rate limiting is a must-have skill.

Which rate-limiting algorithm do you prefer in production, and why? ๐Ÿ‘‡

u/FlatwormAdmirable610 โ€” 25 days ago

Stop guessing. Start estimating.

One of the biggest mindset shifts in System Design is learning to do Back-of-the-Envelope Estimation.

Before discussing databases, caches, or load balancers, ask:

๐Ÿ‘ฅ How many users?

โšก How many requests per second?

๐Ÿ’พ How much storage?

๐ŸŒ How much bandwidth?

๐Ÿ–ฅ๏ธ How much compute?

Example: A photo-sharing app with:

10M users

2 photos/user/day

2 MB per photo

That's roughly 14.6 PB of storage per year.

The goal isn't perfect accuracyโ€”it's getting the right order of magnitude. These quick estimates help identify bottlenecks, choose the right architecture, and avoid over- or under-engineering.

Master this skill, and every system design interview becomes much easier.

What do you estimate first in a system design interviewโ€”QPS, storage, or bandwidth? ๐Ÿ‘‡

u/FlatwormAdmirable610 โ€” 26 days ago

Welcome to r/midleveldeveloper ๐Ÿ‘‹

Whether you're aiming for Senior Software Engineer, Staff Engineer, or Tech Lead, this community is built for you.

What you'll find here:

๐Ÿ—๏ธ System Design

โ˜• Java & Spring Boot

โš™๏ธ Backend Engineering

๐ŸŒ Distributed Systems

๐Ÿง  DSA & Problem Solving

๐Ÿ’ผ Interview Preparation

๐Ÿ“ˆ Career Growth

๐Ÿš€ Real-world Engineering Discussions

Before posting:

Be respectful.

Use the appropriate post flair.

Share knowledge and help others grow.

Avoid spam and low-effort posts.

Introduce Yourself!

Comment below with:

Years of experience

Tech stack

Current role

Your next career goal

Let's grow together! ๐Ÿš€

reddit.com
u/FlatwormAdmirable610 โ€” 28 days ago
โ–ฒ 0 r/midleveldeveloper+1 crossposts

Why can DynamoDB handle millions of requests per second while a traditional database struggles? ๐Ÿค”

The answer lies in 5 core distributed system concepts:

โœ… Partitioning (Consistent Hashing)

โœ… Replication

โœ… GET & PUT Routing

โœ… Data Versioning

โœ… Gossip Protocol

I put together this one-page visual to simplify how DynamoDB achieves high availability, scalability, and eventual consistency.

If you're preparing for System Design interviews or learning Distributed Systems, save this for later.

Which distributed system should I break down nextโ€”Kafka, Cassandra, or Redis? ๐Ÿš€

u/Creative_Fox_8836 โ€” 28 days ago
โ–ฒ 7 r/midleveldeveloper+2 crossposts

๐Ÿค” SQL or NoSQL? ACID or BASE? Vertical Scaling or Horizontal Scaling?

If you've ever prepared for a backend interview, you've probably come across these questions.

I recently revised SQL vs NoSQL and realized that understanding why each database exists is much more important than memorizing definitions.

Here's my quick recap:

๐Ÿ“Œ SQL (Relational Databases)

Structured data with predefined schema

Tables, rows, and relationships

ACID transactions for strong consistency

Ideal for financial and transactional applications

๐Ÿ“Œ NoSQL (Not Only SQL)

Flexible or schema-less data model

Built for horizontal scalability

Optimized for distributed systems

Great for handling massive volumes of data

Types of NoSQL

โœ… Key-Value (Redis)

โœ… Document (MongoDB)

โœ… Column-Family (Cassandra)

โœ… Graph (Neo4j)

Quick Comparison

Schema: Fixed vs Flexible

Scaling: Vertical vs Horizontal

Transactions: ACID vs BASE

Consistency: Strong vs Eventual (depending on implementation)

Best For: Complex transactions vs High-scale distributed applications

The biggest takeaway for me:

Choosing the right database isn't about SQL vs NoSQLโ€”it's about choosing the right tool for the problem you're solving.

Every backend engineer should understand the trade-offs before making architectural decisions.

What's your go-to database for production applications, and why? ๐Ÿš€

u/Creative_Fox_8836 โ€” 28 days ago
โ–ฒ 266 r/FAANGJobs+36 crossposts

Mid level Data scientist MAANG

i want to prepare for sr data scientist in MAANG companies. My background is in ย core ML, deeplearning, nlp etc.ย 

I plan to target in around a year from now.

Does someone have any idea about the interview preparation or someone in these companies who would like to share some experience?

Interviewprep resource:

PracHub: Company specific interview questions

DataLemur: SQL Interview and Data Science Interview questions

StrataScratch: SQL and Python interview

u/FlatwormAdmirable610 โ€” 1 day ago