nodebudget-vps-bench 1.1.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- nodebudget_vps_bench/__init__.py +7 -0
- nodebudget_vps_bench/cli.py +172 -0
- nodebudget_vps_bench-1.1.0.dist-info/METADATA +81 -0
- nodebudget_vps_bench-1.1.0.dist-info/RECORD +8 -0
- nodebudget_vps_bench-1.1.0.dist-info/WHEEL +5 -0
- nodebudget_vps_bench-1.1.0.dist-info/entry_points.txt +3 -0
- nodebudget_vps_bench-1.1.0.dist-info/licenses/LICENSE +13 -0
- nodebudget_vps_bench-1.1.0.dist-info/top_level.txt +1 -0
|
@@ -0,0 +1,172 @@
|
|
|
1
|
+
"""CLI entry point for nodebudget-vps-bench.
|
|
2
|
+
|
|
3
|
+
Zero-dependency Python 3 benchmark measuring:
|
|
4
|
+
1) Non-cached 4K random pwrite + fsync tail latency (P50 / P95 / P99 / Max / IOPS)
|
|
5
|
+
2) Concurrent multi-worker SQLite DELETE vs WAL webhook write failure rate (SQLITE_BUSY)
|
|
6
|
+
|
|
7
|
+
Reference Linux 6.8 telemetry & interactive calculators:
|
|
8
|
+
https://nodebudget.dev/benchmarks/
|
|
9
|
+
https://nodebudget.dev/guides/why-cheap-vps-benchmarks-lie/
|
|
10
|
+
"""
|
|
11
|
+
|
|
12
|
+
from __future__ import annotations
|
|
13
|
+
|
|
14
|
+
import argparse
|
|
15
|
+
import json
|
|
16
|
+
import os
|
|
17
|
+
import platform
|
|
18
|
+
import random
|
|
19
|
+
import sqlite3
|
|
20
|
+
import statistics
|
|
21
|
+
import tempfile
|
|
22
|
+
import threading
|
|
23
|
+
import time
|
|
24
|
+
from typing import Any, Dict
|
|
25
|
+
|
|
26
|
+
__version__ = "1.1.0"
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
def bench_4k_fsync(ops: int = 500, size_mb: int = 16, work_dir: str | None = None) -> Dict[str, Any]:
|
|
30
|
+
if ops < 1:
|
|
31
|
+
raise ValueError("ops must be >= 1")
|
|
32
|
+
if size_mb < 1:
|
|
33
|
+
raise ValueError("size_mb must be >= 1")
|
|
34
|
+
target_dir = work_dir or tempfile.gettempdir()
|
|
35
|
+
fd, probe_path = tempfile.mkstemp(prefix="nodebudget_4k_", suffix=".bin", dir=target_dir)
|
|
36
|
+
size = size_mb * 1024 * 1024
|
|
37
|
+
os.ftruncate(fd, size)
|
|
38
|
+
block = os.urandom(4096)
|
|
39
|
+
rng = random.Random(20261126)
|
|
40
|
+
lats: list[float] = []
|
|
41
|
+
try:
|
|
42
|
+
for _ in range(ops):
|
|
43
|
+
off = rng.randrange(0, size - 4096, 4096)
|
|
44
|
+
t0 = time.perf_counter()
|
|
45
|
+
os.pwrite(fd, block, off)
|
|
46
|
+
os.fsync(fd)
|
|
47
|
+
lats.append((time.perf_counter() - t0) * 1000.0)
|
|
48
|
+
finally:
|
|
49
|
+
os.close(fd)
|
|
50
|
+
if os.path.exists(probe_path):
|
|
51
|
+
os.unlink(probe_path)
|
|
52
|
+
|
|
53
|
+
s = sorted(lats)
|
|
54
|
+
pct = lambda p: round(s[min(len(s) - 1, int(round((p / 100.0) * (len(s) - 1))))], 3)
|
|
55
|
+
total_sec = max(sum(s) / 1000.0, 1e-6)
|
|
56
|
+
return {
|
|
57
|
+
"ops": ops,
|
|
58
|
+
"avg_ms": round(statistics.mean(s), 3),
|
|
59
|
+
"p50_ms": pct(50),
|
|
60
|
+
"p95_ms": pct(95),
|
|
61
|
+
"p99_ms": pct(99),
|
|
62
|
+
"max_ms": round(s[-1], 3),
|
|
63
|
+
"iops": round(ops / total_sec, 1),
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
|
|
67
|
+
def bench_sqlite_burst(
|
|
68
|
+
mode: str = "WAL",
|
|
69
|
+
workers: int = 12,
|
|
70
|
+
writes_per_worker: int = 25,
|
|
71
|
+
work_dir: str | None = None,
|
|
72
|
+
) -> Dict[str, Any]:
|
|
73
|
+
if mode not in ("DELETE", "WAL"):
|
|
74
|
+
raise ValueError("mode must be DELETE or WAL")
|
|
75
|
+
if workers < 1 or writes_per_worker < 1:
|
|
76
|
+
raise ValueError("workers and writes_per_worker must be >= 1")
|
|
77
|
+
|
|
78
|
+
target_dir = work_dir or tempfile.gettempdir()
|
|
79
|
+
fd, db_path = tempfile.mkstemp(prefix=f"nodebudget_sq_{mode}_", suffix=".db", dir=target_dir)
|
|
80
|
+
os.close(fd)
|
|
81
|
+
con = sqlite3.connect(db_path)
|
|
82
|
+
con.execute(f"PRAGMA journal_mode={mode}")
|
|
83
|
+
con.execute("CREATE TABLE execs (id INTEGER PRIMARY KEY AUTOINCREMENT, payload TEXT, ts REAL)")
|
|
84
|
+
con.commit()
|
|
85
|
+
con.close()
|
|
86
|
+
|
|
87
|
+
ok = 0
|
|
88
|
+
errors = 0
|
|
89
|
+
lock = threading.Lock()
|
|
90
|
+
t0 = time.perf_counter()
|
|
91
|
+
|
|
92
|
+
def run() -> None:
|
|
93
|
+
nonlocal ok, errors
|
|
94
|
+
payload = "x" * 4096
|
|
95
|
+
for _ in range(writes_per_worker):
|
|
96
|
+
try:
|
|
97
|
+
c = sqlite3.connect(db_path, timeout=0.05)
|
|
98
|
+
c.execute("INSERT INTO execs(payload, ts) VALUES (?, ?)", (payload, time.time()))
|
|
99
|
+
c.commit()
|
|
100
|
+
c.close()
|
|
101
|
+
with lock:
|
|
102
|
+
ok += 1
|
|
103
|
+
except sqlite3.OperationalError:
|
|
104
|
+
with lock:
|
|
105
|
+
errors += 1
|
|
106
|
+
|
|
107
|
+
threads = [threading.Thread(target=run) for _ in range(workers)]
|
|
108
|
+
for t in threads:
|
|
109
|
+
t.start()
|
|
110
|
+
for t in threads:
|
|
111
|
+
t.join()
|
|
112
|
+
|
|
113
|
+
dur_ms = round((time.perf_counter() - t0) * 1000.0, 1)
|
|
114
|
+
for ext in ("", "-wal", "-shm"):
|
|
115
|
+
if os.path.exists(db_path + ext):
|
|
116
|
+
os.unlink(db_path + ext)
|
|
117
|
+
|
|
118
|
+
total = workers * writes_per_worker
|
|
119
|
+
return {
|
|
120
|
+
"mode": mode,
|
|
121
|
+
"attempted": total,
|
|
122
|
+
"ok": ok,
|
|
123
|
+
"sqlite_busy_errors": errors,
|
|
124
|
+
"failure_pct": round(errors / total * 100.0, 1),
|
|
125
|
+
"duration_ms": dur_ms,
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
|
|
129
|
+
def main(argv: list[str] | None = None) -> int:
|
|
130
|
+
ap = argparse.ArgumentParser(
|
|
131
|
+
prog="nodebudget-bench",
|
|
132
|
+
description="NodeBudget Linux VPS & mini PC 4K fsync + SQLite contention probe",
|
|
133
|
+
)
|
|
134
|
+
ap.add_argument("--ops", type=int, default=500, help="4K random fsync ops (default: 500)")
|
|
135
|
+
ap.add_argument("--size-mb", type=int, default=16, help="Probe file size in MiB (default: 16)")
|
|
136
|
+
ap.add_argument("--workers", type=int, default=12, help="Concurrent SQLite webhook writers (default: 12)")
|
|
137
|
+
ap.add_argument("--writes", type=int, default=25, help="Writes per worker (default: 25)")
|
|
138
|
+
ap.add_argument("--dir", dest="work_dir", default=None, help="Directory for temporary probe files")
|
|
139
|
+
ap.add_argument("--json", action="store_true", help="Output machine-readable JSON")
|
|
140
|
+
ap.add_argument("--version", action="version", version=f"%(prog)s {__version__}")
|
|
141
|
+
args = ap.parse_args(argv)
|
|
142
|
+
|
|
143
|
+
result = {
|
|
144
|
+
"tool": "nodebudget-vps-bench",
|
|
145
|
+
"version": __version__,
|
|
146
|
+
"platform": f"{platform.system()} {platform.release()} ({platform.machine()})",
|
|
147
|
+
"reference": "https://nodebudget.dev/guides/why-cheap-vps-benchmarks-lie/",
|
|
148
|
+
"fsync_4k": bench_4k_fsync(args.ops, args.size_mb, args.work_dir),
|
|
149
|
+
"sqlite_delete": bench_sqlite_burst("DELETE", args.workers, args.writes, args.work_dir),
|
|
150
|
+
"sqlite_wal": bench_sqlite_burst("WAL", args.workers, args.writes, args.work_dir),
|
|
151
|
+
}
|
|
152
|
+
if args.json:
|
|
153
|
+
print(json.dumps(result, indent=2))
|
|
154
|
+
return 0
|
|
155
|
+
|
|
156
|
+
f = result["fsync_4k"]
|
|
157
|
+
print(
|
|
158
|
+
f"[4K-fsync] ops={f['ops']} avg={f['avg_ms']}ms p50={f['p50_ms']}ms "
|
|
159
|
+
f"p95={f['p95_ms']}ms p99={f['p99_ms']}ms max={f['max_ms']}ms iops={f['iops']}"
|
|
160
|
+
)
|
|
161
|
+
for k in ("sqlite_delete", "sqlite_wal"):
|
|
162
|
+
sq = result[k]
|
|
163
|
+
print(
|
|
164
|
+
f"[sqlite:{sq['mode']}] attempted={sq['attempted']} ok={sq['ok']} "
|
|
165
|
+
f"SQLITE_BUSY={sq['sqlite_busy_errors']} ({sq['failure_pct']}% failed) dur={sq['duration_ms']}ms"
|
|
166
|
+
)
|
|
167
|
+
print("Compare against live Linux 6.8 reference nodes & calculators -> https://nodebudget.dev/benchmarks/")
|
|
168
|
+
return 0
|
|
169
|
+
|
|
170
|
+
|
|
171
|
+
if __name__ == "__main__":
|
|
172
|
+
raise SystemExit(main())
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: nodebudget-vps-bench
|
|
3
|
+
Version: 1.1.0
|
|
4
|
+
Summary: Zero-dependency Linux VPS & mini PC benchmark CLI measuring non-cached 4K fsync tail latency (P50/P95/P99/Max) and 12-worker SQLite DELETE vs WAL concurrency for n8n, PostgreSQL, and AI agents.
|
|
5
|
+
Author-email: Yuanqiang Leng <hello@lyq705.com>
|
|
6
|
+
License-Expression: MIT
|
|
7
|
+
Project-URL: Homepage, https://nodebudget.dev/
|
|
8
|
+
Project-URL: Documentation, https://nodebudget.dev/benchmarks/
|
|
9
|
+
Project-URL: Repository, https://github.com/a895047059/nodebudget-vps-bench
|
|
10
|
+
Project-URL: Cost & Break-Even Calculator, https://nodebudget.dev/tools/llm-api-vs-local-vs-gpu/
|
|
11
|
+
Project-URL: VRAM & Mini PC Fit Checker, https://nodebudget.dev/tools/local-llm-vram-mini-pc-checker/
|
|
12
|
+
Project-URL: Bug Tracker, https://github.com/a895047059/nodebudget-vps-bench/issues
|
|
13
|
+
Keywords: vps,benchmark,fsync,sqlite,n8n,self-hosted,ai-agents,postgresql,homelab
|
|
14
|
+
Classifier: Development Status :: 5 - Production/Stable
|
|
15
|
+
Classifier: Environment :: Console
|
|
16
|
+
Classifier: Intended Audience :: Developers
|
|
17
|
+
Classifier: Intended Audience :: System Administrators
|
|
18
|
+
Classifier: Operating System :: POSIX :: Linux
|
|
19
|
+
Classifier: Operating System :: MacOS
|
|
20
|
+
Classifier: Programming Language :: Python :: 3
|
|
21
|
+
Classifier: Programming Language :: Python :: 3.9
|
|
22
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
23
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
24
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
25
|
+
Classifier: Topic :: System :: Benchmark
|
|
26
|
+
Classifier: Topic :: System :: Systems Administration
|
|
27
|
+
Requires-Python: >=3.9
|
|
28
|
+
Description-Content-Type: text/markdown
|
|
29
|
+
License-File: LICENSE
|
|
30
|
+
Dynamic: license-file
|
|
31
|
+
|
|
32
|
+
# nodebudget-vps-bench
|
|
33
|
+
|
|
34
|
+
Zero-dependency Python 3 benchmark CLI built by [NodeBudget](https://nodebudget.dev/) to measure what **actually** matters for self-hosted **n8n**, **OpenClaw**, **LiteLLM**, **PostgreSQL 16**, and **24/7 AI Agents** on budget KVM VPS nodes and local mini PCs.
|
|
35
|
+
|
|
36
|
+
> Why? Because cached `dd if=/dev/zero` benchmarks measure RAM page cache, not durable PostgreSQL WAL commits or multi-tenant noisy-neighbor tail spikes.
|
|
37
|
+
|
|
38
|
+
## Install & Quick Run (Zero Dependencies)
|
|
39
|
+
|
|
40
|
+
Install via pip (or run directly with Python 3):
|
|
41
|
+
|
|
42
|
+
```bash
|
|
43
|
+
pip install nodebudget-vps-bench
|
|
44
|
+
nodebudget-bench --ops 500 --workers 12
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
Or run directly in 15 seconds without installing anything:
|
|
48
|
+
|
|
49
|
+
```bash
|
|
50
|
+
curl -fsSL https://raw.githubusercontent.com/a895047059/nodebudget-vps-bench/main/nb_bench.py | python3 -
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
Machine-readable JSON output for CI or fleet audits:
|
|
54
|
+
|
|
55
|
+
```bash
|
|
56
|
+
nodebudget-bench --ops 500 --workers 12 --json
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
## Reference Measurements (Live 3-vCPU Xeon E5-2680 v4 · Linux 6.8 KVM)
|
|
60
|
+
|
|
61
|
+
| Metric | Measured Result | Engineering Takeaway |
|
|
62
|
+
| --- | --- | --- |
|
|
63
|
+
| Non-cached 4K random `pwrite` + `fsync` (500 ops) | **P50 `0.659 ms` · P99 `1.289 ms` · Max `7.692 ms`** | Noisy-neighbor tail spike is 11.7× median; harmless to Postgres WAL, fatal to SQLite locks |
|
|
64
|
+
| 12-worker webhook burst — SQLite `DELETE` | **64 / 300 failed (`21.3%` `SQLITE_BUSY`)** | Silent webhook drops under modest concurrency |
|
|
65
|
+
| 12-worker webhook burst — SQLite `WAL` | **32 / 300 failed (`10.7%` `SQLITE_BUSY`)** | Even WAL fails >10% of concurrent 4 KB writes |
|
|
66
|
+
| Live PostgreSQL 16 (same node) | **0% lock failures · `31 MB` primary idle RSS** | Always use PostgreSQL 16 for self-hosted n8n & LiteLLM |
|
|
67
|
+
|
|
68
|
+
## Interactive Engineering Tools & Decision Specs (NodeBudget)
|
|
69
|
+
|
|
70
|
+
- **Claude Max ($100/$200) Worth-It Calculator**: https://nodebudget.dev/tools/claude-max-worth-it-calculator/
|
|
71
|
+
- **Local LLM VRAM & Mini PC Fit Checker**: https://nodebudget.dev/tools/local-llm-vram-mini-pc-checker/
|
|
72
|
+
- **MCP Token Overhead & LiteLLM VPS Payback Calculator**: https://nodebudget.dev/tools/mcp-token-overhead-calculator/
|
|
73
|
+
- **LLM API vs On-Demand GPU Cloud vs Local AI Box Calculator**: https://nodebudget.dev/tools/llm-api-vs-local-vs-gpu/
|
|
74
|
+
- **10 Hardware & Agent VPS Decision Spec Sheets**: https://nodebudget.dev/specs/
|
|
75
|
+
- **Interactive 6-Way VPS Cost & 1-Click Docker Compose Builder**: https://nodebudget.dev/
|
|
76
|
+
- **Full 4K fsync Tail Latency & SQLite Lock Study**: https://nodebudget.dev/guides/why-cheap-vps-benchmarks-lie/
|
|
77
|
+
- **First-Party Linux 6.8 Telemetry JSON Dataset**: https://nodebudget.dev/benchmarks/2026-11-telemetry.json
|
|
78
|
+
|
|
79
|
+
## License
|
|
80
|
+
|
|
81
|
+
MIT
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
nodebudget_vps_bench/__init__.py,sha256=FQ5o0fPS6vcECUEcM5rhJW7T-c7OgvXwZY2foxqy9f4,251
|
|
2
|
+
nodebudget_vps_bench/cli.py,sha256=mxON85Moka9_f6ptDMLxMADwV3oCUaI96WcewXxE-Hc,6079
|
|
3
|
+
nodebudget_vps_bench-1.1.0.dist-info/licenses/LICENSE,sha256=CW6eO82z1Gnr7EQASI_idMhgWudUgUAJWoeYGgPQuL8,622
|
|
4
|
+
nodebudget_vps_bench-1.1.0.dist-info/METADATA,sha256=3f_9mxaD9GjlS9j6-cVfKGkZIJ9WmIp3B-A4I96OnfA,4240
|
|
5
|
+
nodebudget_vps_bench-1.1.0.dist-info/WHEEL,sha256=SmOxYU7pzNKBqASvQJ7DjX3XGUF92lrGhMb3R6_iiqI,91
|
|
6
|
+
nodebudget_vps_bench-1.1.0.dist-info/entry_points.txt,sha256=mRzmlloUFW_5r9Sr3Tprm9oxhyBGspP-ibYN2IEXuts,108
|
|
7
|
+
nodebudget_vps_bench-1.1.0.dist-info/top_level.txt,sha256=r2X1pp5xaCkPjegk6iNeC_kx1HNBBx7PBpR2CaYlFSY,21
|
|
8
|
+
nodebudget_vps_bench-1.1.0.dist-info/RECORD,,
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Yuanqiang Leng (NodeBudget)
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
nodebudget_vps_bench
|