IM Systems in Depth

Glossary

Each idea in this book has one name in each language. Here is what each means in this book; names you will meet elsewhere follow “also”. Only terms used in published chapters are listed; each new chapter adds its own.

Basics

long-lived connection长连接

A TCP or WebSocket connection a device keeps open to the server. With it, the server can push a message at any time instead of waiting to be asked.

also: persistent connection

Explained in: Chapter 2 Push instead of poll, Chapter 19 Split the gateway

ACKACK(确认)

The receiver’s “got it” to the sender. In this book, the server’s ACK means the message is in the message log, not that anyone has received it.

Explained in: Chapter 3 Acks and retries

sync/async boundary同步与异步的分界

The line between what the sender waits for and what it does not. In this book it is the message log: the sender waits until the append, and all delivery after it is asynchronous.

Explained in: Chapter 28 A queue before storage

write fan-out写扩散

When a message is sent, write one entry into each recipient’s inbox; reading means reading your own inbox. More writes, fast reads; suits conversations with few members.

also: fan-out on write

Explained in: Chapter 10 Fan-out

read fan-out读扩散

Keep one copy in the conversation’s timeline, and each reader fetches it from there. Few writes, more reads; suits big groups.

also: fan-out on read

Explained in: Chapter 10 Fan-out

business layer业务层

The rules: accounts, friends, groups, permissions, moderation. It sits beside the message path: the layers call it when they need to, and messages do not flow through it.

Explained in: Chapter 12 Who may message whom, Chapter 24 Accounts: the app’s users and the IM’s

Client

IM SDK

The client library inside every app: the outbox and retries, sync, the local database, and the API the app uses.

Explained in: Chapter 7 The local database, Chapter 29 One SDK, many platforms

outbox发件箱

The messages on the client that have not been ACKed yet. After a disconnect or a restart, they are resent from here.

Explained in: Chapter 3 Acks and retries, Chapter 7 The local database

message ID消息 ID

A unique ID the client gives each message before sending it, unchanged on resends. The server uses it to recognise a resend.

also: client message ID

Explained in: Chapter 4 Duplicates

sync cursor同步游标

One per device: how far this device has synced in its inbox. When the device comes back, it pulls everything after the cursor.

Explained in: Chapter 6 Offline sync, Chapter 14 Many devices

read cursor已读游标

How far a person has read in each conversation. It lives on the server, is shared by that person’s devices, and drives unread counts and read receipts. Not the same as the sync cursor.

Explained in: Chapter 13 Unread counts and read receipts

Connection layer

gateway网关

A connection-layer server. Each holds many long-lived connections and handles auth, heartbeats and traffic without reading messages. One of the few stateful parts: a restart drops all its connections.

also: connection server

Explained in: Chapter 19 Split the gateway, Chapter 21 A million connections

locator接入调度

The service that tells a device which gateway to connect to. The device asks it first, then connects.

Explained in: Chapter 19 Split the gateway, Chapter 23 Reconnect storms

heartbeat心跳

A small packet sent while a connection is idle. It finds connections that have died, and keeps carrier equipment from forgetting connections that stay silent too long.

Explained in: Chapter 22 Heartbeats

Message layer (receive)

seq序号(seq)

The number of each message in a conversation, assigned in order by the message service that owns it. It sets the order, and lets a client see which message is missing. Each inbox has a separate per-user sequence.

also: sequence number

Explained in: Chapter 5 Ordering

dedup去重

When a message ID arrives again, return the first result instead of storing another copy. The network can only deliver at least once; dedup makes each message show once.

Explained in: Chapter 4 Duplicates

sharding by conversation按会话分片

Each conversation is owned by one message service. Its seq is then assigned by a single owner, which is what keeps the order.

Explained in: Chapter 27 Sharing out the conversations

message log消息日志

A durable, append-only queue: the hand-off between receiving and delivering. A message counts as received once it is in the log, and the server ACKs then. It usually runs on a message queue, such as a topic partitioned by conversation.

Explained in: Chapter 28 A queue before storage

Dispatch layer (deliver)

online push在线推送

A push through a gateway, over the connection, to an online device. It is a hint: if it is lost, the device catches up by pulling.

Explained in: Chapter 2 Push instead of poll, Chapter 19 Split the gateway

OS push系统推送

A notification sent through Apple’s APNs, Google’s FCM or a phone maker’s channel to a phone with no live connection. A third party, best effort, with no guarantee.

also: offline push, push notification

Explained in: Chapter 15 Waking an offline phone

sync service同步服务

When a device pulls with its sync cursor, it returns everything after the cursor, page by page, from the inbox or the timeline.

Explained in: Chapter 6 Offline sync, Chapter 14 Many devices

Storage layer

message store消息存储

The long-term history of messages, one timeline per conversation. Dispatch writes it after reading the log, so it lags the ACK a little.

Explained in: Chapter 28 A queue before storage

timeline时间线

All of a conversation’s messages in seq order. With read fan-out, everyone reads from here.

Explained in: Chapter 10 Fan-out

inbox信箱

A per-person index of “new messages for you”, with its own per-user sequence. Write fan-out writes it, and devices pull from it by sync cursor.

also: sync queue

Explained in: Chapter 6 Offline sync, Chapter 10 Fan-out

online routes在线路由表

Which gateway each online device is connected to. Gateways register devices as they connect, and dispatch looks gateways up here.

Explained in: Chapter 19 Split the gateway