12-05 更新 实时
首页/ 技术栈/ 正文

多租户系统的公平自适应准入控制

技术栈 来源:Databricks Blog 2026-12-05 05:20 0 阅读 机器翻译
多租户系统的公平自适应准入控制

为什么仅靠速率限制和静态并发限制,可能会漏掉单个副本上的过载,从而在高流量、多租户环境中往往引发级联式的服务故障。

在 Databricks,运营一个由数百个微服务为数千个租户提供服务的大规模共享平台,带来了一项根本性的工程挑战:租户隔离。某个客户突如其来的流量激增或资源密集型操作,可能通过共享服务扩散,并拖累其他客户的平台性能。

在早前的一篇文章中,我们介绍了为保护入口流量和服务间流量而构建的高性能分布式限流系统。分布式限流提供了至关重要的第一道防线,并建立了基础的租户隔离。然而,预定义的速率限制无法直接响应实时的进程健康状况,也无法充分考量执行成本和资源需求差异巨大的请求。例如,来自某一个租户的流量激增,或单个副本的性能退化,仍可能导致过载。

为配合分布式限流,我们构建了自适应准入控制(Adaptive Admission Control,AAC)。AAC 直接集成进我们统一的 RPC 框架,是一种零配置的保护机制:它监控进程健康状态、动态调整本地并发量,并在过载情况下保持租户公平性。AAC 对 JVM 服务默认开启,包括支撑 Model Serving、AI Gateway 和 Genie 等产品的服务。我们近期还将 AAC 扩展到了 Rust、Go 和 Python 服务,例如支撑 AI Functions 的服务。本文中,我们将解释 AAC 的工作原理并分享生产环境的结果。在一次过载事件中,未引发问题的租户可用性保持在 99.79%,而在 AAC 上线前的一次类似事件中这一数字为 91.43%,其 p90 延迟也从 327 ms 降至 52 ms。

Databricks 支持多种关键业务负载,包括 SQL 分析、流式管道、批处理,以及 AI 模型训练和推理。这些负载运行在一个大规模多租户平台上,其中许多服务和基础设施组件由不同客户共享。

单个用户请求可能跨越多个服务边界,并向下游依赖扩散。在这种环境中,过载通常源于个别租户产生的意外流量峰值或资源密集型操作。静态限制——无论是按租户的速率限制,还是固定的每服务器并发上限——对此类情况的防护效果都很差,原因有二。

首先,静态限制统计的是请求数量,而负载取决于这些请求实际做了什么。一个昂贵的查询消耗的 CPU 和内存,可能抵得上大量廉价的元数据查询。如果限制设得足够低,以保护服务器免受突发昂贵请求的冲击,就会无谓地拒绝廉价流量;而如果限制设得足够高,以放行这些廉价流量,那么少数几个昂贵请求就足以压垮服务器,而限制值根本不会被触及。

其次,静态限制假定容量是固定的。垃圾回收暂停、CPU 节流、节点性能下降,或者下游依赖变慢,都会缩减某个副本在当下能够处理的量,但预先设定的限制无法随之收缩。无论哪种情况,请求都会排队、客户端会重试,于是变慢会蔓延到依赖它的服务。

因此,有效的服务保护需要一个进程内机制,围绕四条核心原则构建:

租户公平性:当容量受限时,系统应隔离过量负载的来源,并保障其他租户的可用性。

实时响应:系统必须对由垃圾回收暂停、CPU 节流或下游依赖变慢等情况引起的性能退化立即做出反应。这就排除了调用集中式服务的网络请求:每个进程都需要自己的本地控制循环来保护自身资源。

零配置运行:服务负责人不应需要为每种工作负载手动调优线程池、并发限制或队列大小。

工作守恒(work-conserving):只有在服务器不健康时才会进行公平限流。健康的服务器不会限流,即使某些租户使用的资源比其他租户多。

AAC 建立在多个大规模生产系统所展示的理念之上。LinkedIn 的 Hodor 影响了我们将 JVM 调度延迟用作过载信号的做法,而 Netflix 的 concurrency-limits 则探索了自适应并发控制。Amazon 在多租户系统公平性方面的工作,促使我们决定将租户身份作为准入控制的一等输入;微信的 DAGOR 影响了我们跨服务边界传播流量优先级的方式;Meta 的 Fail at Scale 促使我们决定使用 CoDel 来确保队列排空。Uber 随后发布了 Cinnamon,它独立地得出了类似的自适应负载削减架构。

AAC 将这些理念整合在一起,并针对 Databricks 的企业级多租户环境加以扩展——在这种环境中,单个客户就能产生足以压垮共享服务的流量。为应对这一挑战,AAC 将自适应并发控制与工作区或账户级别的细粒度公平性相结合。它还引入了工作负载感知的流量优先级,使服务在容量受限时做准入决策能够区分延迟敏感型请求与可延后处理的工作。

Databricks 的服务通常基于我们的统一 RPC 框架构建,该框架为整个服务集群提供了标准化的请求处理层。这个框架为我们提供了天然的集成点,可以一次性实现准入控制,并在各服务间一致地应用。通过将 AAC 直接集成到这一层,我们提供了默认开启的过载保护,而无需每个服务团队自行设计、配置和运维自己的准入控制系统。

以下各节将说明 AAC 如何监控进程健康状况、调整并发量,并做出兼顾公平性的准入决策。

AAC 直接位于入站 RPC 请求路径上。对于每个请求,它决定是立即接纳、排队等待容量释放,还是拒绝。AAC 与传统准入控制系统的一个关键区别在于,AAC 无需针对具体服务做配置。它不需要服务负责人手动调整线程池、并发上限或队列大小,而是根据进程的运行时健康状况和在途工作负载,动态判断该进程能安全承载多少工作。

四个主要组件协同实现准入控制:

Hiccup Sampler:一个后台线程,每隔几毫秒测量一次 JVM 调度延迟,也就是所谓的 hiccup。一个控制循环利用这一信号来调整活跃请求的并发上限。当调度延迟上升时,AAC 会下调该上限;当进程健康且接近上限时,AAC 会上调该上限。

Admission Controller:一个类似信号量的组件,负责执行 Hiccup Sampler 所维护的活跃并发上限。当有空闲许可时,它接纳请求;否则将请求送入降载路径。

Load Shedding Controller:将无法立即接纳的请求入队。它利用内部的 Fairness Stats 评估该租户近期及当前的负载,并为请求分配相应的队列优先级。

Request Scoped Executor(RSE):一个绑定到单个请求的单线程执行器,被接纳的请求通过它执行。这实现了请求级隔离,并使线程使用量与 Admission Controller 执行的全局并发上限保持一致。

综合这些组件,一个入站请求经过 AAC 的流程如下:

请求首先尝试从 Admission Controller 获取一个许可。可用许可的数量会随时间变化,取决于 Hiccup Sampler 维护的并发上限。

如果有可用许可,请求会被立即接纳,并通过其 Request Scoped Executor 执行。

如果没有可用许可,Load Shedding Controller 会进行评估,并依据该请求所属租户近期的活跃资源使用情况以及请求的流量优先级,将其加入公平队列。

当有许可被释放时,它会分配给公平队列队首的请求。该队列并非按到达时间对请求排序,而是优先考虑近期消耗容量最少的租户。等待超过超时时长的排队请求会被拒绝。借鉴 CoDel 的做法,当队列近期未能排空时,AAC 会缩短该超时时长,从而不把资源浪费在不太可能被服务的请求上。

以下各节将说明 AAC 如何确定生效的并发上限、如何在各租户之间公平分配受限的容量,以及如何隔离已被接纳请求的执行。

基于并发的自适应限流

Hiccup Sampler 将调度延迟样本的滚动窗口输入一个控制回路,由该回路调节 AAC 的最大并发值:

原文较长,译文为节选;译文由英文原文机器翻译,术语按行业惯例统一,可在文末展开原文核对。

查看英文原文(Fair and adaptive admission control for multi-tenant systems)

Why rate limits and static concurrency limits alone can miss overload on individual replicas, often leading to cascading service failures in high-volume, multi-tenant environments.

At Databricks, operating a large-scale, shared platform where hundreds of microservices serve thousands of tenants presents a fundamental engineering challenge: tenant isolation. An unexpected traffic surge or resource-intensive operation from one customer can propagate through shared services and degrade platform performance for others.

In an earlier post, we described the high-performance distributed rate-limiting system we built to protect both ingress and service-to-service traffic. Distributed rate limiting provides an essential first line of defense and establishes baseline tenant isolation. However, predefined rate limits cannot respond directly to real-time process health or fully account for requests with substantially different execution costs and resource requirements. For example, a spike of traffic from one tenant or a degradation of a single replica can still cause overload.

To complement distributed rate limiting, we built Adaptive Admission Control (AAC). Integrated directly into our unified RPC framework, AAC is a zero-configuration safeguard that monitors process health, dynamically adjusts local concurrency, and preserves tenant fairness under overload. AAC is on by default for JVM services, including those powering products like Model Serving, AI Gateway, and Genie. We've also recently extended AAC to Rust, Go, and Python services, such as those powering AI Functions. In this post, we explain how AAC works and share production results. In one overload incident, availability for non-offending tenants stayed at 99.79%, compared with 91.43% in a similar incident before AAC, and their p90 latency fell from 327 ms to 52 ms.

Databricks supports a wide range of mission-critical workloads, including SQL analytics, streaming pipelines, batch processing, and AI model training and inference. These workloads run on a large-scale, multi-tenant platform where many services and infrastructure components are shared across customers.

A single user request may traverse multiple service boundaries and fan out to downstream dependencies. In this environment, overload commonly originates from unintended traffic spikes or resource-intensive operations generated by individual tenants. Static limits, whether a per-tenant rate limit or a fixed per-server concurrency limit, guard against this poorly, for two reasons.

First, static limits count requests, while load depends on what those requests do. One expensive query can consume as much CPU and memory as a large number of cheap metadata lookups. A limit set low enough to protect a server from a burst of expensive requests needlessly rejects cheap traffic. A limit set high enough to admit that cheap traffic lets a handful of expensive requests overload the server without the limit ever being reached.

Second, a static limit assumes that capacity is fixed. A garbage collection pause, CPU throttling, a degraded node, or a slow downstream dependency can shrink what a replica can handle at that moment, but a limit chosen in advance cannot shrink with it. In either case requests queue, clients retry, and the slowdown spreads to dependent services.

Effective service protection therefore requires an in-process mechanism built around four core principles:

Tenant fairness: When capacity is constrained, the system should isolate the source of excess load and preserve availability for other tenants.

Real-time response: The system must react immediately to degradation caused by conditions such as garbage collection pauses, CPU throttling, or slow downstream dependencies. That rules out a network call to a centralized service: each process needs its own local control loop that protects its resources.

Zero-configuration operation: Service owners should not need to manually tune thread pools, concurrency limits, or queue sizes for each workload.

Work-conserving: Fair throttling only happens when a server is unhealthy. A healthy server doesn't throttle, even if some tenants use more resources than others.

AAC builds on ideas demonstrated by several large-scale production systems. LinkedIn’s Hodor influenced our use of JVM scheduling delays as an overload signal, while Netflix’s concurrency-limits explored adaptive concurrency control. Amazon’s work on fairness in multi-tenant systems informed our decision to make tenant identity a first-class input to admission control, WeChat’s DAGOR influenced our approach to propagating traffic priority across service boundaries, and Meta's Fail at Scale informed our decision to use CoDel to ensure queue draining. Uber subsequently published Cinnamon, which independently arrived at a similar adaptive load-shedding architecture.

AAC brings these ideas together and extends them for Databricks’ enterprise multi-tenant environment, where a single customer can generate enough traffic to overwhelm a shared service. To address this challenge, AAC combines adaptive concurrency control with fine-grained fairness at the workspace or account level. It also incorporates workload-aware traffic priority, allowing services to distinguish latency-sensitive requests from deferrable work when making admission decisions under constrained capacity.

Databricks services are ordinarily built using our unified RPC framework, which provides a standardized request-processing layer across the fleet. This framework gives us a natural integration point to implement admission control once and apply it consistently across services. By integrating AAC directly into this layer, we provide default-on overload protection without requiring every service team to design, configure, and operate its own admission-control system.

The following sections explain how AAC monitors process health, adjusts concurrency, and makes fairness-aware admission decisions.

AAC sits directly in the inbound RPC request path. For each request, it decides whether to admit it immediately, queue it until capacity becomes available, or reject it. A key difference between AAC and traditional admission-control systems is that AAC requires no service-specific configuration. Instead of asking service owners to manually tune thread pools, concurrency limits, or queue sizes, AAC dynamically determines how much work the process can safely handle based on its runtime health and the workload in flight.

Four primary components work together to implement admission control:

Hiccup Sampler: A background thread that measures JVM scheduling delays, also known as hiccups, every few milliseconds. A control loop uses this signal to adjust the active request concurrency limit. When scheduling delays increase, AAC lowers the limit; when the process is healthy and nearing the limit, AAC increases it.

Admission Controller: A semaphore-like component that enforces the active concurrency limit maintained by the Hiccup Sampler. It admits a request when a permit is available and sends the request to the load-shedding path otherwise.

Load Shedding Controller: Enqueues requests that cannot be admitted immediately. It uses internal Fairness Stats to evaluate the tenant’s recent and active load and assign the request an appropriate queue priority.

Request Scoped Executor (RSE): A single-threaded executor scoped to an individual request, that admitted requests execute through. This provides per-request isolation and keeps thread usage aligned with the global concurrency limit enforced by the Admission Controller.

image1.png

Putting these components together, an incoming request passes through AAC as follows:

The request first attempts to acquire a permit from the Admission Controller. The number of available permits changes over time based on the concurrency limit maintained by the Hiccup Sampler.

If a permit is available, the request is admitted immediately and executed through its Request Scoped Executor.

If no permit is available, the Load Shedding Controller evaluates and enqueues the request into a fair queue using its tenant’s recent and active resource usage, along with the request’s traffic priority.

When a permit is released, it goes to the request at the head of the fair queue. Rather than ordering requests by arrival time, the queue prioritizes tenants that have consumed the least capacity recently. Queued requests that wait past a timeout are rejected. Borrowing from CoDel, AAC shortens that timeout when the queue hasn't drained recently, so it doesn't waste resources on requests that are unlikely to be served.

The following sections explain how AAC determines the active concurrency limit, distributes constrained capacity fairly across tenants, and isolates the execution of admitted requests.

Adaptive Concurrency-Based Throttling

The Hiccup Sampler feeds a rolling window of scheduling-delay samples into a control loop that tunes AAC’s maximum concurrency:

When a large share of recent samples exceed the hiccup threshold, AAC reduces the concurrency limit, decreasing the amount of new work admitted into the process. When only a small share of recent samples exceed it and active requests are approaching the current limit, AAC increases the limit to make use of available capacity. Otherwise, AAC leaves the limit unchanged.

This feedback loop allows AAC to adapt to the capacity available at runtime. The concurrency limit contracts when the process is under stress and expands when the process remains healthy, without requiring service owners to determine a static limit in advance.

Customer Fairness Enforcement

When the server is overloaded, AAC distributes capacity fairly among the tenants currently in flight. It maintains per-request statistics for each fairness identity, currently defined by the combination of RPC method and tenant ID. This identity is extensible without changing the admission-control algorithm.

Each queued request receives a weight based on its tenant’s recent load, active already-admitted work, and traffic priority. The more capacity AAC has spent or committed to a tenant, the lower that tenant’s position in the priority queue. This allows underserved tenants to be admitted first as capacity becomes available.

Isolation and Elastic Threading Model

Many Databricks JVM services run on OS threads. Before AAC, each service had to manage its own thread pools, and thread-pool exhaustion was a common cause of overload. To fully realize the benefit of dynamic concurrency, we introduced an isolated, elastic threading model.

Each admitted request receives its own Request Scoped Executor (RSE), a serial executor multiplexed over a shared, direct-handoff, unbounded cached thread pool. When an RSE has work to run, the pool assigns an idle thread or creates a new one.

The RSE ties thread usage to AAC's adaptive concurrency limit. An RSE runs one task at a time, so however a handler is written, the work it runs through its RSE occupies at most one thread at any moment. A blocking handler holds that thread for the life of the request. An asynchronous handler holds it only while one of its callbacks is running, and holds no thread while it waits on a downstream call. Across the process, request-processing threads therefore never exceed the number of admitted requests, and because the underlying pool is unbounded, an admitted request never waits for a thread. When AAC lowers the limit in response to CPU saturation or throttling, thread usage falls with it.

This holds for work that runs through the RSE, which is the framework's default: blocking RPC handlers run on it automatically, and asynchronous handlers pass it as the executor for their callbacks. It is a contract with the application, not a restriction the runtime enforces. A handler that needs parallelism within a single request can still use a thread pool of its own; those threads are not counted against the concurrency limit, so the service is responsible for sizing that pool.

Success Stories from Production

Fair Rejection Under Overload: Protecting Non-Offending Tenants

AAC isolates tenant-driven overload. Without AAC, non-offending tenants experienced sharply reduced availability and elevated latency. With AAC, their overall availability remained at 99.79% and p90 latency stayed at 52 ms, while the impact remained concentrated on the tenant generating excess traffic.

Setup: An important service early in the request path experienced two similar production overload events, one before AAC was enabled and another after its deployment. Both events involved the same service, with overload driven primarily by excess traffic from a single tenant, making them useful for evaluating AAC’s effectiveness in containing tenant-driven overload.

Before enabling AAC: Load generated by one tenant degraded availability and tail latency for all tenants. Both offending and non-offending customers experienced elevated rejection rates and increased request latency.

After enabling AAC: AAC dynamically reduced effective concurrency to protect process health. At the same time, fairness enforcement at the tenant level ensured that rejections were primarily applied to the offending tenant, preserving service quality for others.

Outcome: compared to a deployment without AAC:

Non-offending tenant overall availability improved from 91.43% → 99.79%

Non-offending p90 served latency dropped from 327 ms → 52 ms

This demonstrates that AAC can enforce fairness under real overload while significantly improving latency and availability for non-offending tenants.

Maintaining Service Availability During a Traffic Spike

AAC safely expands concurrency during a traffic spike without rejecting traffic or increasing success latency. Healthy JVM hiccup signals allowed AAC to raise the maximum concurrency from approximately 100 to 750, supporting more than 300 active requests per pod which would otherwise be rejected by the default concurrency limit.

Setup: A critical service experienced a sudden traffic surge against a single API endpoint. Despite the increase in active requests, the underlying pods remained healthy and had additional capacity.

Before AAC: The server’s statically configured concurrency limit acted as a hard ceiling. Once active requests reached that limit, the server would begin rejecting traffic, potentially affecting endpoints unrelated to the surge even though the pods could safely handle more work.

After AAC: Healthy JVM hiccup signals allowed AAC to automatically raise the maximum concurrency limit from approximately 100 to 750 requests per pod. Active concurrency increased beyond 300 requests per pod without triggering unnecessary rejections.

Outcome: The service absorbed the traffic spike while pod latency remained low and unrelated endpoints continued operating normally. AAC can therefore safely expand concurrency when capacity is available, rather than only reducing concurrency during overload.

Protecting a large-scale, multi-tenant platform requires more than setting static traffic limits. Distributed rate limiting provides an essential first line of defense, while Adaptive Admission Control protects each service instance based on its real-time health and the workload it is actually processing.

AAC combines a local health signal, dynamic concurrency control, and tenant-aware fair scheduling. This allows services to reduce admitted work when a process is under stress, expand concurrency when additional capacity is available, and contain the impact of overload to the tenant generating it.

By integrating AAC into our unified RPC framework, we provide this protection by default without requiring every service team to tune and operate its own admission-control system. Production examples demonstrate the result: healthier services, better isolation between tenants, and more efficient use of available capacity.

If you're interested in building reliable systems for large-scale, multi-tenant workloads, come join the Databricks engineering team!

Get the latest posts in your inbox

原文为英文,正文由自动抓取并保留原文。

本文由采集器自动同步

原文发布于 Databricks Blog(Fair and adaptive admission control for multi-tenant systems),标题、摘要与正文由机器翻译,术语按行业惯例统一,未经人工逐句校订。

阅读原文 ↗