The fastest, litest AI Gateway. Rust core with Python SDK. Call 100+ LLM APIs in OpenAI (or native) format with cost tracking, guardrails, load balancing, and logging [Bedrock, Azure, OpenAI, Anthropic, OpenAI, VertexAI, vLLM, Nvidia NIM]
Python ai-gatewayanthropicazure-openaibedrockgatewaylangchainlitellmllmllm-gatewayllmopsmcp-gatewayopenaiopenai-proxyrustrust-aivertex-ai
test(perf): set every perf ceiling to 1.2x the lane median (#47590)
Kerry Lu3c0e08146d80
diff --git a/tests/e2e/perf/cases/mixed_size_requests_2rps.py b/tests/e2e/perf/cases/mixed_size_requests_2rps.pyindex d4f1fdddc9c..3acd8671acd 100644--- a/tests/e2e/perf/cases/mixed_size_requests_2rps.py+++ b/tests/e2e/perf/cases/mixed_size_requests_2rps.py@@ -62,24 +62,24 @@ CASE: Final = PerformanceTestCase(),limits=(Limit("unexpected_status_count", max=3),- Limit("gateway_added_seconds", percentile=50, max=0.58),- Limit("gateway_added_seconds", percentile=99, max=6.1),- Limit("litellm_overhead_seconds", percentile=50, max=0.1),- Limit("litellm_overhead_seconds", percentile=99, max=3.4),- Limit("litellm_response_seconds", percentile=50, max=1.0),- Limit("litellm_response_seconds", percentile=99, max=3.8),- Limit("prometheus_redis_latency_mean_seconds", max=0.005),- Limit("postgres_active_sessions", max=0.016),- Limit("postgres_slowest_statement_seconds", max=0.25),- Limit("postgres_peak_connections", max=45),- Limit("time_to_first_token_seconds", percentile=50, max=2.7),- Limit("time_to_first_token_seconds", percentile=99, max=8.8),+ Limit("gateway_added_seconds", percentile=50, max=0.29),+ Limit("gateway_added_seconds", percentile=99, max=2.7),+ Limit("litellm_overhead_seconds", percentile=50, max=0.052),+ Limit("litellm_overhead_seconds", percentile=99, max=1.8),+ Limit("litellm_response_seconds", percentile=50, max=0.93),+ Limit("litellm_response_seconds", percentile=99, max=2.7),+ Limit("prometheus_redis_latency_mean_seconds", max=0.002),+ Limit("postgres_active_sessions", max=0.0094),+ Limit("postgres_slowest_statement_seconds", max=0.042),+ Limit("postgres_peak_connections", max=23),+ Limit("time_to_first_token_seconds", percentile=50, max=1.56),+ Limit("time_to_first_token_seconds", percentile=99, max=4.5),Limit("memory_growth_megabytes", max=600),- Limit("cpu_seconds_per_request", max=1.26),- Limit("postgres_calls_per_request", max=3.5),- Limit("postgres_max_statement_per_request", max=0.5),- Limit("postgres_max_background_statement_per_request", max=0.9),- Limit("redis_calls_per_request", max=21.0),+ Limit("cpu_seconds_per_request", max=0.57),+ Limit("postgres_calls_per_request", max=2.64),+ Limit("postgres_max_statement_per_request", max=0.43),+ Limit("postgres_max_background_statement_per_request", max=0.86),+ Limit("redis_calls_per_request", max=15.4),),background_cap_exempt_tables=frozenset({"LiteLLM_DailyGuardrailMetrics"}),)diff --git a/tests/e2e/perf/cases/small_bodies_5rps.py b/tests/e2e/perf/cases/small_bodies_5rps.pyindex f93c64afba4..4bf58cde3a5 100644--- a/tests/e2e/perf/cases/small_bodies_5rps.py+++ b/tests/e2e/perf/cases/small_bodies_5rps.py@@ -64,21 +64,21 @@ CASE: Final = PerformanceTestCase(),limits=(Limit("unexpected_status_count", max=3),- Limit("gateway_added_seconds", percentile=50, max=0.29),- Limit("litellm_overhead_seconds", percentile=50, max=0.012),+ Limit("gateway_added_seconds", percentile=50, max=0.165),+ Limit("litellm_overhead_seconds", percentile=50, max=0.006),Limit("litellm_overhead_seconds", percentile=99, max=0.35),- Limit("litellm_response_seconds", percentile=50, max=1.0),- Limit("litellm_response_seconds", percentile=99, max=2.0),- Limit("prometheus_redis_latency_mean_seconds", max=0.006),- Limit("postgres_active_sessions", max=0.01),- Limit("postgres_slowest_statement_seconds", max=0.025),- Limit("postgres_peak_connections", max=45),- Limit("time_to_first_token_seconds", percentile=99, max=3.7),+ Limit("litellm_response_seconds", percentile=50, max=0.91),+ Limit("litellm_response_seconds", percentile=99, max=1.6),+ Limit("prometheus_redis_latency_mean_seconds", max=0.0026),+ Limit("postgres_active_sessions", max=0.0052),+ Limit("postgres_slowest_statement_seconds", max=0.011),+ Limit("postgres_peak_connections", max=23),+ Limit("time_to_first_token_seconds", percentile=99, max=2.05),Limit("memory_growth_megabytes", max=100),- Limit("postgres_calls_per_request", max=1.8),- Limit("postgres_max_statement_per_request", max=0.5),- Limit("postgres_max_background_statement_per_request", max=0.9),- Limit("redis_calls_per_request", max=18),- Limit("cpu_seconds_per_request", max=0.29),+ Limit("postgres_calls_per_request", max=1.31),+ Limit("postgres_max_statement_per_request", max=0.27),+ Limit("postgres_max_background_statement_per_request", max=0.92),+ Limit("redis_calls_per_request", max=13.8),+ Limit("cpu_seconds_per_request", max=0.15),),)diff --git a/tests/e2e_harness/perf/test_upgrade.py b/tests/e2e_harness/perf/test_upgrade.pyindex 89e3a620f48..1f2bc8c46cb 100644--- a/tests/e2e_harness/perf/test_upgrade.py+++ b/tests/e2e_harness/perf/test_upgrade.py@@ -295,19 +295,30 @@ def test_invalid_200_is_not_an_allowed_non_200(failed: WireRecord) -> None:_ = Probe().monitor().poll((failed,))+def _ceiling(metric: str, percentile: int | None = None) -> float:+ return next(+ limit.max for limit in upgrade_case().limits if limit.metric == metric and limit.percentile == percentile+ )++@pytest.mark.parametrize(- "failures,overhead,ttft,growth,expected",+ "over,expected",[- (3, 0.29, 3.7, 100, ()),- (4, 0.29, 3.7, 100, ("unexpected_status_count",)),- (3, 0.30, 3.7, 100, ("gateway_added_seconds percentile 50",)),- (3, 0.29, 3.8, 100, ("time_to_first_token_seconds percentile 99",)),- (3, 0.29, 3.7, 101, ("memory_growth_megabytes",)),+ ("", ()),+ ("unexpected_status_count", ("unexpected_status_count",)),+ ("gateway_added_seconds", ("gateway_added_seconds percentile 50",)),+ ("time_to_first_token_seconds", ("time_to_first_token_seconds percentile 99",)),+ ("memory_growth_megabytes", ("memory_growth_megabytes",)),],)def test_upgrade_verdict_uses_regular_limits_without_cpu_or_datastore_samples(- failures: int, overhead: float, ttft: float, growth: float, expected: tuple[str, ...]+ over: str, expected: tuple[str, ...]) -> None:+ """Each sample sits exactly on the case's ceiling, so only the one nudged past it goes over."""+ failures: Final = int(_ceiling("unexpected_status_count")) + (over == "unexpected_status_count")+ overhead: Final = _ceiling("gateway_added_seconds", 50) * (1.01 if over == "gateway_added_seconds" else 1)+ ttft: Final = _ceiling("time_to_first_token_seconds", 99) * (1.01 if over == "time_to_first_token_seconds" else 1)+ growth: Final = _ceiling("memory_growth_megabytes") + (over == "memory_growth_megabytes")nonstream: Final = tuple(record(i).model_copy(update={"total_s": overhead, "mock_delay_s": 0}) for i in range(100))stream: Final = record(100).model_copy(update={"stream": True, "first_token_s": ttft})observed: Final = Observation(