跳到正文
实时
Databricks Blog·· 1 小时前34

Databricks 构建 Adaptive Admission Control (AAC) 实现多租户系统公平与自适应准入控制

Fair and adaptive admission control for multi-tenant systems

要点速览

Databricks 发布 Adaptive Admission Control (AAC) 入侵检测系统,集成统一 RPC 框架监控进程健康动态调整本地并发。

正文

Introduction

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.

Background

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.

Architecture

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:

  1. 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.
  2. If a permit is available, the request is admitted immediately and executed through its Request Scoped Executor.
  3. 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.
  4. 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

image2.png

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

image4.png image3.png

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.

Conclusion

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.

Join us

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

来源: Databricks Blog · databricks.com