Interviewer:
You're at Razorpay.
A startup just processed
their first ever payment.
โน999. 11:59 PM.
Your system failed to capture it.
Money deducted. โ
Payment never received. โ
Founder's first customer. Gone.
What went wrong and how do you make sure nobody loses their first โน999 again?
Interviewer:
You're the engineer at CRED.
Your users are India's most impatient people.
High income. Zero tolerance.
App takes 3 seconds to load.
50,000 users uninstall.
Same day.
What's the first thing you fix?
Large React apps get harder to scale when every feature has to live inside the core codebase.
In this tutorial, Jessica shows you how to design a React plugin architecture with TypeScript that is type-safe, lazy-loaded, and secure.
You'll also learn about hosting APIs, plugin lifecycles, separate bundling, runtime loading, and more.
https://t.co/SsT4uIKAnH
System Design - EDA and Messaging - Day 50 โ Kafka Delivery Guarantees
What happens if a message is lost?
Or processed twice?
Distributed systems must choose between speed, reliability, and duplicates.
That's where Kafka's delivery guarantees come in.
---
What Are Delivery Guarantees?
Delivery guarantees define what Kafka promises when delivering messages from a producer to a consumer.
There are three models:
- At Most Once
- At Least Once
- Exactly Once
Each makes different trade-offs.
---
1. At Most Once
A message is delivered zero or one time.
Producer
โ
โผ
Kafka
โ
โผ
Consumer
โ Crash
Message Lost
If a failure occurs before processing finishes...
The message is lost forever.
Characteristics
โ Fastest
โ No retries
โ Possible message loss
---
2. At Least Once
A message is delivered one or more times.
Producer
โ
โผ
Kafka
โ
โผ
Consumer
Crash
Retry
Consumer Again
If processing fails...
Kafka delivers the message again.
No data is lost.
But duplicates are possible.
Characteristics
โ Reliable
โ Retries
โ Duplicate processing
---
3. Exactly Once
Kafka guarantees each message is processed exactly one time.
Producer
โ
Kafka
โ
Consumer
โ
Processed Once โ
- No duplicates.
- No message loss.
This requires idempotent producers and Kafka transactions.
---
Delivery Guarantee Comparison
At Most Once: Possible message loss โข No duplicates โข Fastest
At Least Once: No message loss โข Possible duplicates โข High throughput
Exactly Once: No message loss โข No duplicates โข Lowest throughput
---
Real-World Examples
At Most Once
- Metrics
- Application Logs
- Monitoring Data
Losing one message usually isn't critical.
---
At Least Once
- Order Processing
- Email Notifications
- Inventory Updates
- Audit Events
Missing data is unacceptable.
Duplicates can be handled.
---
Exactly Once
- Banking
- Payments
- Financial Transactions
- Invoice Generation
Processing the same event twice can cause serious problems.
---
Production Example
Customer pays โน100.
Without protection:
Payment Event
โ
Processed
โ
Consumer Crash
โ
Retry
โ
โน100 Charged Again โ
With Exactly Once:
Payment Event
โ
Kafka Transaction
โ
Processed Once โ
The customer is charged only once.
---
Common Mistake
Many developers assume Exactly Once is always the best option.
It isn't.
It adds extra coordination and overhead.
For many systems, At Least Once + Idempotent Consumers provides the best balance of reliability and performance.
---
Best Practices
- Use At Most Once for telemetry and logs.
- Use At Least Once for most business events.
- Use Exactly Once only for critical financial workflows.
---
Key Takeaway
At Most Once โ Fast, but messages may be lost.
At Least Once โ Reliable, but duplicates are possible.
Exactly Once โ No loss, no duplicates, with additional complexity.
Choosing the right delivery guarantee depends on your business requirements not just the technology.
---
Tomorrow ->Dead Letter Queues (DLQ)
Learn how production systems handle messages that repeatedly fail without blocking the rest of the queue.
OpenStreetMap is a free, open alternative to Google Maps you can use for many location-based apps.
In this tutorial, @joshuaaabraham explains how OpenStreetMap works and how to integrate it into a React app with Leaflet.
You'll also learn about geocoding with Nominatim, when to choose OpenStreetMap over Google Maps, and more.
https://t.co/l3UbxEa7jw
Iโve seen people go from:
- Infosys (4 LPA) โ Google (40+ LPA)
- Tech Mahindra (4.2 LPA) โ Adobe (25+ LPA)
- Cognizant (4.5 LPA) โ Microsoft (30+ LPA)
What made the difference?
It wasn't luck.
It wasn't having an IIT or NIT tag.
It wasn't waiting for the "perfect opportunity."
It was a few consistent habits:
1. They mastered DSA topic wise and pattern wise, instead of just solving random questions.
2. They built strong fundamentals in one tech stack, instead of chasing every new trend.
3. They kept upskilling - system design, AI, a new framework, even when they weren't actively looking for a job.
4. They learned from every rejection and kept improving, instead of giving up.
5. They stayed consistent for months, not just a few weekends before interviews.
Your first salary doesn't define your career.
Your learning mindset does.
Most distributed systems work in 2026 is still 10 concepts, done under failure and pager noise:
1) Timeouts + retries. Cap them, add jitter, and avoid retry storms when the dependency is already burning.
2) Idempotency. Every write endpoint needs a key or dedupe window, or at-least-once delivery turns into double charges.
3) Backpressure. Bounded queues and load shedding beat infinite buffers that just convert spikes into OOMs.
4) Consistency model. Pick what can be stale, for how long, and where; document it or it becomes an incident later.
5) Partitioning + hotspots. One bad key (tenant_id, user_id) can pin a shard; add salting and watch skew.
6) Concurrency control. Use optimistic locking, version checks, or leases; last-write-wins quietly loses money.
7) Deployment safety. Canary, feature flags, and rollbacks; schema changes need forward and backward compatibility.
8) Observability you can use. Correlation IDs, RED metrics, traces with sampling that still catches rare errors.
9) Debugging in prod. Packet captures, thread dumps, pprof, slow query logs; know what to grab before you SSH.
10) Security basics. mTLS or at least service auth, secrets rotation, least-privilege IAM; most breaches start as internal misuse.
[generated using my AI agent, shared so you can learn from it]
toString() Best Practices in Java - Day 36
Have you ever printed an object and seen something like this?
User@6d06d69c
Not very helpful, right?
That is the default implementation of toString().
A well-written toString() can save hours of debugging and make logs much easier to understand.
Let's see why.
---
What is toString()?
Every Java object inherits the toString() method from the Object class.
public String toString()
Its purpose is simple:
Return a human-readable representation of an object.
Whenever you do this:
System.out.println(user);
Java automatically calls:
user.toString();
---
Default Implementation
Suppose we have:
class User {
int id;
String name;
}
Now:
User user = new User();
System.out.println(user);
Output:
User@6d06d69c
What does that mean?
User โ Class name
6d06d69c โ Hexadecimal hash code
Useful for the JVM.
Not useful for developers.
---
Override toString()
Instead, provide meaningful information.
@ Override
public String toString() {
return "User{id=" + id +
", name='" + name + "'}";
}
Now:
System.out.println(user);
Output:
User{id=1, name='Alice'}
Much easier to read.
---
Where is toString() Used?
You use it more often than you think.
โ Logging
โ Debugging
โ IDE object inspection
โ Exception messages
โ String concatenation
System.out.println("User = " + user);
Internally Java calls:
user.toString();
Automatically.
---
Best Practices
A good toString() should:
- Include meaningful fields
- Keep the output concise
- Be easy to read
- Handle null values gracefully
Avoid including:
- Passwords
- Access tokens
- API keys
- Sensitive personal information
Remember:
Logs often end up in monitoring systems.
Never expose secrets through toString().
Use IDEs to Generate It
You don't need to write it manually.
Most IDEs can generate it for you.
IntelliJ IDEA:
Right Click โ Generate โ toString()
This saves time and reduces mistakes.
---
Interview Takeaway
Should every field be included in toString()?
Not necessarily.
Include fields that help identify and understand the object's state.
Exclude:
- Passwords
- Authentication tokens
- Sensitive identifiers
- Large collections if they make logs unreadable
A clean toString() should help developers not overwhelm them.
---
Easy Way to Remember
equals() โ Are these two objects logically equal?
hashCode() โ Which bucket should this object go into?
toString() โ How should this object look when printed?
These three methods from the Object class are among the most commonly overridden methods in Java and are essential for writing clean, maintainable code.
That completes Phase 2: Object-Oriented Programming (OOP)
Next, we will move into the next phase of the roadmap - Memory & JVM
---
Question:
Do you usually write toString() manually, generate it using your IDE, or rely on Lombok's @ ToString annotation?
Fast backups at-scale are made possible by sharding.
These require an amazing amount of engineering to nail the infrastructure, orchestration, and reliability.
I wrote all about it... with the help of some PlanetScale database geniuses, of course!
Postgres 19 can query relationships like a GRAPH
NOT with a long manual join chain. With a path:
customer โ bought โ product product โ bought โ similar customer similar customer โ follows โ brand
That is a recommendation system in one readable pattern. SQL/PGQ finds the relationship.
COLUMNS decides what comes back.
Postgres keeps eating the backend stack.
https://t.co/3LUxPoZWaN
PostgreSQL adds OAuth 2.0 support ๐
Instead of managing separate database passwords, users can authenticate through an external identity provider using SSO and OAuth tokens.
PostgreSQL can integrate with providers such as:
โ Google
โ Auth0
โ Keycloak
โ Microsoft Entra ID
Centralized access control.
Short-lived credentials.
Fewer database passwords to manage.
Modern authentication, directly in PostgreSQL.
https://t.co/hq0R5tIMPM
As a Frontend Developer,
Please slap yourself if you cannot clearly explain at least 10 of the following :
Hydration
Partial hydration
Islands architecture
Streaming SSR
Concurrent rendering
Time slicing
Reconciliation algorithm
Fiber architecture
Virtual DOM diffing complexity
Stale closure problem
Event loop (macro vs microtasks)
Task starvation
Layout thrashing
Critical rendering path
Render blocking resources
Tree shaking internals
Code splitting strategies
Dynamic import chunking
Module federation
Shadow DOM
Web Components interoperability
Web Workers vs Service Workers
SharedArrayBuffer
Transferable objects
OffscreenCanvas
WebAssembly integration
Browser compositing layers
Paint vs composite vs layout
GPU acceleration in CSS
CSS containment
Subpixel rendering
IntersectionObserver internals
ResizeObserver loop limits
MutationObserver cost
IndexedDB
Service Worker lifecycle traps
Cache invalidation strategies
Stale-while-revalidate
ETag vs Cache-Control
HTTP/3 and QUIC
Priority hints
Preload vs Prefetch vs Preconnect
CORS preflight
SameSite cookie modes
CSRF vs XSS mitigation
Content Security Policy (CSP)
Trusted Types
DOM clobbering
Prototype pollution
Race conditions in UI state
Suspense boundaries
Selective hydration
Server components
Edge rendering
Micro-frontend orchestration
Finite state modeling
Event sourcing in frontend
Optimistic UI rollback strategy
WebRTC
Backpressure in streams API
AbortController
Streaming fetch response handling
Browser memory leak detection
Detached DOM nodes
Garbage collection timing
PerformanceObserver API
Long tasks API
First Input Delay (FID)
Interaction to Next Paint (INP)
Cumulative Layout Shift (CLS)
Largest Contentful Paint (LCP)
Speculative prerendering
Priority inversion in async code
Senior Backend Interview Question:
Two engineers cache product data.
Engineer A โ Cache-Aside ๐
Read: Check cache โ miss โ query DB โ store in cache โ return
Write: Update DB only. Cache expires on TTL.
Engineer B โ Write-Through ๐
Read: Check cache โ always there โ return instantly
Write: Update DB AND cache simultaneously. Always in sync.
Engineer A's users see stale product prices for up to 1 hour.
A flash sale starts. Old prices show for 60 minutes.
Engineer B's cache is always fresh. But every write is slower because it updates two places.
At Shopify, flash sales affect millions of users simultaneously.
Which strategy would you choose โ and what's the tradeoff you're accepting? ๐
(another dbi glaze post)
database internals is the best book i've ever read. it can be a bit dense in its approach, but it has taught me a lot. this book really means a lot to me.
Idempotency โ Deduplication โ Exactly-Once Processing
These three concepts are often used together in distributed systems...
But they solve completely different problems.
Confusing them can lead to duplicate payments, repeated emails, or inconsistent order processing.
Here is the easiest way to remember them:
Idempotency โ The same request can be executed multiple times, but the final result remains the same.
Deduplication โ Detects and ignores duplicate requests or messages before processing.
Exactly-Once Processing โ Ensures a message's effect is applied only once across the entire processing pipeline.
Quick memory trick
- Idempotency = Safe Retries
- Deduplication = Remove Duplicates
- Exactly-Once = One Effect
----
Imagine a Payment API
A customer clicks "Pay Now"...
The network times out.
The client retries the request.
What happens next?
Idempotency
The request includes:
Idempotency-Key: abc123
Even if the request is sent 5 times...
Only one payment is created.
Every retry returns the same result.
Deduplication
Suppose Kafka delivers the same event twice:
PaymentCompleted
PaymentCompleted
The consumer checks the Message ID.
If it's already processed...
The duplicate is skipped.
Only one copy is handled.
Exactly-Once Processing
Imagine:
Producer โ Kafka โ Consumer โ Database
The consumer crashes after writing to the database but before acknowledging the message.
Without proper guarantees...
The message may be processed again.
Exactly-once processing ensures that even if retries happen, the business effect is applied only once.
Examples include transactional messaging systems such as Kafka's Exactly-Once Semantics (EOS) combined with idempotent consumers or transactions where appropriate.
---
When should you use each?
Idempotency
- Payment APIs
- REST APIs
- Retryable operations
- Order creation
- Money transfers
Purpose:
๐ Make retries safe.
Deduplication
- Kafka consumers
- RabbitMQ consumers
- Email notifications
- Webhooks
- Event processing
Purpose:
๐ Filter duplicate messages.
Exactly-Once Processing
- Financial systems
- Inventory management
- Banking
- Event-driven microservices
- Critical business workflows
Purpose:
๐ Guarantee a single business effect.
---
The biggest misconception
Many developers think:
Idempotency gives Exactly-Once Processing.
Not necessarily.
Idempotency makes repeated requests safe.
Deduplication filters repeated messages.
Exactly-once processing is an end-to-end guarantee that typically requires coordination across producers, brokers, consumers, and storage.
In production systems, you will often use all three together.
---
One sentence to remember forever
Idempotency = Same request, same outcome.
Deduplication = Ignore duplicates.
Exactly-Once = One business effect.
Reliable distributed systems aren't built by hoping messages arrive only once...
They are built by assuming retries, duplicates, and failures will happen and designing the system to handle them correctly.