---
title: "Petsem: Sometimes Dead Is Better"
description: "Fly.io replaced HashiCorp Vault with Petsem, a home-grown secrets store that keeps a single write master in IAD but adds regional read replicas, trading strict consistency for availability."
url: "https://swe.quest/articles/petsem-sometimes-dead-is-better-1fcc24cdcd7724b3"
canonical: "https://fly.io/blog/petsem/"
source: "Fly.io"
published: "2026-11-20"
difficulty: "medium"
kind: "Case study"
reading_minutes: 6
tags: ["security","identity-auth","replication","system-design","cloud"]
---

# Petsem: Sometimes Dead Is Better

A post on [Fly.io](https://swe.quest/sources/flyio.md), published 2026-11-20, 6 min read, Case study. Original: [https://fly.io/blog/petsem/](https://fly.io/blog/petsem/)

## Summary

Fly.io replaced HashiCorp Vault with Petsem, a home-grown secrets store that keeps a single write master in IAD but adds regional read replicas, trading strict consistency for availability. The change cut p99 secret-load time on app boot from 10s to 300ms and removed a single-region dependency, avoiding an enterprise multi-region Vault license costing roughly an engineer's salary per year. Macaroon third-party discharge tokens restrict secret reads to workers actually hosting the app, so a compromised host can only reach secrets for apps placed on it, and denied reads trigger alerts. The migration ran dual-write and side-by-side from 2024 to a July 2025 cutover, and Fly KMS builds on Petsem to offer encrypt, decrypt, sign and verify operations without the secret ever leaving the store.

Written by swe.quest, not by the author.

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

## Topics

- [Security](https://swe.quest/tags/security.md) (Security)
- [Identity & auth](https://swe.quest/tags/identity-auth.md) (Security)
- [Replication](https://swe.quest/tags/replication.md) (Distributed systems)
- [System design](https://swe.quest/tags/system-design.md) (Architecture & design)
- [Cloud platforms](https://swe.quest/tags/cloud.md) (Infrastructure)

## Prerequisites

- secrets management basics ([easy posts on Engineering management](https://swe.quest/tags/engineering-management.md?difficulty=easy))
- Raft consensus ([easy posts on Consensus](https://swe.quest/tags/consensus.md?difficulty=easy))
- macaroon tokens

## Keywords

Petsem, HashiCorp Vault, Fly.io, macaroons, Fly KMS, Raft, flyd

## Related posts

- [Skip the API, Ship Your Database](https://swe.quest/articles/skip-the-api-ship-your-database-848af5fd83020408.md): Fly.io · 2023-09-13 · Medium · 5 min read · SQLite, API design, Replication, Multi-tenancy, System design
  Instead of designing an API for internal services, Fly.io ships them a read-only SQLite replica via LiteFS, letting consumers query and join data with plain SQL.
- [Session revocations at scale](https://swe.quest/articles/session-revocations-at-scale-0e845eb64b268c30.md): Canva Engineering · 2026-07-22 · Medium · 9 min read · Identity & auth, Caching, Scaling, System design, Storage systems
  Canva moved its gateway session-revocation cache from per-pod MySQL loads to sorted binary chunks in S3, eliminating the database stampede when hundreds of gateway pods started during deploys.
- [How Cedalio uses Neon for an efficient development workflow](https://swe.quest/articles/how-cedalio-uses-neon-for-an-efficient-development-workflow-265835e6a16f5a00.md): Neon · 2024-05-29 · Easy · 5 min read · PostgreSQL, CI/CD, Multi-tenancy, Serverless
  Cedalio, an ESG data verification startup, moved from DynamoDB to Postgres and picked Neon over RDS for a simpler API and console.
- [How Hugging Face Scaled Secrets Management for AI Infrastructure](https://swe.quest/articles/how-hugging-face-scaled-secrets-management-for-ai-infrastructure-9737f7d559f7a125.md): Hugging Face · 2025-03-31 · Medium · 5 min read · Security, Kubernetes, Identity & auth, Infrastructure as code, CI/CD
  Hugging Face moved secrets management to Infisical as its infrastructure grew from AWS-only to multi-cloud (Azure, GCP), choosing it over HashiCorp Vault for developer workflows and multi-cloud abstraction.
- [Staying Evergreen: How we automated secure access and repo hygiene in a shared org](https://swe.quest/articles/staying-evergreen-how-we-automated-secure-access-and-repo-hygiene-in-a-shared-b76aa86640c047a2.md): GitHub Engineering · 2026-10-15 · Medium · 8 min read · Identity & auth, Developer tools, Security, System design
  Evergreen is a Go-based GitHub App that automates quarterly outside-collaborator access reviews and stale-repo archival in a shared org of 1,400+ GitHub employees, customers and partners, built entirely from native primitives: scheduled Actions firing repository\_dispatch, webhooks, issue checklists, custom properties, and per-repo JSON state files in git that double as the audit trail.

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)
