I'm currently doing some research for a project about mobile devices and could only find apps that perform instant messaging, but not how they do it.

So I'd like to know what are the technologies/methods behind instant communication between mobile devices? e.g. facebook messenger app. Do the messages go from clientA-to the server-to clientB? This is the impression I got, since the messages are stored, but then how is it so fast?

Any help is greatly appreciated, thanks.

Dani AI

Generated

Brief answer for context: as suspected, almost all mobile IMs use servers as the central routing and sync point (that handles presence, offline storage, multi-device sync and security). ’s historical note about older chat systems is useful — modern mobile apps layer on different transports and lightweight protocols to make delivery feel instant while minimizing battery and data use.

Common building blocks, in plain terms:

  • A persistent, authenticated connection from the mobile client to a cluster of backend servers (WebSocket or a custom TCP socket, or MQTT for very lightweight pub/sub).
  • A message routing layer that accepts inbound messages, stores them briefly (or permanently), and forwards them to connected devices. Message brokers or in-memory routers (Redis, Kafka, Erlang-based routers, etc.) are used to scale this.
  • Mobile push gateways (APNs for iOS, FCM for Android) used when the app is backgrounded or the socket is closed. Push often carries a small payload or just a wake-up so the app can fetch the full message.
  • Security: transport TLS and optionally end-to-end encryption (Signal/Double-Ratchet style) if the app wants servers to be unable to read content.

Typical message flow (simplified):

  1. Sender composes message and sends it over its socket to the server.
  2. Server persists/queues the message and attempts delivery to recipient device(s).
  3. If recipient is online, server pushes message over its open socket and waits for ack. If offline, server triggers APNs/FCM or holds message until the device reconnects.
  4. Recipient acknowledges receipt; server updates delivery/read state and syncs history to other devices.

Minimal message example (for illustration):

{
  "id":"msg-12345",
  "from":"alice",
  "to":"bob",
  "ts":1609459200,
  "type":"text",
  "body":"Hi!"
}

Practical tips: test with varying heartbeat/keepalive intervals (battery vs latency tradeoff), handle duplicate/out-of-order messages with idempotent IDs and sequence numbers, ensure TLS and token refresh are robust, and remember Android/iOS power-management behaviors can force reliance on push notifications.

Recommended Answers

All 3 Replies

There are a number of IM protocols that are in common use, one of which is ICMP. Look at Pidgin, a popular IM application that handles most protocols. It is open source, so you can see how each protocol it supports (almost 20 differenct protocols) is implemented.

"one of which is ICMP". Oops, I mean to say "one of which is IRC (Internet Relay Chat)"... :-)

Thanks for the reply. So from my understanding, a server is still required to pass on the message using IRC? Sorry but I'm relatively new to web technologies .

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.