Fly.ioProblem & solution
Petsem: Sometimes Dead Is Better
Summary
Fly.io replaced HashiCorp Vault with a custom secrets manager called Petsem to address performance and reliability issues at scale. Vault’s Raft-based cluster required low-latency connections, causing a p99 of 10 seconds for app secrets reads during boot and a hard dependency on the IAD region. Petsem uses a write master in IAD with read replicas across regions, dropping p99 from 10 seconds to 300ms. It enforces scoped access via macaroons: a worker must present its credential and a third-party discharge token verifying it hosts that app. Petsem also supports Fly KMS for encrypt, decrypt, sign, and verify operations that never expose the secret to the app.
Context
Fly.io was built on Hashistack (Consul, Nomad, Vault). As they scaled, they hit edges and replaced Consul in 2022 and Nomad in 2023. Vault’s Raft-based cluster required low-latency connections, causing a p99 of 10 seconds for app secrets reads during boot and a hard dependency on the IAD region. Enterprise multi-region Vault would cost roughly a fully loaded engineer’s salary per year. Vault also lacked a way to guarantee that only the worker hosting an app could read its secrets, as policy updates could arrive after Machines were placed on a worker.
Approach / What changed
Petsem is a custom secrets manager that replaces HashiCorp Vault. It uses a write master in IAD with read replicas across regions to reduce latency and eliminate single-region dependency. Access is scoped via macaroons: a worker must present its credential and a third-party discharge token from a separate service that verifies the worker is hosting the specific app. The migration started in March 2024, ran Vault and Petsem side by side, and cut over in July 2025. Petsem also supports Fly KMS for encrypt, decrypt, sign, and verify operations without exposing the secret to the app.
Takeaways
Petsem reduced p99 secrets read latency from 10 seconds to 300ms by using a write master in IAD with read replicas across regions, eliminating the single-region dependency of Vault’s Raft cluster.
Petsem enforces scoped access using macaroons: a worker must present both its credential and a third-party discharge token from a separate service that confirms the worker is hosting the specific app, preventing a compromised worker from reading all secrets.
Fly KMS allows apps to perform encrypt, decrypt, sign, and verify operations using secrets stored in Petsem without the secret ever leaving Petsem or being exposed to the app.
FAQ
Why did Fly.io replace Vault with Petsem?
Vault's Raft-based cluster required low-latency connections, causing a p99 of 10 seconds for app secrets reads during boot and a single-region dependency. Enterprise multi-region Vault would cost roughly a fully loaded engineer's salary per year, so they built Petsem.
How does Petsem ensure only authorized workers can read app secrets?
Petsem uses macaroons: a worker must present its credential and a third-party discharge token from a separate service that verifies the worker is hosting that specific app. The worker receives the app's service token from the orchestrator when the app is placed on the worker.
What is Fly KMS and how does it relate to Petsem?
Fly KMS is a feature built on top of Petsem that allows apps to perform encrypt, decrypt, sign, and verify operations using secrets stored in Petsem. The secret never leaves Petsem or lives in the app, preventing leakage or theft.
Source and freshness
- Source
- fly.io
- Published
- Added to Yomu
Summaries are generated from the original by a language model. Check the original before relying on it.
Keep reading
Related reading
The Good Stuff
Paid picks we use ourselves. Links carry a referral code — a subscription through one earns us a commission at no extra cost to you.
The best engineering reads, once a week
One useful email. Unsubscribe anytime.