Load Testing AI Systems
An LLM endpoint does not have one latency. It has a time to first token and a tokens-per-second rate, and they fail differently.
11 min read11 মিনিটে পড়া যায় · 6 sections6টি সেকশন · 3 sources3টি সোর্স · updated Nov 2026আপডেট: Nov 2026
TTFT versus total time under loadলোডের নিচে TTFT বনাম মোট সময়
Add long questions to the mix and see the first token stay quick while the tokens and the time pile up.মিশ্রণে লম্বা প্রশ্ন যোগ করুন আর দেখুন প্রথম token দ্রুতই থাকে, কিন্তু token আর সময় জমতে থাকে।
You’ll learnআপনি শিখবেন
- TTFT is not total timeTTFT আর মোট সময় এক নয়
- Total time follows output lengthমোট সময় আউটপুট দৈর্ঘ্য মেনে চলে
- A weighted mix finds the bottleneckওজনযুক্ত মিশ্রণ bottleneck খুঁজে দেয়
- Truncation and fallback hide in a 200কাটা ও fallback 200-এর আড়ালে লুকায়
In plain words
Load testing an AI system measures five things that a normal API load test does not.
- Time to first token (TTFT). How long until the user sees the first word. This is what the user perceives as responsiveness. A request that takes ten seconds total but gives its first token in 300ms feels fast.
- Tokens per second (TPS). How fast the model produces the rest. This is what determines how long a long answer takes to arrive.
- Total latency. The sum, and it is a function of the output length, not just of the server. A prompt that produces 800 tokens takes longer than one that produces 50, on the same machine.
The consequence is that the load test has to control the output length, or it is not comparing like with like. max_tokens caps the output length, and it has to be the same on every arm Source 2সোর্স 2. The model can still stop earlier, so also record output_tokens.
The fourth thing is rate limiting. Every provider limits you, and the limit is measured in requests per minute and in input and output tokens per minute, and the token limits are often the ones you hit first Source 3সোর্স 3. A load test that ignores the token rate will hit the limit and measure your retry logic instead of your server.
And the fifth is that load has a quality cost. A server under strain can degrade by truncating, by serving a shorter answer, or by falling back to a smaller model. A load test that only checks the status code misses all three.
সহজ English
Load testing an AI system measures five things that a normal API load test does not.
- Time to first token (TTFT). How long until the user sees the first word. This is how fast the system feels. A request that takes ten seconds in total but shows its first token in 300ms feels fast.
- Tokens per second (TPS). How fast the model writes the rest of the answer. It decides how long a long answer takes to arrive.
- Total latency. The two added together. It depends on the output length, not only on the server. A prompt that gives 800 tokens takes longer than one that gives 50, on the same machine.
So the load test has to control the output length. Otherwise you are not comparing like with like. max_tokens caps the output length. It must be the same on every arm of the test Source 2সোর্স 2. The model can still stop earlier, so also record output_tokens.
The fourth thing is rate limiting. Every provider limits you. The limit is counted in requests per minute and in input and output tokens per minute. The token limits are often the ones you hit first Source 3সোর্স 3. If the test ignores the token rate, it hits the limit and measures your retry logic instead of your server.
The fifth is that load has a quality cost. A strained server can cut answers short, give a shorter answer, or fall back to a smaller model. A test that only checks the status code misses all three.
বাংলা ব্যাখ্যা
AI সিস্টেমের load test পাঁচটা জিনিস মাপে যেগুলো সাধারণ API load test মাপে না:
- Time to first token (TTFT)। ব্যবহারকারী প্রথম শব্দ কবে দেখে। এটাই ব্যবহারকারীর কাছে দ্রুততার অনুভূতি। মোট দশ সেকেন্ড লাগলেও প্রথম token ৩০০ms-এ এলে দ্রুত মনে হয়।
- Tokens per second (TPS)। বাকি উত্তর model কত দ্রুত বানায়। লম্বা উত্তর কত সময়ে আসবে তা এটা নির্ধারণ করে।
- মোট latency। দুটোর যোগ, আর এটা আউটপুট দৈর্ঘ্যের ফলাফল, শুধু server-এর নয়। ৮০০ token উৎপন্ন করা prompt একই মেশিনে ৫০ token উৎপন্ন করা prompt-এর চেয়ে বেশি সময় নেয়।
ফলে load test-এ আউটপুট দৈর্ঘ্য নিয়ন্ত্রণ করতে হবে, নইলে তুলনা তুলনা হবে না। max_tokens আউটপুট দৈর্ঘ্যের ঊর্ধ্বসীমা ঠিক করে, আর প্রতিটা arm-এ এটা একই রাখতে হবে Source 2সোর্স 2। model তবু আগে থামতে পারে, তাই output_tokens-ও রেকর্ড করুন।
চতুর্থ বিষয় হলো rate limiting। প্রতিটা provider আপনাকে সীমা দেয়, আর সেই সীমা মাপা হয় প্রতি মিনিটে request আর প্রতি মিনিটে input ও output token দিয়ে, আর token সীমাতেই প্রায়ই আগে ঠেকতে হয় Source 3সোর্স 3। যে load test token rate উপেক্ষা করে সেটা সীমায় ঠেকে গিয়ে আপনার server নয়, retry logic মাপবে।
আর পঞ্চম হলো load-এর একটা মানের দাম আছে। চাপের নিচের server উত্তর কেটে দিতে পারে, ছোট উত্তর দিতে পারে, বা ছোট model-এ ফিরে যেতে পারে। শুধু status code দেখা একটা load test তিনটিই মিস করে।
How it works
The load profile has to be shaped like the real traffic, and real LLM traffic is not uniform. It is bursty, it has a long tail of long prompts, and its arrival is correlated with business hours. A flat ramp tells you almost nothing.
Locust drives the load and gives you the percentile numbers Source 1সোর্স 1:
from locust import HttpUser, task, between
LONG_POLICY_QUESTION = "Explain the full return, refund, and warranty policy for laptops, including every exception."
class SupportUser(HttpUser):
wait_time = between(1, 3)
@task(10)
def short_question(self):
self.client.post("/api/chat", json={
"message": "How long do I have to return a laptop?",
"max_tokens": 64,
})
@task(2)
def long_question(self):
self.client.post("/api/chat", json={
"message": LONG_POLICY_QUESTION,
"max_tokens": 800,
})The weighted mix matters: the long question is about one request in six (weights 10 and 2) but a much larger share of the tokens and of the wall-clock time. A load test with only short questions will never find the bottleneck.
The measurement has to separate TTFT from total time, and that means the client has to read the stream rather than wait for the body. Locust's self.client.post does not stream, so use a separate streaming client such as this one for the timing:
import json
import time
import httpx
async def measure_one(client: httpx.AsyncClient, payload: dict) -> dict:
# Assumes /api/chat forwards the Anthropic streaming events as server-sent events.
start = time.perf_counter()
first_token_at = None
input_tokens = 0
output_tokens = 0
stop_reason = None
model = None
async with client.stream("POST", "/api/chat", json=payload) as response:
async for line in response.aiter_lines():
if not line.startswith("data: "):
continue
event = json.loads(line[len("data: "):])
kind = event.get("type")
if kind == "message_start":
model = event["message"]["model"]
input_tokens = event["message"]["usage"]["input_tokens"]
elif kind == "content_block_delta" and event["delta"].get("type") == "text_delta":
if first_token_at is None:
first_token_at = time.perf_counter() # first text, not message_start
elif kind == "message_delta":
stop_reason = event["delta"].get("stop_reason")
output_tokens = event["usage"]["output_tokens"]
end = time.perf_counter()
first_token_at = first_token_at or end
return {
"started_at": start,
"ttft_ms": (first_token_at - start) * 1000,
"total_ms": (end - start) * 1000,
"tps": output_tokens / max(end - first_token_at, 1e-6),
"input_tokens": input_tokens,
"output_tokens": output_tokens,
"stop_reason": stop_reason,
"model": model,
}The quality under load check is the one nobody writes. The test asserts that the answer is still complete and still correct at peak load:
def test_the_answer_is_still_complete_under_load(load_results):
# load_results: the list of dicts that measure_one returned during the run
truncated = [r for r in load_results if r["stop_reason"] == "max_tokens"]
assert len(truncated) / len(load_results) < 0.01, (
f"{len(truncated)} answers were truncated under load"
)Because a truncated answer can still be grammatical, the assertion on the stop reason catches it where a keyword check would not. The same applies to a fallback to a smaller model: the response is fine, and the quality silently drops.
সহজ English
The load should look like real traffic. Real LLM traffic is not even. It comes in bursts. It has a long tail of long prompts. It follows business hours. A flat ramp tells you almost nothing.
Locust drives the load and gives you the percentile numbers Source 1সোর্স 1:
from locust import HttpUser, task, between
LONG_POLICY_QUESTION = "Explain the full return, refund, and warranty policy for laptops, including every exception."
class SupportUser(HttpUser):
wait_time = between(1, 3)
@task(10)
def short_question(self):
self.client.post("/api/chat", json={
"message": "How long do I have to return a laptop?",
"max_tokens": 64,
})
@task(2)
def long_question(self):
self.client.post("/api/chat", json={
"message": LONG_POLICY_QUESTION,
"max_tokens": 800,
})The mix is weighted. The long question is about one request in six (weights 10 and 2). But it takes a much larger share of the tokens and of the waiting time. A test with only short questions never finds the bottleneck.
The measurement must separate TTFT from total time. So the client has to read the stream instead of waiting for the whole body. Locust's self.client.post does not stream, so use a separate streaming client such as this one for the timing:
import json
import time
import httpx
async def measure_one(client: httpx.AsyncClient, payload: dict) -> dict:
# Assumes /api/chat forwards the Anthropic streaming events as server-sent events.
start = time.perf_counter()
first_token_at = None
input_tokens = 0
output_tokens = 0
stop_reason = None
model = None
async with client.stream("POST", "/api/chat", json=payload) as response:
async for line in response.aiter_lines():
if not line.startswith("data: "):
continue
event = json.loads(line[len("data: "):])
kind = event.get("type")
if kind == "message_start":
model = event["message"]["model"]
input_tokens = event["message"]["usage"]["input_tokens"]
elif kind == "content_block_delta" and event["delta"].get("type") == "text_delta":
if first_token_at is None:
first_token_at = time.perf_counter() # first text, not message_start
elif kind == "message_delta":
stop_reason = event["delta"].get("stop_reason")
output_tokens = event["usage"]["output_tokens"]
end = time.perf_counter()
first_token_at = first_token_at or end
return {
"started_at": start,
"ttft_ms": (first_token_at - start) * 1000,
"total_ms": (end - start) * 1000,
"tps": output_tokens / max(end - first_token_at, 1e-6),
"input_tokens": input_tokens,
"output_tokens": output_tokens,
"stop_reason": stop_reason,
"model": model,
}The quality under load check is the one nobody writes. The test asserts that the answer is still complete and still correct at peak load:
def test_the_answer_is_still_complete_under_load(load_results):
# load_results: the list of dicts that measure_one returned during the run
truncated = [r for r in load_results if r["stop_reason"] == "max_tokens"]
assert len(truncated) / len(load_results) < 0.01, (
f"{len(truncated)} answers were truncated under load"
)A truncated answer can still read fine. So the assertion on the stop reason catches it, where a keyword check would not. A fallback to a smaller model works the same way. The response looks fine, and the quality silently drops.
বাংলা ব্যাখ্যা
load profile-এর আকৃতি আসল ট্রাফিকের মতো হতে হবে, আর আসল LLM ট্রাফিক সমান নয়। এটা bursty, দীর্ঘ prompt-এর লম্বা tail আছে, আর আসার সময় business hours-এর সাথে যুক্ত। সমান ramp আপনাকে প্রায় কিছুই বলে না।
Locust load চালায় আর percentile সংখ্যা দেয় Source 1সোর্স 1:
from locust import HttpUser, task, between
LONG_POLICY_QUESTION = "Explain the full return, refund, and warranty policy for laptops, including every exception."
class SupportUser(HttpUser):
wait_time = between(1, 3)
@task(10)
def short_question(self):
self.client.post("/api/chat", json={
"message": "How long do I have to return a laptop?",
"max_tokens": 64,
})
@task(2)
def long_question(self):
self.client.post("/api/chat", json={
"message": LONG_POLICY_QUESTION,
"max_tokens": 800,
})weighted mix গুরুত্বপূর্ণ: লম্বা প্রশ্ন প্রায় ছয়টা অনুরোধের একটা (weight ১০ আর ২) কিন্তু token-এর আর wall-clock সময়ের অনেক বেশি। শুধু ছোট প্রশ্নের load test কখনো bottleneck খুঁজে পাবে না।
মাপ TTFT আর মোট সময় আলাদা করতে হয়, আর তার জন্য client-কে body-এর জন্য অপেক্ষা না করে stream পড়তে হয়। Locust-এর self.client.post stream করে না, তাই timing-এর জন্য এটার মতো আলাদা streaming client ব্যবহার করুন:
import json
import time
import httpx
async def measure_one(client: httpx.AsyncClient, payload: dict) -> dict:
# Assumes /api/chat forwards the Anthropic streaming events as server-sent events.
start = time.perf_counter()
first_token_at = None
input_tokens = 0
output_tokens = 0
stop_reason = None
model = None
async with client.stream("POST", "/api/chat", json=payload) as response:
async for line in response.aiter_lines():
if not line.startswith("data: "):
continue
event = json.loads(line[len("data: "):])
kind = event.get("type")
if kind == "message_start":
model = event["message"]["model"]
input_tokens = event["message"]["usage"]["input_tokens"]
elif kind == "content_block_delta" and event["delta"].get("type") == "text_delta":
if first_token_at is None:
first_token_at = time.perf_counter() # first text, not message_start
elif kind == "message_delta":
stop_reason = event["delta"].get("stop_reason")
output_tokens = event["usage"]["output_tokens"]
end = time.perf_counter()
first_token_at = first_token_at or end
return {
"started_at": start,
"ttft_ms": (first_token_at - start) * 1000,
"total_ms": (end - start) * 1000,
"tps": output_tokens / max(end - first_token_at, 1e-6),
"input_tokens": input_tokens,
"output_tokens": output_tokens,
"stop_reason": stop_reason,
"model": model,
}load-এর নিচে মানের চেকটাই কেউ লেখে না। টেস্ট assert করে যে peak load-এও উত্তর এখনো সম্পূর্ণ আর এখনো সঠিক:
def test_the_answer_is_still_complete_under_load(load_results):
# load_results: the list of dicts that measure_one returned during the run
truncated = [r for r in load_results if r["stop_reason"] == "max_tokens"]
assert len(truncated) / len(load_results) < 0.01, (
f"{len(truncated)} answers were truncated under load"
)কারণ কাটা উত্তর ব্যাকরণসঠিক হতে পারে, তাই stop reason-এর assertion সেটা ধরে যেখানে keyword check ধরতে পারত না। ছোট model-এ ফিরে যাওয়ার ক্ষেত্রেও তাই হয়: উত্তর ঠিক থাকে, আর মান নীরবে কমে যায়।
In practice
The load test asserts on percentiles, not on the average, and it asserts TTFT and total time separately:
# tests/perf/test_chat_load.py
import statistics
from collections import defaultdict
import pytest
EXPECTED_MODEL = "claude-sonnet-5-5" # the model your app is configured to use
INPUT_TOKENS_PER_MINUTE = 400_000 # example values: set these to your own limits
OUTPUT_TOKENS_PER_MINUTE = 80_000
def percentile(values, p):
return statistics.quantiles(values, n=100)[p - 1]
def per_minute(results, key):
t0 = min(r["started_at"] for r in results)
buckets = defaultdict(int)
for r in results:
buckets[int((r["started_at"] - t0) // 60)] += r[key]
return buckets
# `results` is a fixture that returns the list of dicts from measure_one for one run.
@pytest.mark.perf
def test_the_p95_latency_is_within_budget(results):
ttft = percentile([r["ttft_ms"] for r in results], 95)
total = percentile([r["total_ms"] for r in results], 95)
assert ttft < 800, f"p95 time to first token is {ttft:.0f}ms"
assert total < 6000, f"p95 total latency is {total:.0f}ms"The TTFT budget and the total budget are different numbers for a reason: the user waits for the first one and reads the second. A system that passes the TTFT budget but fails the total budget is fine for a short answer and unusable for a long one, and only the total budget catches that.
The rate limit test is the one that stops the load test from measuring your retry logic:
@pytest.mark.perf
def test_the_rate_limit_is_respected_not_exceeded(results):
peak_input = max(per_minute(results, "input_tokens").values())
peak_output = max(per_minute(results, "output_tokens").values())
assert peak_input <= INPUT_TOKENS_PER_MINUTE, f"peak input was {peak_input} tokens a minute"
assert peak_output <= OUTPUT_TOKENS_PER_MINUTE, f"peak output was {peak_output} tokens a minute"And the quality under load check, the one that catches the degradation that a status code cannot:
@pytest.mark.perf
def test_no_answer_was_truncated_under_load(results):
truncated = [r for r in results if r["stop_reason"] == "max_tokens"]
assert len(truncated) / len(results) < 0.01, f"{len(truncated)} of {len(results)} were truncated"@pytest.mark.perf
def test_no_request_fell_back_to_a_smaller_model(results):
fallbacks = [r for r in results if r["model"] != EXPECTED_MODEL]
assert not fallbacks, f"{len(fallbacks)} requests used a fallback model"The second one needs the response to report which model answered, which is another reason the envelope should be logged rather than just the text.
Finally, the tokens per second check, because a low TPS is a user-facing problem even when the total latency passes:
@pytest.mark.perf
def test_the_generation_rate_is_fast_enough(results):
slow = [r for r in results if r["output_tokens"] > 50 and r["tps"] < 20]
assert len(slow) / len(results) < 0.05, (
f"{len(slow)} long answers generated slower than 20 tokens per second"
)The output_tokens > 50 filter matters: the first token of a short answer dominates its TPS and would fail the check for the wrong reason.
সহজ English
Assert on percentiles, not on the average. Check TTFT and total time as two separate numbers:
# tests/perf/test_chat_load.py
import statistics
from collections import defaultdict
import pytest
EXPECTED_MODEL = "claude-sonnet-5-5" # the model your app is configured to use
INPUT_TOKENS_PER_MINUTE = 400_000 # example values: set these to your own limits
OUTPUT_TOKENS_PER_MINUTE = 80_000
def percentile(values, p):
return statistics.quantiles(values, n=100)[p - 1]
def per_minute(results, key):
t0 = min(r["started_at"] for r in results)
buckets = defaultdict(int)
for r in results:
buckets[int((r["started_at"] - t0) // 60)] += r[key]
return buckets
# `results` is a fixture that returns the list of dicts from measure_one for one run.
@pytest.mark.perf
def test_the_p95_latency_is_within_budget(results):
ttft = percentile([r["ttft_ms"] for r in results], 95)
total = percentile([r["total_ms"] for r in results], 95)
assert ttft < 800, f"p95 time to first token is {ttft:.0f}ms"
assert total < 6000, f"p95 total latency is {total:.0f}ms"The two budgets are different numbers for a reason. The user waits for the first one and reads during the second. A system can pass the TTFT budget but fail the total budget. That is fine for a short answer and unusable for a long one. Only the total budget catches it.
The rate limit test keeps the load test from measuring your retry logic:
@pytest.mark.perf
def test_the_rate_limit_is_respected_not_exceeded(results):
peak_input = max(per_minute(results, "input_tokens").values())
peak_output = max(per_minute(results, "output_tokens").values())
assert peak_input <= INPUT_TOKENS_PER_MINUTE, f"peak input was {peak_input} tokens a minute"
assert peak_output <= OUTPUT_TOKENS_PER_MINUTE, f"peak output was {peak_output} tokens a minute"Next is the quality under load check. It catches the damage that a status code cannot see:
@pytest.mark.perf
def test_no_answer_was_truncated_under_load(results):
truncated = [r for r in results if r["stop_reason"] == "max_tokens"]
assert len(truncated) / len(results) < 0.01, f"{len(truncated)} of {len(results)} were truncated"@pytest.mark.perf
def test_no_request_fell_back_to_a_smaller_model(results):
fallbacks = [r for r in results if r["model"] != EXPECTED_MODEL]
assert not fallbacks, f"{len(fallbacks)} requests used a fallback model"The second test needs the response to say which model answered. That is one more reason to log the whole envelope, not just the text.
Last is the tokens per second check. A low TPS hurts the user even when total latency passes:
@pytest.mark.perf
def test_the_generation_rate_is_fast_enough(results):
slow = [r for r in results if r["output_tokens"] > 50 and r["tps"] < 20]
assert len(slow) / len(results) < 0.05, (
f"{len(slow)} long answers generated slower than 20 tokens per second"
)The output_tokens > 50 filter matters. In a short answer, the first token dominates the TPS. Without the filter, the check would fail for the wrong reason.
বাংলা ব্যাখ্যা
load test assert করে গড়ের ওপর নয়, percentile-এর ওপর, আর TTFT আর মোট সময় আলাদা করে:
# tests/perf/test_chat_load.py
import statistics
from collections import defaultdict
import pytest
EXPECTED_MODEL = "claude-sonnet-5-5" # the model your app is configured to use
INPUT_TOKENS_PER_MINUTE = 400_000 # example values: set these to your own limits
OUTPUT_TOKENS_PER_MINUTE = 80_000
def percentile(values, p):
return statistics.quantiles(values, n=100)[p - 1]
def per_minute(results, key):
t0 = min(r["started_at"] for r in results)
buckets = defaultdict(int)
for r in results:
buckets[int((r["started_at"] - t0) // 60)] += r[key]
return buckets
# `results` is a fixture that returns the list of dicts from measure_one for one run.
@pytest.mark.perf
def test_the_p95_latency_is_within_budget(results):
ttft = percentile([r["ttft_ms"] for r in results], 95)
total = percentile([r["total_ms"] for r in results], 95)
assert ttft < 800, f"p95 time to first token is {ttft:.0f}ms"
assert total < 6000, f"p95 total latency is {total:.0f}ms"TTFT বাজেট আর মোট বাজেট আলাদা সংখ্যা হওয়ার কারণ একটা: ব্যবহারকারী প্রথমটার জন্য অপেক্ষা করে আর দ্বিতীয়টা পড়ে। যে সিস্টেম TTFT বাজেট পাস করে কিন্তু মোট বাজেট ফেইল করে সেটা ছোট উত্তরের জন্য ভালো আর লম্বা উত্তরের জন্য অব্যবহার্য, আর শুধু মোট বাজেটটাই সেটা ধরে।
rate limit টেড়টাই সেটা আটকায় যে load test আপনার retry logic মাপবে না:
@pytest.mark.perf
def test_the_rate_limit_is_respected_not_exceeded(results):
peak_input = max(per_minute(results, "input_tokens").values())
peak_output = max(per_minute(results, "output_tokens").values())
assert peak_input <= INPUT_TOKENS_PER_MINUTE, f"peak input was {peak_input} tokens a minute"
assert peak_output <= OUTPUT_TOKENS_PER_MINUTE, f"peak output was {peak_output} tokens a minute"আর load-এর নিচে মানের চেক, যেটা status code-এ ধরা যায় না এমন degradation ধরে:
@pytest.mark.perf
def test_no_answer_was_truncated_under_load(results):
truncated = [r for r in results if r["stop_reason"] == "max_tokens"]
assert len(truncated) / len(results) < 0.01, f"{len(truncated)} of {len(results)} were truncated"@pytest.mark.perf
def test_no_request_fell_back_to_a_smaller_model(results):
fallbacks = [r for r in results if r["model"] != EXPECTED_MODEL]
assert not fallbacks, f"{len(fallbacks)} requests used a fallback model"দ্বিতীয়টার জন্য response-কে জানাতে হবে কোন model উত্তর দিয়েছে, যেটা envelope log করার আরেকটা কারণ — শুধু লেখা নয়।
শেষে, tokens per second চেক, কারণ কম TPS ব্যবহারকারীর সমস্যা এমনক্ষেত্রেও যখন মোট latency পাস করে:
@pytest.mark.perf
def test_the_generation_rate_is_fast_enough(results):
slow = [r for r in results if r["output_tokens"] > 50 and r["tps"] < 20]
assert len(slow) / len(results) < 0.05, (
f"{len(slow)} long answers generated slower than 20 tokens per second"
)output_tokens > 50 ফিল্টারটা গুরুত্বপূর্ণ: ছোট উত্তরের প্রথম token তার TPS-কে আধিপত্য করে আর ভুল কারণে চেক ফেইল করত।
Common mistakes
Mistake 1: only short questions. The long prompt is about one request in six and a large share of the load.
Mistake 2: measuring only total latency. The user perceives the first token, and the two budgets are different numbers.
Mistake 3: not fixing max_tokens. Then the arms are not comparable, because the output lengths can differ. A fixed cap alone does not make them equal, because the model can stop earlier, so also record output_tokens Source 2সোর্স 2.
Mistake 4: ignoring the token rate limit. The provider cuts you off and the test measures your retry behaviour instead of your server.
Mistake 5: only checking the status code. A truncated or downgraded answer is a 200.
Mistake 6: running the load test against production traffic. A load test shares your organization's rate limit with live traffic, so it can push real users into 429 errors Source 3সোর্স 3.
সহজ English
Mistake 1: only short questions. The long prompt is about one request in six. It is also a large share of the load.
Mistake 2: measuring only total latency. The user feels the first token. The two budgets are different numbers.
Mistake 3: not fixing max_tokens. Then the arms cannot be compared, because the output lengths can differ. A fixed cap alone does not make them equal, because the model can stop earlier. So also record output_tokens Source 2সোর্স 2.
Mistake 4: ignoring the token rate limit. The provider cuts you off. The test then measures your retry behaviour, not your server.
Mistake 5: only checking the status code. A truncated or downgraded answer is still a 200.
Mistake 6: running the load test against production traffic. A load test shares your organization's rate limit with live traffic, so it can push real users into 429 errors Source 3সোর্স 3.
বাংলা ব্যাখ্যা
Mistake ১: শুধু ছোট প্রশ্ন। লম্বা prompt প্রায় ছয়টা অনুরোধের একটা আর load-এর বড় অংশ।
Mistake ২: শুধু মোট latency মাপা। ব্যবহারকারী প্রথম token দেখে, আর দুটো বাজেট আলাদা সংখ্যা।
Mistake ৩: max_tokens স্থির না করা। তাহলে arm দুটো তুলনাযোগ্য নয়, কারণ আউটপুট দৈর্ঘ্য আলাদা হতে পারে। শুধু একটা ক্যাপ দিলেই দৈর্ঘ্য সমান হয় না, কারণ model আগে থামতে পারে, তাই output_tokens-ও রেকর্ড করুন Source 2সোর্স 2।
Mistake ৪: token rate limit উপেক্ষা করা। provider আপনাকে কেটে দেয় আর টেস্ট আপনার server নয়, retry আচরণ মাপে।
Mistake ৫: শুধু status code দেখা। কাটা বা ছোট model-এ নামানো উত্তরও 200।
Mistake ৬: production traffic-এর ওপর load test। load test আপনার organization-এর rate limit live traffic-এর সাথে ভাগ করে, তাই আসল ব্যবহারকারীদের 429 error-এ ঠেলে দিতে পারে Source 3সোর্স 3।
What a tester can check
Tutorial advice
This advice is the tutorial's own. It does not come from the sources.
- Put the load test behind a
perfmark so it never runs on every commit. It is slow and it costs tokens. - Record the mix of prompt lengths in the test report. "100 users" says nothing; "95 short, 5 long" does.
- Log the model id with every response so a fallback is visible.
- Compare against a baseline run, not against an absolute number. The number moves when the provider changes.
- Test at the rate you expect at peak, not at the maximum the provider allows. The second one just gets you rate limited.
- Keep the TTFT and total-latency budgets as separate numbers, even when one is derived from the other.
সহজ English
Tutorial advice
This advice is the tutorial's own. It does not come from the sources.
- Put the load test behind a
perfmark so it never runs on every commit. It is slow and it costs tokens. - Record the mix of prompt lengths in the test report. "100 users" says nothing; "95 short, 5 long" does.
- Log the model id with every response so a fallback is visible.
- Compare against a baseline run, not against an absolute number. The number moves when the provider changes.
- Test at the rate you expect at peak, not at the maximum the provider allows. The second one just gets you rate limited.
- Keep the TTFT and total-latency budgets as separate numbers, even when one is derived from the other.
বাংলা ব্যাখ্যা
Tutorial advice
এই পরামর্শ টিউটোরিয়ালের নিজস্ব। এটি সোর্স থেকে আসেনি।
- load test-টা
perfmark-এর পেছনে রাখুন যাতে প্রতিটা commit-এ না চলে। এটা ধীর আর token খরচ করে। - টেস্ট রিপোর্টে prompt দৈর্ঘ্যের মিশ্রণ লিখুন। "১০০ ব্যবহারকারী" কিছু বলে না; "৯৫ ছোট, ৫ লম্বা" বলে।
- প্রতিটা response-এর সাথে model id লগ করুন যাতে fallback দেখা যায়।
- নির্দিষ্ট সংখ্যার বদলে baseline run-এর সাথে তুলনা করুন। provider বদলালে সংখ্যা নড়ে।
- provider-এর সর্বোচ্চ যে rate দেয় তার বদলে আপনি peak-এ যে rate আশা করেন সেই rate-এ টেস্ট করুন। দ্বিতীয়টা শুধু rate limit-এ ঠেকাবে।
- TTFT আর total-latency বাজেট আলাদা সংখ্যা হিসেবে রাখুন, একটা অন্যটা থেকে বের হলেও।
Key words
| Word | What it means |
|---|---|
| TTFT | Time to first token: how long until the user sees the first word |
| Tokens per second | How fast the model produces the rest of the answer |
| Load profile | The shape of the traffic a load test generates |
| Bursty traffic | Traffic that arrives in bursts rather than evenly |
| Token rate limit | A provider limit measured in tokens per minute (input and output separately), in addition to requests per minute |
| p95 | The value that 95 percent of measurements are under |
| Truncation under load | The server cutting answers short when it is under strain |
| Fallback model | A smaller model used when the primary one cannot serve the request |
| Locust | The load-testing tool used to drive concurrent traffic |