Skip to content
This repository has been archived by the owner on Mar 28, 2022. It is now read-only.

Latest commit

 

History

History
55 lines (48 loc) · 3.56 KB

technology.md

File metadata and controls

55 lines (48 loc) · 3.56 KB
title description published date tags
Technology
Stuff about Discord's internal systems, with some undocumented situations as well
true
2020-01-22 09:18:13 UTC

Discord's "stack"

Technologies Discord uses to provide the service as we know it, gathered from Discord's engineering articles and some other stuff:

Clusters

All the clusters were made to be fault tolerant(read: "not crash") and handle cases where a node of them goes out or when a cluster goes down and wait a bit before requesting from the cluster again.

Sources

Clusters

  • sessions cluster
    • Manages multiple sessions per node in the cluster(as Elixir allows it).
    • Relationships:
      • Requests from the guild cluster to gather guild data for your READY event.
      • Requests from the presence cluster for the same reason.
  • presence cluster
    • Manages your "playing status", smaller than sessions.
    • Gets a high throughput since users join in and request presence data, and users go out and write presence data.
  • guild cluster
    • Manages real time state for guilds and guild data.
  • push cluster
    • Manages push notifications to users.

Informations about Resuming

There is some stuff regarding the resume logic for clients:

  • Session nodes have a message deque, that gets filled with each event your client receives

    • If you want to resume from a sequence number that isn't in the deque, your session gets invalidated
  • When Discord goes down, you might get a PRESENCES_REPLACE event

    • That is sent when your session node notices your client is lagging behind new presence updates.