---
title: "Petsem: Sometimes Dead Is Better"
description: "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."
---

# Petsem: Sometimes Dead Is Better

[Fly.io](https://yomu.fyi/company/fly-io) · Nov 20, 2026

**Type:** Problem & solution

## 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.

**Tags:** [Fly.io](https://yomu.fyi/topic/fly-io), [Macaroons](https://yomu.fyi/topic/macaroons), [Scalability](https://yomu.fyi/topic/scalability), [Security](https://yomu.fyi/topic/security), [Vault](https://yomu.fyi/topic/vault)

- Source: [Fly.io](https://fly.io/blog/petsem)
- Source URL: https://fly.io/blog/petsem
- Ingested by Yomu: 2026-11-20T15:00:13.402Z

[Read original post](https://fly.io/blog/petsem)
