Node.js 24.22.2 “Krypton” (LTS) is here! 🚀
Includes V8 backports and a fix that keeps async context in parked stream writes.
🔗 Full changelog and download links: https://t.co/M3dSNKO7W2
HLD Interview Notes: Day 6/30
Topic: Cache Stampede, Cache Penetration and Cache Avalanche
Your cache is supposed to protect the database. But what happens when caching itself creates a traffic problem?
Three common failure scenarios every system design interview candidate should understand.
1. Cache Stampede
Problem: A popular cache key expires, and thousands of requests try to fetch the same data from the database simultaneously.
Example: A product page's cache expires during a sale. Every incoming request hits the database.
Solutions:
Request coalescing: Let one request fetch the data while others wait.
Distributed locking: Allow one worker to refresh the cache.
Background refresh: Update popular entries before they expire.
2. Cache Penetration
Problem: Requests repeatedly ask for data that doesn't exist in the database, causing cache misses every time.
Example: Bots request thousands of nonexistent product IDs. Every request reaches the database.
Solutions:
Cache negative results for a short TTL.
Use a Bloom Filter to identify keys that definitely don't exist.
Validate requests before querying the database.
3. Cache Avalanche
Problem: Many cache entries expire simultaneously, causing a sudden surge of requests to the database.
Example: Thousands of product entries share the same TTL and expire together.
Solutions:
Add random jitter to TTLs.
Use staggered expiration times.
Apply rate limiting and load shedding to protect the database.
4. Quick Comparison
Stampede: Many requests for the same expired key.
Penetration: Requests for nonexistent data.
Avalanche: Many keys expire around the same time.
5. Interview Tip
When diagnosing a cache problem, ask:
Is one hot key causing too many requests?
Are requests targeting data that doesn't exist?
Are many keys expiring together?
The answer helps you choose the right mitigation.
FAANG Takeaway
Caching is not just about hit rates. It's also about protecting the database when the cache fails to serve a request.
Design for cache misses, expiration spikes, and malicious traffic before they become production incidents.
Next: Day 7/30
Cache-Aside vs Read-Through vs Write-Through vs Write-Back
Database Scaling and Sharding Strategies - Simplified with Visuals!
When your app or system grows, your database needs to scale smartly to keep up. Here’s a breakdown of the core strategies:
1. Horizontal Scaling: Add more servers to share the load and increase capacity without overloading a single machine.
2. Vertical Scaling: Upgrade a server’s CPU, RAM, or storage to make it stronger and handle more demand.
3. Partition Strategies: Split large databases logically (by time, region, or type) to improve manageability and access speed.
4. Range-Based Sharding: Store and organize data based on value ranges (like prices or dates) for faster lookups.
5. Even Distribution: Spread the load evenly across servers to maximize performance and prevent bottlenecks.
6. Uneven Distribution: When servers are imbalanced - some overloaded, some underused - leading to inefficiencies.
7. Key-Based Sharding: Use a hash function to distribute data consistently and randomly across shards.
8. Scaling Reads: Create multiple read replicas to handle heavy traffic and offload the main database.
9. Monolith vs Sharding: Instead of one huge database (monolith), splitting into logical shards helps systems grow, stay organized, and perform faster.
Book your System Design session with me (link in comments) and save this if you're learning System Design or preparing for Tech Interviews!
Let me know which concept you found the most helpful.
P.S. Preparing for a software engineering role? Check out my book, System Design and Behavioral Intelligence.
It will help you:
• Build strong System Design foundations and approach design problems with confidence
• Develop practical frameworks to navigate complex behavioral and leadership challenges
Get Your Copy anywhere internationally:
US: https://t.co/tkmGPyIFya
UK: https://t.co/b6QWqdN8y9
India : https://t.co/RoOZPwjd2w
𝗠𝗖𝗣 𝘃𝘀 𝗔𝗣𝗜 𝘃𝘀 𝗦𝗸𝗶𝗹𝗹𝘀.
An 𝗔𝗣𝗜 defines how software systems communicate through specific endpoints, requests, and responses. It gives applications a structured way to access data or trigger functionality in another system.
𝗠𝗖𝗣 (Model Context Protocol) standardizes how AI applications discover and interact with external tools, data, and resources. Instead of building custom integrations for every AI client, MCP servers expose capabilities through a common protocol that agents can use.
𝗦𝗸𝗶𝗹𝗹𝘀 package reusable instructions, workflows, and resources that guide agents through specific tasks. Rather than providing new connections to external systems, they give agents task-specific procedures and know-how they can load when needed.
Together, they help agents connect to systems and use those capabilities to complete tasks.
But building all these integrations and workflows from scratch takes time.
Precisely AI Studio helps builders build faster with 𝗿𝗲𝗮𝗱𝘆-𝗺𝗮𝗱𝗲 𝗔𝗜 𝗮𝗴𝗲𝗻𝘁𝘀, 𝗮𝗽𝗽𝘀, 𝗮𝗻𝗱 𝘀𝗸𝗶𝗹𝗹𝘀 𝗰𝗼𝗻𝗻𝗲𝗰𝘁𝗲𝗱 𝘁𝗵𝗿𝗼𝘂𝗴𝗵 𝗠𝗖𝗣. Builders can explore and test them using sample data, then bring agents and skills into their existing AI stack.
Explore Precisely AI Studio → https://t.co/Foa98LDoxs
What else would you add?
——
♻️ Repost to help other learn AI.
🙏 Thanks to @PreciselyData for sponsoring this post.
➕ Follow me ( Nikki Siapno ) to improve at AI and system design.
Nest has always been known as a framework on top of Express or Fastify.
But what if Nest was just Nest? 🤔
In the next minor release: @nestjs/platform-node, built directly on node:http. One-line switch, and the fastest way to run Nest yet. 🚀
Data pipelines let you collect, process, and use huge amounts of data efficiently.
But building and maintaining these pipelines can be tricky with API rate limits, changing data schemas, and so on.
In this in-depth course, you'll learn about data ingestion & normalization, data loading with an open source Python library, tuning performance, and much more.
https://t.co/RkINNJhsTC
New: @nestjs/resilience 🎉
Timeouts, retries, circuit breakers, bulkheads and fallbacks as decorators. Safe-by-default retries, shared presets, and it works on HTTP, GraphQL, microservices and gateways.
https://t.co/Q2CJTnlqi5
Redis is not a database. It's amnesia with a purpose. Your database remembers everything forever. Redis remembers only the hot stuff and forgets it fast.
Your app asks for user data 10,000 times a second. Hitting the database 10,000 times melts the server. So Redis sits in between and says I remember that, use this cached copy. Instant.
Strings, lists, hashes, sets, sorted sets. It's not just a key-value store. It's a versatile memory engine that handles caching, queues, rate limiting, leaderboards, and real-time counters all at once.
But here's what kills people: they treat it like a database. Store data in Redis and assume it's safe. It's not. Redis is volatile. Power dies and everything vanishes unless you have persistence enabled.
Use Redis to speed up your database. Don't use it to replace your database.
Set expiration on every key. Monitor memory limits. Enable persistence if you care about data. Run without any of these and you're playing with fire.
Redis makes apps faster. It's not immortal. Treat it right and it scales. Treat it wrong and it crashes at 3 AM.
Monorepo vs Microservices 🧩⚙️
They solve very different problems in how software is organized and operated.
🔵 Monorepo
- Keeps multiple apps, packages, or services in one repository.
- It makes shared code, tooling, and collaboration easier.
- But large repos can make builds and coordination more complex.
🟢 Microservices
- Split the system into smaller, independently owned services.
- Each service can usually be deployed and scaled separately.
- But networking, observability, and cross-service coordination become harder.
Monorepo → centralized code organization
Microservices → distributed system architecture
Monorepo often improves consistency across teams.
Microservices improve independence between services.
And they are not opposites - you can run multiple microservices from a monorepo too. 🚀
Your entire Kubernetes cluster just froze because etcd died. Not because your servers crashed. Because the database holding your cluster's memory stopped working.
etcd is the brain of your cluster. It stores everything: which pods run where, which nodes exist, what services are available, configuration state. Every controller, every scheduler, every API server reads from etcd constantly.
When etcd goes down, the cluster doesn't just slow down. It forgets what to do. New pods can't be scheduled. Controllers can't make decisions. Your entire infrastructure becomes a zombie - technically running but unable to think.
This is why etcd runs as a cluster, not a single node. If one etcd member dies, the other two keep the quorum alive. If all three die simultaneously, everything stops.
Running a single etcd node in production is playing with fire. Running without backups is arson. Ignoring resource limits lets etcd consume memory until it crashes. Misconfiguring network settings makes members unable to talk to each other.
etcd isn't just a database. It's the backbone. It keeps your cluster coordinated, consistent, and always running.
Backup etcd. Monitor etcd. Run at least three nodes. Understand that when etcd breaks, your entire infrastructure breaks.
CI/CD vs GitOps ⚙️🔁
Both help teams ship software faster, but they solve different parts of the delivery process.
🔵 CI/CD automates build, test, and deployment
🟢 GitOps uses Git as the source of truth for environment state
🔁 GitOps continuously reconciles infrastructure with what’s defined in Git
🚀 CI/CD is great for application delivery
☸️ GitOps shines with Kubernetes and declarative infrastructure
In practice, many teams use both together:
CI builds and tests; GitOps handles deployment and sync.
Meteor Agent Skills 1.1.0-beta.0 gives your coding assistant guidance for the 3.6 beta, including Rspack migration and pnpm workspaces. Our release notes also cover the checks we've run and remaining test gaps.
https://t.co/m7gYF8en7w
REST, GraphQL, or gRPC? 🤔
They all solve API communication differently:
🔵 REST
- Simple and widely understood
- Uses multiple resource-based endpoints
- Great for public APIs and web apps
🟣 GraphQL
- Fetch exactly the data you need
- Usually works through a single endpoint
- Great for dashboards, mobile apps, and complex UIs
🟢 gRPC
- Uses Protocol Buffers and HTTP/2
- Fast, strongly typed, and supports streaming
- Great for microservices and internal systems
There’s no universal winner - the right choice depends on your architecture, performance needs, and clients.
API authentication can look confusing, but the main methods are pretty straightforward. 🔐
🔑 API Keys - simple server-to-server access
👤 Basic Auth - username + password
🎟️ Bearer Tokens - common for modern APIs
📄 JWT - stateless auth with signed claims
🔄 OAuth 2.0 - delegated third-party access
🪪 OpenID Connect - login + identity on top of OAuth
🛡️ mTLS - strong service-to-service authentication
Backend System Design Question
Which strategy is better for scaling database performance under high read traffic?
Design A (In-Memory Caching) vs Design B (Read Replicas)