Document scaling experiment, measured database boundary and verified failure recovery
This commit is contained in:
@@ -0,0 +1,40 @@
|
||||
"""Return PostgreSQL to the original quota to check time/warm-cache confounding."""
|
||||
import asyncio
|
||||
import json
|
||||
import subprocess
|
||||
import threading
|
||||
from pathlib import Path
|
||||
|
||||
from load import run_load
|
||||
from run import ROOT, Client, configure, sample_services
|
||||
|
||||
|
||||
def main():
|
||||
profile = {"name": "db-reverted", "replicas": 4, "api_cpu": .5,
|
||||
"api_memory": "256m", "pg_cpu": .25}
|
||||
rows = []
|
||||
try:
|
||||
actual = configure(profile)
|
||||
c = Client("http://127.0.0.1:8083")
|
||||
actor = c.user("reversal")
|
||||
for repeat in range(3):
|
||||
chat = c.call("POST", "/api/v1/chats", 201, actor=actor,
|
||||
body={"title": "reversal", "member_ids": [actor["id"]]}, schema="Chat")["json"]
|
||||
samples, stop = [], threading.Event()
|
||||
thread = threading.Thread(target=sample_services, args=(stop, samples, actual))
|
||||
thread.start()
|
||||
result = asyncio.run(run_load(c.base, actor, chat["id"], rate=900, duration=6))
|
||||
stop.set()
|
||||
thread.join()
|
||||
result.update(configuration="db-reverted", repeat=repeat + 1,
|
||||
actual_containers=actual, resource_samples=samples)
|
||||
rows.append(result)
|
||||
print(json.dumps({k: result[k] for k in ["repeat", "successful_rps", "dropped", "errors"]}), flush=True)
|
||||
finally:
|
||||
subprocess.run(["docker", "compose", "up", "-d", "--scale", "api=2", "--wait"], cwd=ROOT, check=True,
|
||||
stdout=subprocess.DEVNULL)
|
||||
Path(ROOT / "evidence/scaling-reversal.json").write_text(json.dumps({"runs": rows}, indent=2) + "\n")
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
Reference in New Issue
Block a user