DIY Gateway Load Test: Method and Ready-to-Use Script

Gateway reviews give you a snapshot as of the day of publication; your project lives for weeks. A 15-minute load test of your own gives you the current RPM, stability and failure pattern — three numbers no review contains. The method and a ready-made script.

The three numbers of the test

  1. Actual RPM: how many requests go through per minute before the first 429. APInex — 30 (headers), God Router — 8 (a server message), ABCRelay — ≥60 (no limit in the test).
  2. Stability: the share of successful requests under nominal load. TokenForge — 17/60; Token Harbor — 20/20; the difference is a verdict.
  3. Failure pattern: 429 with Retry-After (normal), latency degradation (Token Harbor), 5xx noise (ABCRelay now and then), silence and empty answers (an alarm).

The test script

import time, statistics
from openai import OpenAI

client = OpenAI(base_url="URL_ШЛЮЗА", api_key="КЛЮЧ")
model = "МОДЕЛЬ"

times, codes = [], {"ok": 0, "429": 0, "err": 0}
N = 60
for i in range(N):
    t0 = time.time()
    try:
        r = client.chat.completions.create(
            model=model,
            messages=[{"role": "user", "content": "Ответь одним словом: ок"}],
            timeout=30)
        if r.choices[0].message.content:
            codes["ok"] += 1
            times.append(time.time() - t0)
        else:
            codes["err"] += 1
    except Exception as e:
        code = getattr(e, "status_code", None)
        codes["429" if code == 429 else "err"] += 1
    time.sleep(1.0)

print(codes)
if times:
    print("медиана сек:", statistics.median(times), "| p95:", sorted(times)[int(len(times)*0.95)])

60 requests at one-second intervals — a standard load comparable to the Habr breakdowns (measurements of 20/60 RPM for all the major gateways). Log the results into the testing table with the date.

Interpreting the results

ProfileDiagnosisAction
60/60 ok, median <3 sHealthyWorking layer + monthly monitoring
Ok up to 20, 429 afterRPM limit foundPipeline paced below the limit
ok 20–40%UnstableDrafts with retries only
Empty answers / constant 5xxBrokenExclude until retested

Regularity: the test as monitoring

Once a week — one run of N=20 for each active gateway (5 minutes). Degradation against the previous run is a signal of changed conditions (provider rotation under the hood is the norm of the segment). A full N=60 run — once a month. A testing journal + a usage journal = the complete picture of pipeline health. The pairing with 429 handling patterns is in the material on retries and fallbacks.

Case: a month of runs in a journal

A single test gives a snapshot for one day; the value appears when you compare runs with each other. Extend the script above with a single line written to a CSV journal after each run — in a month you will see dynamics that no review contains. It is enough to append a block at the end of the same file: the variables codes, times and N are already declared by the test script.

import csv, datetime

# после каждого прогона (N=20 раз в неделю, N=60 раз в месяц):
row = [datetime.date.today().isoformat(), "APInex", N,
       codes["ok"], codes["429"], codes["err"]]
if times:
    row.append(round(statistics.median(times), 2))
with open("gateway_journal.csv", "a", newline="") as f:
    csv.writer(f).writerow(row)

The journal columns: date, gateway, run size, successes, 429s, errors, latency median. Reading it is simple: the ok share fell from 60/60 to 40/60 — move the gateway to the “Unstable” profile from the interpretation table and bring the full N=60 run forward off schedule. The median grows while the ok share stays the same — an early signal of latency degradation, as with Token Harbor: while the success counter is still green, the pipeline is already slowing down. The journal records the opposite scenario too: a gateway that fell into the “Broken” profile a month ago returns 60/60 ok — an entry with a new date returns it to the working layer faster than memory.

A practical cost reference: 22 requests = $0.0041, so even a monthly schedule of four to six runs remains pocket change. Entries with a date and run size protect against false alarms: you can only compare runs with the same N and the same prompt. The testing journal together with the usage journal is that very complete picture of pipeline health.

A couple of rules for keeping the journal. Make the interval between requests no shorter than the Retry-After pause if the gateway sends one: a test that ignores the server’s hint turns the measurement into a fight with the limit and understates stability. And second: the median in the journal instead of the mean — one request hanging for 25 seconds ruins the mean but not the median; if p95 output is enabled, its growth with a flat median signals rare hangs that in production turn into pipeline timeouts.

Frequently asked questions

Does the script load the platform? 60 requests one per second is within typical limits; aggressive tests without intervals are disrespectful and pointless (the server will answer with exactly what is already known).

Won’t the test force you to pay? On free routes — no; on balance-based ones — short prompts, the cost is pocket change (practice: 22 requests = $0.0041).

What else is worth measuring? TTFT and answer length on your real prompt — speed on “ok” is barely informative.

When does the test fail by itself? The key expired, the model rotated, the domain moved — gateways are living organisms; a login error is also a test result.

Which run to start with — N=20 or N=60? For weekly monitoring N=20 is enough: five minutes per gateway. Leave the full N=60 for the monthly run and for off-schedule launches after conditions change; runs are comparable as long as the interval and the prompt match.

A 429 came with Retry-After — is that bad? On the contrary, it is a healthy failure pattern: wait out the pause from the header and repeat the request. Such a gateway stays within the norm, unlike silence and empty answers without error codes.

Why TTFT if there is already a median? The median on the “Answer with one word: ok” prompt says little about real tasks. Measure TTFT and answer length on your working prompt — that is exactly where the difference between fast and ordinary models shows.

Does the script change for balance-based gateways? No, only the prompt changes — shorter and cheaper. Practice: 22 requests = $0.0041; on free routes the cost is zero, so always make the first run on a free route.

A load test is your personal review, always current. The script, the interpretation table, the weekly rhythm — and the pipeline will never surprise you with degradation. The method is based on the breakdowns of autumn 2026.

Like this post? Please share to your friends:
11AI - Your Free LLM
Leave a Reply

;-) :| :x :twisted: :smile: :shock: :sad: :roll: :razz: :oops: :o :mrgreen: :lol: :idea: :grin: :evil: :cry: :cool: :arrow: :???: :?: :!: