How Feishu Counts Group Read Receipts: Store Watermarks, Not Read Arrays
Let's talk about a feature that looks simple but is actually easy to mess up: group chat read receipts.
You send a message in Feishu and after a while you can see which members have read it. How does that count get calculated? Most people's first reaction, I'd guess, is: this is easy, just add a field to the message.
First, how that 'obvious' solution dies
The intuitive approach looks roughly like this: each message's JSON carries an array, say read_by, storing the user IDs of everyone who read it. Whoever reads the message pushes their own ID in.
Sounds fine, right? I thought so too. But do the math for a 500-person group: one message read by 500 people means 500 updates. And those 500 updates are not ordinary KV writes; they're all concurrent appends targeting the same message record. With many messages and a large group, that record becomes a hotspot for lock contention.
It doesn't stop there. The more annoying part is when someone scrolls back through history. Then the server has to pack and return the read status of hundreds of messages, while other members are concurrently reading and modifying. Database row locks queue up and the whole chain slows down.
Where's the problem? To put it plainly, you're stuffing two kinds of data with totally different rhythms into the same record. The moment a message is sent, its content is fixed and never changes again. But 'who has read it' can change eight hundred times a minute. High-frequency progress data paired with a low-frequency message entity — the tighter you bind them, the more data accumulates and the worse the write conflicts get.
There's another common illusion: group chat read receipts are just a loop of the single-chat logic, right? Single-chat 'the other party has read' works fine, so just go from one person to N people, done?
I urge you not to think that way. In 1-to-1, read/write pressure is low, and you can write it any way. In a 500-person group, the connection pool gets saturated in no time. Just because a single-chat solution runs doesn't mean it still runs after multiplying by N.
The first step for an experienced developer isn't writing code
It's splitting the model.
Look at RocketMQ's design: from start to finish, it does only one thing — physically separating message content from consumption progress.
How? All messages from all topics, regardless of anything, are appended sequentially to a single Commit Log file. The message body is persisted once, sequential writes, clean.
Where does the progress info — 'how far each consumer group has read' — go? It never touches the Commit Log; it's written separately into a lightweight Consumer Queue index file. Messages stay messages, progress stays progress; storage is separate, IO is separate, neither drags down the other.
Translating this into IM language, the design principle is one sentence: Store a single copy of the group message entity, and maintain a separate read watermark for each group member, stored somewhere else.
What is a watermark? Single chat already gave you the answer
Assign each message a strictly increasing int64 sequence number — 100, 101, 102, and so on. If the other party has read up to 102, then all messages before 102 are considered read by default. That 102 is the read watermark.
Those familiar with RocketMQ should smile here: isn't this just the Offset? The consumer advancing an offset is the same action as IM advancing read progress, just under a different name.
How do you do group chat? Multiply this logic by N. A 500-person group doesn't need 500 copies of the message; it needs 500 watermark records, with keys like group_id + user_id → last_read_seq. The message entity stays untouched; each watermark advances independently; the read and write paths part ways.
If you're familiar with RocketMQ's consumption model, this mapping requires no thought: a chat window is a topic; you sending a message makes you a producer; the other party fetching and reading makes them a consumer advancing their own offset; the 500 people in the group are not 500 consumers, but 500 consumers under the same consumer group, each recording their own progress.
RocketMQ's mechanism was designed for exactly this: one message, a bunch of independent consumers, each advancing progress independently. Group chat read receipts sit squarely on this pattern. So this isn't a forced analogy; the business model and the middleware model are the same underneath.
To actually ship it, three hurdles are unavoidable
The first is where to store the watermark. The answer is two words: keep it separate. The message entity goes into the message storage cluster; the watermark goes into Redis Cluster. Use HINCRBY to atomically increment a group's message sequence number, and HSET to update each user's watermark — one hash per group, each member a field. From then on, messages stay messages and progress stays progress; each does its own thing without interfering.
The second is what to do when concurrency overwhelms you. RocketMQ handles massive concurrency by having NameServer, Broker, Producer, and Consumer each do their own job, and you scale whichever becomes the bottleneck. In IM, the role division is even simpler: the mobile client is both producer and consumer — they're naturally unified. And this isn't a stretch; if you dig into RocketMQ source, you'll find that Producer and Consumer are both assembled by the same MQClientFactory, sharing the same long-lived network connections. Extending IM business commands on top of that is straightforward — no need to start from scratch.
The third is the one that most easily gets you stuck: how to push read status back to the sender. Someone might grumble here: RocketMQ's message flow is one-way, isn't it? The Broker won't actively push 'consumption results' to the Producer. But look at its transaction message callback implementation: the Netty long connection between Broker and Producer is always bidirectional; the Broker is fully capable of actively pushing commands — it just usually isn't used for that. IM systems have it even easier; the long connection from client to gateway is naturally maintained. As soon as someone in the group updates their watermark, the server pushes the progress event back to the sender over that connection; the sender merges it locally and the number like 52.7% read comes out.
What's actually valuable in this design
Honestly, it's not Redis, and it's not long-connection push.
It's borrowing the mature model of a message middleware and turning your business problem into an architectural problem someone already solved long ago.
Most people, when they encounter group chat read receipts, instinctively treat it as a brand-new social feature and then reinvent the wheel at the business layer. But if you're familiar enough with RocketMQ's storage model, consumption progress model, and communication model, you'll see this problem was already solved at the infrastructure layer. You don't need to invent from zero; you need to recognize 'I've seen this problem,' then write down the mapping.
Going back to that last_read_seq watermark: the thing it does is essentially one thing: it turns O(N) update complexity into O(1) progress advancement.
This ability has nothing to do with whether you've used RocketMQ. It has to do with whether you can abstract a business problem into a data structure problem.