---
title: "FOQS: Making a distributed priority queue disaster-ready"
description: "Meta's FOQS distributed priority queue moved from isolated regional installations on semi-synchronous replicated MySQL to a single global installation, after Hurricane Florence in 2018 exposed manual traffic rebalancing and items stuck on unreachable shards."
url: "https://swe.quest/articles/foqs-making-a-distributed-priority-queue-disaster-ready-0c0b1a2a20084eae"
canonical: "https://engineering.fb.com/2022/01/18/production-engineering/foqs-disaster-ready/"
source: "Meta Engineering"
published: "2022-01-18"
difficulty: "medium"
kind: "Case study"
reading_minutes: 10
tags: ["messaging","resilience","replication","distributed-systems","mysql"]
---

# FOQS: Making a distributed priority queue disaster-ready

A post on [Meta Engineering](https://swe.quest/sources/meta.md), published 2022-01-18, 10 min read, Case study. Original: [https://engineering.fb.com/2022/01/18/production-engineering/foqs-disaster-ready/](https://engineering.fb.com/2022/01/18/production-engineering/foqs-disaster-ready/)

## Summary

Meta's FOQS distributed priority queue moved from isolated regional installations on semi-synchronous replicated MySQL to a single global installation, after Hurricane Florence in 2018 exposed manual traffic rebalancing and items stuck on unreachable shards. The global design uses Shard Manager so a queue node in the new region takes over a MySQL primary within seconds of failover. A routing service maps logical region preferences to shards for enqueue and keeps a heap-based cache of nodes with ready items for dequeue. Migrating the Async platform required parallelizing cache replenishment, which nearly halved its latency, and randomizing selection among top-priority nodes to fix thundering herd and starvation. The 2021 migration finished with zero downtime using shadow load testing, config-based rollouts and health dashboards.

Written by swe.quest, not by the author.

**Difficulty:** Medium: assumes a working developer; shows how it is built or done

## Topics

- [Queues & messaging](https://swe.quest/tags/messaging.md) (Backend & APIs)
- [Resilience](https://swe.quest/tags/resilience.md) (Distributed systems)
- [Replication](https://swe.quest/tags/replication.md) (Distributed systems)
- [Distributed systems](https://swe.quest/tags/distributed-systems.md) (Distributed systems)
- [MySQL](https://swe.quest/tags/mysql.md) (Data & databases)

## Prerequisites

- MySQL replication and failover ([easy posts on MySQL](https://swe.quest/tags/mysql.md?difficulty=easy))
- message queue basics ([easy posts on Queues & messaging](https://swe.quest/tags/messaging.md?difficulty=easy))
- sharding ([easy posts on Distributed databases](https://swe.quest/tags/distributed-databases.md?difficulty=easy))

## Keywords

FOQS, MySQL, Shard Manager, Async

## Related posts

- [Asynchronous computing at Meta: Overview and learnings](https://swe.quest/articles/asynchronous-computing-at-meta-overview-and-learnings-38025981fbc83823.md): Meta Engineering · 2023-01-31 · Medium · 10 min read · Serverless, Queues & messaging, Scheduling, Distributed systems, System design
  Meta re-architected Async tier, its serverless asynchronous computing platform running multi-trillion workloads per day, by splitting an overloaded Dispatcher into data-source-specific "tailers" and a source-agnostic scheduler.
- [How Meta built the infrastructure for Threads](https://swe.quest/articles/how-meta-built-the-infrastructure-for-threads-961a6b509998fe97.md): Meta Engineering · 2023-12-19 · Medium · 7 min read · Scaling, Distributed databases, Multi-tenancy, Serverless, Resilience
  Threads reached 100 million sign-ups in five days on existing shared Meta infrastructure rather than purpose-built systems, illustrated through two components: ZippyDB and Async.
- [Shard Balancing: Moving Shops Confidently with Zero-Downtime at Terabyte-scale](https://swe.quest/articles/shard-balancing-moving-shops-confidently-with-zero-downtime-at-terabyte-scale-76a6177fa357eea4.md): Shopify Engineering · 2021-09-24 · Medium · 13 min read · MySQL, Distributed databases, Schema migrations, Scaling
  Shopify rebalances its MySQL shards by moving individual shops between pods online, with downtime confined to a brief cutover.
- [Beyond synthetic testing: Capturing and replaying real database workloads at Airbnb](https://swe.quest/articles/beyond-synthetic-testing-capturing-and-replaying-real-database-workloads-at-ad8d4a3a0c1cef6e.md): Airbnb Engineering · 2026-10-06 · Medium · 11 min read · MySQL, Testing, Capacity planning, Performance engineering, Databases
  Airbnb replaced fragmented per-language client-side query logging with a client-agnostic capture point in ProxySQL, so real production MySQL traffic can be replayed offline.
- [Keep the monolith, but split the workloads](https://swe.quest/articles/keep-the-monolith-but-split-the-workloads-a46b5ee6a5f1e352.md): incident.io · 2023-04-12 · Medium · 9 min read · Resilience, System design, PostgreSQL, Go, Microservices
  A Go monolith can get much of the reliability isolation of microservices by splitting workloads into separate deployments of the same binary, instead of breaking it into services.

Browse: [Latest posts](https://swe.quest/index.md) · [Topics](https://swe.quest/tags.md) · [Sources](https://swe.quest/sources.md) · [Topic map](https://swe.quest/map.md) · [Site guide (llms.txt)](https://swe.quest/llms.txt)
