Skip to content

In development. Expect rough edges and changes. The source code is not public yet.

Slack Engineering 9 min read Case study mediumAdept

Managing Slack Connect

Slack built per-connection configuration for Slack Connect using a single MySQL table keyed by source and target team ID, with org-level defaults modeled as target team 0 and settings stored as a Protobuf blob to avoid per-setting columns and tables. The application-layer store first grew into a tightly coupled monolith of per-pref logic, so it was refactored into a container that delegates to per-pref wrapper classes implementing transform, isValid and migrate, with exceptions isolated per pref. Wrapper classes won over code generation because each pref differed too much to template. For admin dashboards, multi-table reads over partitioned data caused latency and timeouts, so Slack denormalized connection data into Solr instead of MySQL, accepting a roughly five-second indexing delay in exchange for full indexing, array-field queries and dynamic fields that scale to millions of connections.

Assumes: MySQL sharding basicsProtocol Bufferssearch indexes

Related posts

  • Unified Grid: How We Re-Architected Slack for Our Largest Customers

    Slack Engineering mediumAdept

    Slack re-architected its backend and clients to replace the workspace-centric model, where session tokens carried a workspace ID used for shard routing and access control, with an org-wide Unified Grid view for Enterprise Grid customers. The work built on earlier Vitess resharding by channel ID and on RTM changes. APIs were fixed in one of three ways: allowing calls that no longer depended on workspace routing, prompting users to pick a workspace, or fanning queries out across the user's workspaces, capped at 50 relevant workspaces per user. The rollout used a "prototype the path" approach: dogfooding internally, two-pass API fixes, a parallel integration test suite run with org context, shared permission helpers and client data-store migrations, finishing in March 2024.

  • Admixer Aggregates Over 1 Billion Unique Users a Day using ClickHouse

    ClickHouse mediumAdept

    Admixer's ad exchange ingests about 100 billion records a day, over 1 million inserts per second, into a 15-server ClickHouse cluster after outgrowing MSSQL and the per-transaction pricing of Azure Table Storage. Events flow from request handlers through a custom on-disk queue, chosen to replace Redis and avoid an early Kafka driver array bug, into EventsProcessors. These write via Buffer → Null table → materialized views, and AggregatingMergeTree counts over 1 billion unique UUIDs per day across arbitrary periods and slices. Practical advice includes using HyperLogLog and sampling when exactness isn't needed, load testing before sizing the cluster, inserting in Native format, and watching Buffer memory and too-many-parts merges. Replication is chosen up front: Admixer skipped ZooKeeper and ReplicatedMergeTree and has clients dual-write to two servers.

  • Data Lineage at Slack

    Slack Engineering mediumAdept

    Slack built a central Data Lineage Service that automatically captures table- and column-level lineage by hooking Airflow success callbacks and dashboard audit logs, then parsing the submitted SQL with ANTLR (backed by a large unit-test suite). Raw lineage lands in RDS MySQL, and a daily Spark job uses Pregel to traverse the dependency graph and write a flattened Hive table with a 'layer' column, so transitive downstream dependencies come back from a single query. A Data Portal notify feature uses this lineage to message downstream owners in Slack about deprecations and retention changes. Lineage for non-SQL Spark jobs, a graph database and automated schema-change alerts are listed as future work.

  • How HighLevel rebuilt its data platform for speed, scale, and simplicity on ClickHouse Cloud

    ClickHouse mediumAdept

    HighLevel replaced MySQL, Elasticsearch, Firestore and a document database with ClickHouse Cloud for lead activity, workflow logs, notifications and billing dashboards. Results: an 11 TB MySQL table compressed to 1.3 TB, P99 latency fell from over 6 s to under 200 ms, and a 60 TB Elasticsearch log store shrank to 6.27 TB served by three replicas. Notifications were modeled as MergeTree raw events plus ReplacingMergeTree read/delete state, with argMax instead of FINAL, Bloom filters and two-month partitions. Dashboards moved from daily cron reprocessing to SummingMergeTree materialized views. Key lessons are to model data as immutable, iterate on schemas, use bulk inserts, and instrument the client with per-service query observability.

  • Email Classification

    Slack Engineering mediumAdept

    Slack classifies invited email addresses as internal or external, so it can steer users toward Workspace Invites or Slack Connect. The classifier checks unique domains against org settings and the inviter's domain in O(1), then looks up a per-team aggregate of user counts by domain and role in a Vitess table sharded by team_id. A domain counts as internal when it holds at least a configurable share of the team, for example 10%. Counts are kept current with relative +N/-N UPSERTs from asynchronous mutation jobs, and a Healer job recounts users in memory and applies corrective deltas when drift appears, such as negative counts from re-executed jobs. The result is an eventually consistent aggregate that needs no expensive daily backfills.

The quest for software engineering knowledge.

Look:
Layout: