Multi-Tenant AI SaaS in Phoenix: Isolation That Holds
Tenant isolation for AI SaaS in Phoenix: per-tenant API key tradeoffs, Ecto context scoping, and the pgvector bug that leaks one tenant into another.
We can't find the internet
Attempting to reconnect
Something went wrong!
Attempting to reconnect
Writing · Tag
19 posts on Elixir. Or browse the full writing index →
Tenant isolation for AI SaaS in Phoenix: per-tenant API key tradeoffs, Ecto context scoping, and the pgvector bug that leaks one tenant into another.
ReqLLM already emits token cost and latency telemetry events. The real gap is a few lines wiring them into LiveDashboard and PromEx, not another SaaS bill.
The Iron Law for has_many vs belongs_to, plus when Dataloader, subqueries, or raw SQL are the honest fix, not another preload tutorial.
Elixir/Phoenix mechanics for parallel Claude Code agents: templating PORT per worktree, one Postgres DB per branch, and asset-watcher collisions nobody covers.
Together AI raised $800M at an $8.3B valuation. Its own job postings show Elixir/Phoenix on the BEAM running auth, orgs, and access control.
A founder-readable case for Elixir as an AI startup's backend — what the BEAM gets right for agents, streaming, and durable jobs, and when to skip it.
Twelve Phoenix LiveView patterns that hold up in production — streams vs assigns, async mounts, PubSub gating, and the failure mode behind each one.
An ExUnit suite for agent loops in Elixir: asserting on tool-call order and hallucinations, not just final strings — plus evals that survive model upgrades.
Where TDD with Claude Code actually holds up in an Elixir/Phoenix codebase — ExUnit async, mix precommit, Ecto.Multi idempotency — and where it breaks.
Token-by-token LLM streaming in Phoenix LiveView, no React — the 2026 async APIs, plus the production failure modes most tutorials skip.
An MCP server lets Claude and other agents call your Phoenix app directly. How to ship one with Hermes — auth, transport, and safe tool boundaries.
Most AI agent frameworks reinvent a job queue badly. Oban already is one — durable, idempotent, retry-aware. Run an agent loop that survives a deploy mid-run.
The Hex packages I install on day one of a new Elixir project in 2026 — what each earns its place doing, and the ones I dropped along the way.
Every AI agent framework runs the same loop: observe, decide, act, repeat. Here it is in 50 lines of Elixir — no framework, just a GenServer.
You don't need a vector database — the Postgres you already run does RAG fine. The hand-rolled pgvector path in Phoenix, and when Arcana earns its place.
Go won the agent daemon and Python owns the reasoning — but the layer nobody claimed is the one that bites you: thousands of long-lived, stateful, crash-prone agents you must keep alive. That's the BEAM's home turf.
A Tencent benchmark across 20 languages found Elixir at the top of LLM code-completion rates — Claude Opus 4 hit 80.3% on Elixir vs 74.9% on C#. The reasons aren't an accident; they're the same boring properties that have always made Elixir pleasant, now compounded by AI.
async/await and goroutines solve scheduling. The BEAM solves failure. Why most concurrency pain is actually failure-isolation pain — and only the actor model plus supervision trees fix it.
We started with ten Ruby and Elixir services serving real-time messaging for 450K students across 900+ universities. Two years later we had six, fully Elixir, and on-call alerts had halved. The migration order, the patterns we leaned on, and what I'd do differently today.