Byte-Sized Design

Byte-Sized Design

Share this post

Byte-Sized Design
Byte-Sized Design
How Message on Slack Really Works

How Message on Slack Really Works

Lots and lots of websockets

Byte-Sized Design's avatar
Byte-Sized Design
Oct 09, 2023
∙ Paid
11

Share this post

Byte-Sized Design
Byte-Sized Design
How Message on Slack Really Works
Share

TLDR;

Slack sends tons of messages everyday on their workplace communication app.

→ The flow a message takes its message

→ It goes to an admin server to look up which server the channel is on

→ Channel server works on broadcasting to all clients on the server.

📺 It’s not TV but there’s channels

Slack has a ton of channels. They’re all grouped together on specific servers. The name for these servers is unsurprisingly called “channel servers”

Every slack channel has a channel id, pretty much a channel number. These channels are stored on specific servers based on their hash

The Super Simple Example:

Channels 1-100 are on channel server 1

Channels 101-200 are on channel server 2…

and so on.

🔌 What if we change the channel?

How does slack know which requests belong to which channel?

We won’t go in too much detail but it’s based off of consistent hashing on the slack ids.

⚡ Set me up with the setup

Here’s how Slack’s architecture works when anyone logs into the app. Diagram looks scary. Lets talk about to make it not scary.

  1. Get some user data from the webapp server.

  2. Make a web socket connection to listen to get messages pushed from the server

  3. Send that request to this gateway server. Gateway server is just a fancy word for knowing where the slack channels are based on Id.

    1. These are region based. Meaning there’s gateway servers for being in the United States and being in India or any other country.

  4. Get the channel data on the user’s webapp server somewhere else.

  5. Send the response back to the proxy server.

  6. Forward that response back to the client.

  7. Keep the channel directory gateway server subscribed to the related channel servers.

Keep reading with a 7-day free trial

Subscribe to Byte-Sized Design to keep reading this post and get 7 days of free access to the full post archives.

Already a paid subscriber? Sign in
© 2025 Byte-Sized Design
Privacy ∙ Terms ∙ Collection notice
Start writingGet the app
Substack is the home for great culture

Share