planetscale-traffic-control-recommendations

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

Database Traffic Control recommendations

数据库流量控制推荐方案

Purpose

目的

For PlanetScale Postgres, recommend Traffic Control budgets and rules that protect critical traffic from runaway queries, traffic spikes, batch jobs, agents, and third-party integrations. Do not create or change budgets without approval.
针对PlanetScale Postgres,推荐能够保护关键流量免受失控查询、流量峰值、批处理任务、Agent和第三方集成影响的Traffic Control预算与规则。未经批准,不得创建或修改预算。

Preconditions

前置条件

Run this skill only for PlanetScale Postgres.
Before recommending rules, inspect:
  • Current budgets and rules.
  • Insights query patterns.
  • Current query tags.
  • Application routes and jobs.
  • Known critical paths.
  • Known expensive non-critical paths.
  • Active incidents or recent anomalies.
If query tags are missing, recommend tagging first unless a fingerprint-specific rule is clearly needed for an immediate known offender.
仅针对PlanetScale Postgres运行此Skill。
在推荐规则前,需检查以下内容:
  • 当前的预算和规则。
  • Insights查询模式。
  • 当前的查询标签。
  • 应用路由与任务。
  • 已知的关键路径。
  • 已知的高成本非关键路径。
  • 活跃事件或近期异常情况。
如果缺少查询标签,建议先进行标签设置,除非针对已知的即时违规查询明确需要特定指纹规则。

Candidate traffic slices

候选流量切片

Look for:
  • Exports.
  • Reports.
  • Search endpoints.
  • Admin dashboards.
  • Backfills.
  • Workers and queues.
  • Webhooks from third-party systems.
  • BI tools.
  • Agent-generated read queries.
  • High-frequency polling.
  • Known expensive query fingerprints.
  • Customer-triggered endpoints with high variance.
需关注以下流量类型:
  • 导出操作。
  • 报表生成。
  • 搜索端点。
  • 管理仪表盘。
  • 数据回填。
  • 工作进程与队列。
  • 第三方系统的Webhook。
  • BI工具。
  • Agent生成的读查询。
  • 高频轮询。
  • 已知的高成本查询指纹。
  • 客户触发的高差异端点。

Budget modes

预算模式

Recommend in this order:
  1. warn
    mode first for normal rollout.
  2. Observe warnings and false positives.
  3. Tune tags, fingerprints, and thresholds.
  4. Move to
    enforce
    only with explicit approval and an emergency rollback path.
Do not recommend starting directly in
enforce
unless there is an active incident and the operator explicitly asks for emergency mitigation.
按以下顺序推荐:
  1. 正常部署时优先使用
    warn
    模式。
  2. 观察警告信息与误报情况。
  3. 调整标签、指纹和阈值。
  4. 仅在获得明确批准且具备紧急回滚路径的情况下,切换至
    enforce
    模式。
除非存在活跃事件且操作人员明确要求紧急缓解,否则不建议直接从
enforce
模式开始。

Rule strategy

规则策略

Prefer tag-based rules when tags are stable and bounded:
  • source=agent
  • source=bi
  • feature=export
  • feature=report
  • route=/admin/reports
  • job=DailyBackfill
  • service=analytics-worker
Use fingerprint rules when:
  • A specific known query pattern is dangerous.
  • Tagging is missing or unreliable.
  • The query source is hard to attribute.
Use a separate budget for each materially different traffic class.
Do not combine unrelated traffic in one budget because it hides who is consuming the budget.
当标签稳定且范围明确时,优先使用基于标签的规则:
  • source=agent
  • source=bi
  • feature=export
  • feature=report
  • route=/admin/reports
  • job=DailyBackfill
  • service=analytics-worker
在以下情况下使用指纹规则:
  • 特定已知查询模式存在风险。
  • 标签缺失或不可靠。
  • 查询来源难以确定。
为每个显著不同的流量类别设置独立预算。
不要将无关流量合并到同一预算中,因为这会掩盖预算的消耗方。

Suggested default budgets

建议的默认预算

Use these as recommendation patterns, not as values to apply blindly.
将这些作为推荐模板,而非盲目套用的数值。

Agent budget

Agent预算

Target: queries tagged
source=agent
or
source=mcp
.
Intent: prevent agents from starving application traffic.
Mode: start in
warn
.
Recommendation: agents should prefer replicas and read-only scopes. Writes require human approval.
目标:标记为
source=agent
source=mcp
的查询。
目的:防止Agent占用过多资源导致应用流量资源不足。
模式:初始使用
warn
模式。
建议:Agent应优先使用副本和只读范围。写入操作需人工批准。

Export/reporting budget

导出/报表预算

Target:
feature=export
,
feature=report
, or specific report route/job.
Intent: keep customer-triggered reporting from consuming all database resources.
Mode: start in
warn
; consider
enforce
after observation.
目标:
feature=export
feature=report
或特定报表路由/任务。
目的:避免客户触发的报表操作占用全部数据库资源。
模式:初始使用
warn
模式;观察后可考虑切换至
enforce
模式。

Background job budget

后台任务预算

Target: worker service, queue, or job tags.
Intent: prevent backfills and retries from starving interactive traffic.
Mode:
warn
first; enforce only after confirming queue backpressure behavior.
目标:工作进程服务、队列或任务标签。
目的:防止数据回填与重试操作占用过多资源导致交互式流量资源不足。
模式:优先使用
warn
模式;仅在确认队列背压行为后切换至
enforce
模式。

Third-party integration budget

第三方集成预算

Target:
source=integration
, partner-specific bounded tags, or route templates for inbound integration calls.
Intent: isolate unpredictable partner behavior.
Mode:
warn
first.
目标:
source=integration
、合作伙伴特定的范围明确标签,或入站集成调用的路由模板。
目的:隔离不可预测的合作伙伴行为。
模式:初始使用
warn
模式。

Known fingerprint budget

已知指纹预算

Target: specific expensive query fingerprint.
Intent: contain a known pathological query while code or schema fixes are developed.
Mode:
warn
first unless emergency.
目标:特定的高成本查询指纹。
目的:在开发代码或架构修复方案期间,限制已知的问题查询。
模式:初始使用
warn
模式,紧急情况除外。

“Each tag value” strategy

“每个标签值”策略

When PlanetScale supports applying a budget separately for each unique value of a selected tag, recommend it for bounded tags such as:
  • application
  • service
  • route
    when normalized
  • job
  • feature
  • source
Do not recommend it for unbounded tags such as user IDs, request IDs, raw tenant IDs, emails, UUIDs, or raw URLs.
当PlanetScale支持为选定标签的每个唯一值单独应用预算时,建议对以下范围明确的标签使用此策略:
  • application
  • service
  • 标准化后的
    route
  • job
  • feature
  • source
不建议对无范围限制的标签使用此策略,例如用户ID、请求ID、原始租户ID、邮箱、UUID或原始URL。

Limits and caveats to include

需说明的限制与注意事项

Every recommendation must explain:
  • Traffic Control limits resource use; it does not replace query tuning.
  • It is not a web application firewall.
  • It does not replace application-level rate limits.
  • Limits are guardrails, not exact guarantees for every failure mode.
  • Bad tags create bad rules.
  • Enforce mode can reject queries and affect application behavior.
每个推荐方案必须说明:
  • Traffic Control仅限制资源使用,无法替代查询调优。
  • 它并非Web应用防火墙。
  • 无法替代应用层的速率限制。
  • 限制仅作为防护措施,无法为所有故障模式提供精确保障。
  • 不良标签会导致不良规则。
  • Enforce模式可能会拒绝查询并影响应用行为。

Output format

输出格式

For each proposed budget:
  • Budget name.
  • Target branch.
  • Mode: off, warn, or enforce.
  • Matched traffic slice.
  • Rule type: tag, fingerprint, keyspace, query kind.
  • Proposed tags or fingerprint.
  • Limit rationale.
  • Queries seen in Insights that justify it.
  • Safety risk.
  • Test/observe plan.
  • Rollback plan.
  • Approval requirement.
End with:
“No Traffic Control budgets or rules have been created, updated, deleted, or enforced.”
对于每个建议的预算:
  • 预算名称。
  • 目标分支。
  • 模式:off、warn或enforce。
  • 匹配的流量切片。
  • 规则类型:标签、指纹、键空间、查询类型。
  • 建议的标签或指纹。
  • 限制依据。
  • Insights中观察到的可支撑该建议的查询。
  • 安全风险。
  • 测试/观察计划。
  • 回滚计划。
  • 审批要求。
结尾需包含:
“No Traffic Control budgets or rules have been created, updated, deleted, or enforced.”