Database Traffic Control™
Postgres has no built-in way to fight back against bad queries, unexpected spikes, or runaway workloads. It accepts everything thrown at it until performance degrades or the whole thing falls over. PlanetScale's Database Traffic Control gives Postgres what it's always lacked: the ability to fight back.
How it works
Traffic Control uses budgets to cap resource usage for specific slices of your query traffic. A budget defines limits on things like:
- Server share — the percentage of overall CPU time a workload is allowed to use
- Burst limit — the maximum burst capacity, measured in seconds
- Per-query limit — a resource cap on individual queries within the budget
- Concurrency — the number of backend processes that can run simultaneously for a workload
You target traffic using rules that match on the dimensions you care about:
- Query pattern — a specific query fingerprint identified in Insights
- Application name — the app that sent the query
- Postgres user — the database user that executed it
- Custom tags — any metadata attached to your queries via SQL comments: feature name, priority level, region, customer tier, and more
Budgets can run in warn mode to observe what would be throttled, or enforce mode to actively block queries that exceed limits. Enforced budgets can also emit warnings at a separate threshold, so you know when workloads are approaching their limits before queries get blocked. Switch between modes at any time.
Use cases
Incident response
A rogue query is spiking CPU and degrading performance for your entire application. Find it in Insights, create a budget to cap its resource usage, and stabilize your database while your team investigates.
Priority-based traffic shaping
Tag queries by priority and create budgets for each tier. Core features get protected resources while lower-priority background jobs can't starve them out.
Protecting users from AI agent traffic
As AI-powered features drive more queries to your database, Traffic Control sets guardrails so automated traffic can't overwhelm the queries powering your real users' experience.
Prioritizing paid tiers
In multi-tenant apps, use tags to identify traffic by customer or tier and budget accordingly. Enterprise customers stay protected during load spikes caused by free-tier users.
Safe deployments
Tag queries by deployment version or service name. If a new release generates expensive queries, you have an instant kill switch to throttle that traffic while you roll back.
Regional traffic management
Tag queries by region and set budgets so traffic from one geography can't degrade performance for users elsewhere.
Works with Insights
PlanetScale Insights tracks historical statistics for every query running against your database. When something goes wrong, find the problematic query in Insights, see detailed usage data, and set up a budget to restrict it in just a few clicks.
Watch the demo
Getting started
Traffic Control is available today for all PlanetScale Postgres databases.
- Navigate to your database in the PlanetScale dashboard
- Open Insights and go to the Traffic control tab
- Create your first budget by selecting the dimensions and limits you want to enforce
- Start in warn mode to observe the impact, then switch to enforce
Traffic Control is also available via the PlanetScale API and CLI, so you can automate budget creation as part of your deployment pipelines.
Resources
Announcement
Read about why we built Traffic Control and how it fits into PlanetScale Postgres.
Demo application
Try it out yourself by running our demo application with pre-built budgets
Watch the walkthrough
Head to our YouTube for a walkthrough covering how to use Traffic Control