Skip to content

That's just a taste — their profile full of gems!

Visit profile
User avatar
Karen Edwards
November 1875

Group Chat Design Mistakes

I’ve seen candidates tank perfectly winnable system design rounds because they answered group chat like this:

user sends message → server writes directly to DB → server sends to group

That answer sounds clean. It’s also exactly the kind of answer that gets exposed in 5 minutes.

If I’m interviewing you on WhatsApp, Slack, Messenger, Discord, or Teams-style group chat, I’m not testing whether you can draw boxes. I’m testing whether you understand load, latency, decoupling, and failure handling.

And the first red flag is almost always the same: treating the database like the ingestion layer.

A real group chat system has brutal write pressure. Messages are constantly being created, delivered, indexed, retried, notified, and sometimes processed for abuse detection. If your core design is “ingest service writes every message directly to the database,” you’ve already created a bottleneck at the worst possible point in the system.

That’s amateur thinking.

What I want to hear instead is this:

The client sends over WebSocket, not plain REST, because chat is a real-time product. I don’t want polling nonsense in a messaging system. The server needs to push data to connected users instantly, and WebSocket gives you that bidirectional channel.

Then the message ingest service does the lightweight work: validate sender, group membership, basic abuse checks, message size, create message ID, enrich metadata

And then it does the most important thing:

publish a message_created event to Kafka

That’s the pivot.

Not “save to DB first.” Not “fan out directly from the API server.” Not “let one service do everything.”

Just publish the event and get out of the way.

That one decision tells me you understand system design at a much deeper level.

Because now the system is decoupled.

The ingest service is no longer blocked on storage. It’s no longer blocked on delivery. It’s no longer blocked on notifications. It’s no longer blocked on search indexing.

It has one job: accept, validate, enrich, publish, ack.

That acknowledgment matters too. Once the event is safely published, the client can get a success response and show the equivalent of the single tick—the message reached the platform.

From there, Kafka becomes the event backbone.

The storage service consumes the event and writes messages to durable storage, ideally in batches, not one write at a time.

The delivery service consumes the same event and fans it out to group members.

The notification service can decide who is offline and needs push via FCM/APNs versus who is already active in-app.

The search indexer consumes the event and updates Elasticsearch or another search store.

Optional services like analytics and abuse detection can subscribe too without making the sender wait.

That’s what strong architecture looks like: one producer, multiple consumers, independent scaling.

Another point candidates routinely miss is ordering.

In chat, ordering is not a “nice to have.” It’s table stakes. If messages arrive out of sequence inside a group conversation, the product feels broken immediately.

So I’d expect you to talk about partitioning Kafka by group ID. That gives you ordering within the partition for that group’s messages. If you skip that and just say “Kafka handles ordering,” you’re hand-waving. It handles ordering within a partition, not magically across everything.

That distinction matters in interviews.

Same with presence and connection routing.

At scale, you need some form of connection manager / registry to know which user is connected to which machine, because delivery is not just “send to user.” It’s “find the active socket, the right server, the right connection.”

And if the user is offline, don’t pretend WebSocket solves that. It doesn’t. Now you need an offline queue, push notifications, and eventual delivery when the user reconnects.

This is also where weaker candidates blur delivery and notification into one thing. They’re not the same.

Delivery is about getting the message to the recipient’s chat session. Notification is about alerting them when they’re not actively receiving it in-app.

Different responsibilities. Different service boundaries.

I also liked the emphasis on keeping the ingest layer’s validation lightweight. That’s another interview tell. If you stuff deep ML spam analysis, expensive moderation, and heavy downstream logic into the synchronous send path, congratulations—you just destroyed latency on the most user-sensitive flow in the product.

Do the cheap checks inline. Push the rest asynchronously.

That’s the pattern.

A few interview-grade takeaways I’d drill into anyone preparing for this question:

Don’t make the sender wait on everything. They should not sit behind DB writes, search indexing, notification generation, or abuse pipelines.

Don’t use REST as your primary real-time delivery mechanism. For chat, default to WebSockets unless the interviewer gives constraints that force another tradeoff.

Don’t pretend Kafka is permanent storage. It’s durable, yes. It is not your long-term message store.

Don’t forget idempotency. Retries happen. Message IDs need to protect you from duplicates.

Don’t ignore large-group behavior. A 20-person family group and a 100k-member channel are not the same fan-out problem.

That last one is where senior candidates separate themselves.

For small and medium groups, straightforward fan-out is fine. For very large groups, you need to start talking about smarter delivery patterns, online-only fan-out, channel semantics, batching, and cost control. If you use the exact same strategy for a 10-user group and a 100k-user group, your design is incomplete.

My bigger takeaway is this:

System design interviews are not won by naming tools. They’re won by showing you understand where systems break.

Anybody can say Kafka. Anybody can say WebSocket. Anybody can say NoSQL, Redis, sharding, notifications.

I care whether you can explain why the naive database-first design collapses, why decoupling matters, why ordering is tricky, and why the send path must stay thin.

That’s what gets offers.

If you’re preparing for chat system design, stop memorizing diagrams and start practicing the performance story:

user sends message → low-latency ingest → event bus → independent consumers → durable storage + real-time delivery + async side effects

That’s the answer structure I’d want to hear in a strong interview.

And yes, I’d absolutely push hard if you started with “we’ll just write every message directly to the DB.”

#softwareengineering#systemdesign#scalability#distributedsystems#interviewprep#backend#faang#groupchat#kafka#websocket
Like
Dislike

74

22

Add a comment...