Add loadtest/ harness and query sets
Two ramped-concurrency exercisers for POST /search/contents plus a flat 290-query list (58 topics x 5 templates) for feeding external harnesses. Endpoint/key come from LWSS_BASE/LWSS_KEY env vars; no secrets committed. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
parent
0a80d0ef26
commit
cb1f887a48
4 changed files with 484 additions and 0 deletions
35
loadtest/README.md
Normal file
35
loadtest/README.md
Normal file
|
|
@ -0,0 +1,35 @@
|
|||
# LWSS load tests
|
||||
|
||||
Ramped-concurrency exercisers for the live MCP endpoint. They hit
|
||||
`POST /search/contents` (the full search → render → extract path — the part
|
||||
that actually saturates under load) at increasing concurrency and report
|
||||
latency + per-page render yield.
|
||||
|
||||
## Setup
|
||||
|
||||
Both scripts read the endpoint and bearer key from the environment — no
|
||||
secrets are committed:
|
||||
|
||||
```sh
|
||||
export LWSS_BASE="https://websearch.neilbantoc.dev" # or your own endpoint
|
||||
export LWSS_KEY="<your MCP bearer key>"
|
||||
pip install httpx
|
||||
```
|
||||
|
||||
## Scripts
|
||||
|
||||
- **`loadtest.py`** — 36 hand-written natural queries, ramps `1,3,6,10,16,20`.
|
||||
Reuses queries across levels (some cache hits expected at higher N).
|
||||
- **`loadtest2.py`** — 290 unique queries (58 topics × 5 templates) so nothing
|
||||
hits cache; ramps `1,4,8,12,16,20`. Best for measuring the true render
|
||||
ceiling. Edit `LEVELS` to push harder.
|
||||
- **`queries.txt`** — the 290 unique queries, one per line. Feed this straight
|
||||
into opencode / a local model / your own harness.
|
||||
|
||||
## Reference numbers (2026-07, single-node deploy)
|
||||
|
||||
Clean cliff between **8 and 12 concurrent content-searches**: ≤8 is ~2s with
|
||||
100% page yield; at 12+ latency hits the 60s stage timeout and yield drops
|
||||
(92% → 72%). Zero errors at every level — degrades gracefully, never breaks.
|
||||
The bottleneck is the Playwright renderer (each content-search fans out to 5
|
||||
page renders), tunable via the renderer's `cpus` / browser-context pool.
|
||||
80
loadtest/loadtest.py
Normal file
80
loadtest/loadtest.py
Normal file
|
|
@ -0,0 +1,80 @@
|
|||
"""Ramped concurrency load test against the live LWSS /search/contents.
|
||||
|
||||
Fires N simultaneous content-searches (distinct queries so caching doesn't hide
|
||||
the render bottleneck) at increasing N, records per-request latency, HTTP status,
|
||||
and server-side degradation.
|
||||
|
||||
Usage:
|
||||
export LWSS_BASE="https://websearch.neilbantoc.dev" # or your own endpoint
|
||||
export LWSS_KEY="<your MCP bearer key>"
|
||||
python loadtest.py
|
||||
"""
|
||||
import asyncio, os, time, statistics
|
||||
import httpx
|
||||
|
||||
BASE = os.environ.get("LWSS_BASE", "https://websearch.neilbantoc.dev")
|
||||
KEY = os.environ["LWSS_KEY"] # required; do not hardcode secrets
|
||||
HDR = {"Authorization": f"Bearer {KEY}", "Content-Type": "application/json"}
|
||||
MAX_RESULTS = 5
|
||||
CLIENT_TIMEOUT = 120 # above the server's 60s stage timeout so we see 502s, not client aborts
|
||||
LEVELS = [1, 3, 6, 10, 16, 20]
|
||||
|
||||
QUERIES = [
|
||||
"history of the printing press","how do tsunamis form","best practices postgres indexing",
|
||||
"photosynthesis light reactions","rust vs go concurrency model","james webb telescope discoveries 2026",
|
||||
"mediterranean diet health effects","how lithium batteries degrade","origins of jazz music",
|
||||
"kubernetes ingress explained","great barrier reef bleaching","quantum error correction basics",
|
||||
"roman aqueduct engineering","caffeine metabolism half life","tcp congestion control algorithms",
|
||||
"volcano types and eruptions","machine learning gradient descent","history of the silk road",
|
||||
"how vaccines train immune system","black hole event horizon","sourdough fermentation science",
|
||||
"electric vehicle battery recycling","north sea wind farms","how gps satellites work",
|
||||
"coral reef restoration methods","the fall of constantinople","monarch butterfly migration",
|
||||
"cryptography elliptic curves","antarctic ice sheet melting","how noise cancelling works",
|
||||
"the history of coffee trade","neural network backpropagation","deep sea hydrothermal vents",
|
||||
"renaissance art techniques","how solar panels convert light","plate tectonics explained",
|
||||
]
|
||||
|
||||
async def one(client, q):
|
||||
t0 = time.monotonic()
|
||||
try:
|
||||
r = await client.post(f"{BASE}/search/contents", headers=HDR,
|
||||
json={"query": q, "max_results": MAX_RESULTS})
|
||||
dt = time.monotonic() - t0
|
||||
if r.status_code == 200:
|
||||
d = r.json()
|
||||
got = sum(1 for x in d["results"] if x.get("content"))
|
||||
return ("ok", dt, r.status_code, got, len(d.get("failed_urls", [])))
|
||||
return ("http_err", dt, r.status_code, 0, 0)
|
||||
except Exception as e:
|
||||
return ("exc", time.monotonic() - t0, type(e).__name__, 0, 0)
|
||||
|
||||
async def level(client, n, qstart):
|
||||
qs = [QUERIES[(qstart + i) % len(QUERIES)] for i in range(n)]
|
||||
t0 = time.monotonic()
|
||||
res = await asyncio.gather(*(one(client, q) for q in qs))
|
||||
wall = time.monotonic() - t0
|
||||
lat = [r[1] for r in res]
|
||||
ok = [r for r in res if r[0] == "ok"]
|
||||
print(f"\n=== concurrency {n} ===")
|
||||
print(f" wall time: {wall:5.1f}s for {n} requests")
|
||||
print(f" succeeded: {len(ok)}/{n}")
|
||||
print(f" latency p50: {statistics.median(lat):5.1f}s "
|
||||
f"min {min(lat):.1f} max {max(lat):.1f}")
|
||||
if len(lat) >= 4:
|
||||
print(f" latency p95: {sorted(lat)[int(len(lat)*0.95)-1]:5.1f}s")
|
||||
avg_content = statistics.mean([r[3] for r in ok]) if ok else 0
|
||||
print(f" avg pages w/ content per req: {avg_content:.1f}/{MAX_RESULTS}")
|
||||
fails = [r for r in res if r[0] != "ok"]
|
||||
if fails:
|
||||
for r in fails:
|
||||
print(f" FAIL: {r[0]} status={r[2]}")
|
||||
return qstart + n
|
||||
|
||||
async def main():
|
||||
qs = 0
|
||||
async with httpx.AsyncClient(timeout=CLIENT_TIMEOUT) as client:
|
||||
for n in LEVELS:
|
||||
qs = await level(client, n, qs)
|
||||
await asyncio.sleep(3) # brief cooldown between levels
|
||||
|
||||
asyncio.run(main())
|
||||
79
loadtest/loadtest2.py
Normal file
79
loadtest/loadtest2.py
Normal file
|
|
@ -0,0 +1,79 @@
|
|||
"""Clean ramped load test — large UNIQUE query set so nothing hits cache.
|
||||
|
||||
Builds 300 unique queries (60 topics x 5 templates) and ramps concurrency,
|
||||
reporting latency and per-page render yield for the full /search/contents path.
|
||||
|
||||
Usage:
|
||||
export LWSS_BASE="https://websearch.neilbantoc.dev" # or your own endpoint
|
||||
export LWSS_KEY="<your MCP bearer key>"
|
||||
python loadtest2.py
|
||||
"""
|
||||
import asyncio, os, time, statistics
|
||||
import httpx
|
||||
|
||||
BASE = os.environ.get("LWSS_BASE", "https://websearch.neilbantoc.dev")
|
||||
KEY = os.environ["LWSS_KEY"] # required; do not hardcode secrets
|
||||
HDR = {"Authorization": f"Bearer {KEY}", "Content-Type": "application/json"}
|
||||
MAX_RESULTS = 5
|
||||
CLIENT_TIMEOUT = 120
|
||||
LEVELS = [1, 4, 8, 12, 16, 20]
|
||||
|
||||
TOPICS = [
|
||||
"the printing press","tsunamis","postgres indexing","photosynthesis","volcanoes","jazz music",
|
||||
"the mediterranean diet","lithium batteries","the silk road","kubernetes","coral reefs","quantum computing",
|
||||
"roman aqueducts","caffeine","tcp networking","gradient descent","the roman empire","monarch butterflies",
|
||||
"elliptic curve cryptography","antarctic ice","noise cancelling","the coffee trade","neural networks",
|
||||
"hydrothermal vents","renaissance art","solar panels","plate tectonics","the french revolution","glaciers",
|
||||
"sourdough bread","wind turbines","gps satellites","the great wall of china","honeybees","nuclear fusion",
|
||||
"the human immune system","black holes","the amazon rainforest","electric cars","the industrial revolution",
|
||||
"vaccines","tectonic earthquakes","the byzantine empire","desalination","the ozone layer","fiber optics",
|
||||
"the cold war","permafrost","hydrogen fuel","the mongol empire","antibiotics","ocean currents",
|
||||
"the apollo program","genetics","the stock market","volcano monitoring","migratory birds","semiconductors",
|
||||
]
|
||||
TEMPLATES = ["how does {} work","the history of {}","explain {} in detail","{} facts and science","understanding {}"]
|
||||
QUERIES = [t.format(x) for x in TOPICS for t in TEMPLATES] # 60*5 = 300 unique
|
||||
|
||||
async def one(client, q):
|
||||
t0 = time.monotonic()
|
||||
try:
|
||||
r = await client.post(f"{BASE}/search/contents", headers=HDR, json={"query": q, "max_results": MAX_RESULTS})
|
||||
dt = time.monotonic() - t0
|
||||
if r.status_code == 200:
|
||||
d = r.json()
|
||||
got = sum(1 for x in d["results"] if x.get("content"))
|
||||
n = len(d["results"])
|
||||
return ("ok", dt, got, n)
|
||||
return ("http_%d" % r.status_code, dt, 0, 0)
|
||||
except Exception as e:
|
||||
return (type(e).__name__, time.monotonic() - t0, 0, 0)
|
||||
|
||||
async def level(client, n, qstart):
|
||||
qs = QUERIES[qstart:qstart+n]
|
||||
t0 = time.monotonic()
|
||||
res = await asyncio.gather(*(one(client, q) for q in qs))
|
||||
wall = time.monotonic() - t0
|
||||
ok = [r for r in res if r[0] == "ok"]
|
||||
lat = [r[1] for r in res]
|
||||
full = sum(1 for r in ok if r[2] >= r[3] and r[3] > 0) # all results had content
|
||||
partial = sum(1 for r in ok if 0 < r[2] < r[3])
|
||||
empty = sum(1 for r in ok if r[2] == 0)
|
||||
errs = [r for r in res if r[0] != "ok"]
|
||||
total_pages = sum(r[3] for r in ok)
|
||||
got_pages = sum(r[2] for r in ok)
|
||||
print(f"\n=== concurrency {n} ===")
|
||||
print(f" wall {wall:5.1f}s | p50 {statistics.median(lat):5.1f}s | min {min(lat):.1f} max {max(lat):.1f}")
|
||||
print(f" requests: {len(ok)}/{n} ok (full={full} partial={partial} empty={empty}) errors={len(errs)}")
|
||||
print(f" page yield: {got_pages}/{total_pages} rendered "
|
||||
f"({100*got_pages/total_pages:.0f}%)" if total_pages else " page yield: n/a")
|
||||
for r in errs:
|
||||
print(" ERROR:", r[0])
|
||||
return qstart + n
|
||||
|
||||
async def main():
|
||||
qs = 0
|
||||
async with httpx.AsyncClient(timeout=CLIENT_TIMEOUT) as client:
|
||||
for n in LEVELS:
|
||||
qs = await level(client, n, qs)
|
||||
await asyncio.sleep(4)
|
||||
|
||||
asyncio.run(main())
|
||||
290
loadtest/queries.txt
Normal file
290
loadtest/queries.txt
Normal file
|
|
@ -0,0 +1,290 @@
|
|||
how does the printing press work
|
||||
the history of the printing press
|
||||
explain the printing press in detail
|
||||
the printing press facts and science
|
||||
understanding the printing press
|
||||
how does tsunamis work
|
||||
the history of tsunamis
|
||||
explain tsunamis in detail
|
||||
tsunamis facts and science
|
||||
understanding tsunamis
|
||||
how does postgres indexing work
|
||||
the history of postgres indexing
|
||||
explain postgres indexing in detail
|
||||
postgres indexing facts and science
|
||||
understanding postgres indexing
|
||||
how does photosynthesis work
|
||||
the history of photosynthesis
|
||||
explain photosynthesis in detail
|
||||
photosynthesis facts and science
|
||||
understanding photosynthesis
|
||||
how does volcanoes work
|
||||
the history of volcanoes
|
||||
explain volcanoes in detail
|
||||
volcanoes facts and science
|
||||
understanding volcanoes
|
||||
how does jazz music work
|
||||
the history of jazz music
|
||||
explain jazz music in detail
|
||||
jazz music facts and science
|
||||
understanding jazz music
|
||||
how does the mediterranean diet work
|
||||
the history of the mediterranean diet
|
||||
explain the mediterranean diet in detail
|
||||
the mediterranean diet facts and science
|
||||
understanding the mediterranean diet
|
||||
how does lithium batteries work
|
||||
the history of lithium batteries
|
||||
explain lithium batteries in detail
|
||||
lithium batteries facts and science
|
||||
understanding lithium batteries
|
||||
how does the silk road work
|
||||
the history of the silk road
|
||||
explain the silk road in detail
|
||||
the silk road facts and science
|
||||
understanding the silk road
|
||||
how does kubernetes work
|
||||
the history of kubernetes
|
||||
explain kubernetes in detail
|
||||
kubernetes facts and science
|
||||
understanding kubernetes
|
||||
how does coral reefs work
|
||||
the history of coral reefs
|
||||
explain coral reefs in detail
|
||||
coral reefs facts and science
|
||||
understanding coral reefs
|
||||
how does quantum computing work
|
||||
the history of quantum computing
|
||||
explain quantum computing in detail
|
||||
quantum computing facts and science
|
||||
understanding quantum computing
|
||||
how does roman aqueducts work
|
||||
the history of roman aqueducts
|
||||
explain roman aqueducts in detail
|
||||
roman aqueducts facts and science
|
||||
understanding roman aqueducts
|
||||
how does caffeine work
|
||||
the history of caffeine
|
||||
explain caffeine in detail
|
||||
caffeine facts and science
|
||||
understanding caffeine
|
||||
how does tcp networking work
|
||||
the history of tcp networking
|
||||
explain tcp networking in detail
|
||||
tcp networking facts and science
|
||||
understanding tcp networking
|
||||
how does gradient descent work
|
||||
the history of gradient descent
|
||||
explain gradient descent in detail
|
||||
gradient descent facts and science
|
||||
understanding gradient descent
|
||||
how does the roman empire work
|
||||
the history of the roman empire
|
||||
explain the roman empire in detail
|
||||
the roman empire facts and science
|
||||
understanding the roman empire
|
||||
how does monarch butterflies work
|
||||
the history of monarch butterflies
|
||||
explain monarch butterflies in detail
|
||||
monarch butterflies facts and science
|
||||
understanding monarch butterflies
|
||||
how does elliptic curve cryptography work
|
||||
the history of elliptic curve cryptography
|
||||
explain elliptic curve cryptography in detail
|
||||
elliptic curve cryptography facts and science
|
||||
understanding elliptic curve cryptography
|
||||
how does antarctic ice work
|
||||
the history of antarctic ice
|
||||
explain antarctic ice in detail
|
||||
antarctic ice facts and science
|
||||
understanding antarctic ice
|
||||
how does noise cancelling work
|
||||
the history of noise cancelling
|
||||
explain noise cancelling in detail
|
||||
noise cancelling facts and science
|
||||
understanding noise cancelling
|
||||
how does the coffee trade work
|
||||
the history of the coffee trade
|
||||
explain the coffee trade in detail
|
||||
the coffee trade facts and science
|
||||
understanding the coffee trade
|
||||
how does neural networks work
|
||||
the history of neural networks
|
||||
explain neural networks in detail
|
||||
neural networks facts and science
|
||||
understanding neural networks
|
||||
how does hydrothermal vents work
|
||||
the history of hydrothermal vents
|
||||
explain hydrothermal vents in detail
|
||||
hydrothermal vents facts and science
|
||||
understanding hydrothermal vents
|
||||
how does renaissance art work
|
||||
the history of renaissance art
|
||||
explain renaissance art in detail
|
||||
renaissance art facts and science
|
||||
understanding renaissance art
|
||||
how does solar panels work
|
||||
the history of solar panels
|
||||
explain solar panels in detail
|
||||
solar panels facts and science
|
||||
understanding solar panels
|
||||
how does plate tectonics work
|
||||
the history of plate tectonics
|
||||
explain plate tectonics in detail
|
||||
plate tectonics facts and science
|
||||
understanding plate tectonics
|
||||
how does the french revolution work
|
||||
the history of the french revolution
|
||||
explain the french revolution in detail
|
||||
the french revolution facts and science
|
||||
understanding the french revolution
|
||||
how does glaciers work
|
||||
the history of glaciers
|
||||
explain glaciers in detail
|
||||
glaciers facts and science
|
||||
understanding glaciers
|
||||
how does sourdough bread work
|
||||
the history of sourdough bread
|
||||
explain sourdough bread in detail
|
||||
sourdough bread facts and science
|
||||
understanding sourdough bread
|
||||
how does wind turbines work
|
||||
the history of wind turbines
|
||||
explain wind turbines in detail
|
||||
wind turbines facts and science
|
||||
understanding wind turbines
|
||||
how does gps satellites work
|
||||
the history of gps satellites
|
||||
explain gps satellites in detail
|
||||
gps satellites facts and science
|
||||
understanding gps satellites
|
||||
how does the great wall of china work
|
||||
the history of the great wall of china
|
||||
explain the great wall of china in detail
|
||||
the great wall of china facts and science
|
||||
understanding the great wall of china
|
||||
how does honeybees work
|
||||
the history of honeybees
|
||||
explain honeybees in detail
|
||||
honeybees facts and science
|
||||
understanding honeybees
|
||||
how does nuclear fusion work
|
||||
the history of nuclear fusion
|
||||
explain nuclear fusion in detail
|
||||
nuclear fusion facts and science
|
||||
understanding nuclear fusion
|
||||
how does the human immune system work
|
||||
the history of the human immune system
|
||||
explain the human immune system in detail
|
||||
the human immune system facts and science
|
||||
understanding the human immune system
|
||||
how does black holes work
|
||||
the history of black holes
|
||||
explain black holes in detail
|
||||
black holes facts and science
|
||||
understanding black holes
|
||||
how does the amazon rainforest work
|
||||
the history of the amazon rainforest
|
||||
explain the amazon rainforest in detail
|
||||
the amazon rainforest facts and science
|
||||
understanding the amazon rainforest
|
||||
how does electric cars work
|
||||
the history of electric cars
|
||||
explain electric cars in detail
|
||||
electric cars facts and science
|
||||
understanding electric cars
|
||||
how does the industrial revolution work
|
||||
the history of the industrial revolution
|
||||
explain the industrial revolution in detail
|
||||
the industrial revolution facts and science
|
||||
understanding the industrial revolution
|
||||
how does vaccines work
|
||||
the history of vaccines
|
||||
explain vaccines in detail
|
||||
vaccines facts and science
|
||||
understanding vaccines
|
||||
how does tectonic earthquakes work
|
||||
the history of tectonic earthquakes
|
||||
explain tectonic earthquakes in detail
|
||||
tectonic earthquakes facts and science
|
||||
understanding tectonic earthquakes
|
||||
how does the byzantine empire work
|
||||
the history of the byzantine empire
|
||||
explain the byzantine empire in detail
|
||||
the byzantine empire facts and science
|
||||
understanding the byzantine empire
|
||||
how does desalination work
|
||||
the history of desalination
|
||||
explain desalination in detail
|
||||
desalination facts and science
|
||||
understanding desalination
|
||||
how does the ozone layer work
|
||||
the history of the ozone layer
|
||||
explain the ozone layer in detail
|
||||
the ozone layer facts and science
|
||||
understanding the ozone layer
|
||||
how does fiber optics work
|
||||
the history of fiber optics
|
||||
explain fiber optics in detail
|
||||
fiber optics facts and science
|
||||
understanding fiber optics
|
||||
how does the cold war work
|
||||
the history of the cold war
|
||||
explain the cold war in detail
|
||||
the cold war facts and science
|
||||
understanding the cold war
|
||||
how does permafrost work
|
||||
the history of permafrost
|
||||
explain permafrost in detail
|
||||
permafrost facts and science
|
||||
understanding permafrost
|
||||
how does hydrogen fuel work
|
||||
the history of hydrogen fuel
|
||||
explain hydrogen fuel in detail
|
||||
hydrogen fuel facts and science
|
||||
understanding hydrogen fuel
|
||||
how does the mongol empire work
|
||||
the history of the mongol empire
|
||||
explain the mongol empire in detail
|
||||
the mongol empire facts and science
|
||||
understanding the mongol empire
|
||||
how does antibiotics work
|
||||
the history of antibiotics
|
||||
explain antibiotics in detail
|
||||
antibiotics facts and science
|
||||
understanding antibiotics
|
||||
how does ocean currents work
|
||||
the history of ocean currents
|
||||
explain ocean currents in detail
|
||||
ocean currents facts and science
|
||||
understanding ocean currents
|
||||
how does the apollo program work
|
||||
the history of the apollo program
|
||||
explain the apollo program in detail
|
||||
the apollo program facts and science
|
||||
understanding the apollo program
|
||||
how does genetics work
|
||||
the history of genetics
|
||||
explain genetics in detail
|
||||
genetics facts and science
|
||||
understanding genetics
|
||||
how does the stock market work
|
||||
the history of the stock market
|
||||
explain the stock market in detail
|
||||
the stock market facts and science
|
||||
understanding the stock market
|
||||
how does volcano monitoring work
|
||||
the history of volcano monitoring
|
||||
explain volcano monitoring in detail
|
||||
volcano monitoring facts and science
|
||||
understanding volcano monitoring
|
||||
how does migratory birds work
|
||||
the history of migratory birds
|
||||
explain migratory birds in detail
|
||||
migratory birds facts and science
|
||||
understanding migratory birds
|
||||
how does semiconductors work
|
||||
the history of semiconductors
|
||||
explain semiconductors in detail
|
||||
semiconductors facts and science
|
||||
understanding semiconductors
|
||||
Loading…
Add table
Add a link
Reference in a new issue