Personal Blog Experiences, thoughts and technical stuff! :D

Scaling Slack

How slack works

Slack is mainly known for its Persistent Group Messaging service.

Trivia:

alt text

Slack’s webapp codebase:

Login and Receive Messages: the “mains”

the mains

the shards

MySQL Shards:

By why MySQL?

How is MySQL used then?

At slack, MySQL is used for master-master replication

MMR text

This helps in retreiving data from one shard in case of failure of the other, as write operations are performed on both shards simultaneously.

Now what if the same row is written or same value is written ? How does Slack with MMR complications?

The rtm-API (RealTime Messaging API), does all of the above and shares to the user the following but not limited to:

  1. Identity of every channel in a team,

  2. ID of every user in the team,

  3. The membership of all channels,

  4. Where has the cursor moved since you were last active on the channel, etc..

But the two important pieces of information are:

{
    "ok": True,
    "url": "wss:\/\/ms9.slack-msgs.com/\websocket\/7I5yBpcvk",
    ...
}

Using the above frame of information of each session, slack manages realtime update with cache memory of the websocket connection

Rtm.start payload

Message Delivery

msg delivery

Deferring Work:

def work

How slacks works today

Hard scenarios slack deals with

Solutions for the above problem?