Go HTTP backend that serves precomputed JSON payloads at fixed size tiers, fronted by Nginx on port 80 proxying to the app on 127.0.0.1:9000. Useful for load testing, benchmarking proxies, or verifying throughput with predictable response sizes.
- Nginx listens on
:80and proxies to the Go process on127.0.0.1:9000. - The Go server binds only to localhost; external traffic hits Nginx first.
| Path | Response |
|---|---|
/health |
Small JSON: {"status":"ok"} |
/small |
JSON ~5–10 KB (8 variants, round-robin) |
/medium |
JSON ~50–100 KB |
/large |
JSON ~500 KB–1 MB |
Payloads are generated once at startup and reused (no per-request JSON marshaling for body content beyond selecting a variant).
Requirements: Go 1.21+.
go build -o json-load-backend .
./json-load-backendSanity checks (backend directly):
curl -I http://127.0.0.1:9000/health
curl -I http://127.0.0.1:9000/small
curl -I http://127.0.0.1:9000/medium
curl -I http://127.0.0.1:9000/large
curl -s http://127.0.0.1:9000/small | wc -c
curl -s http://127.0.0.1:9000/medium | wc -c
curl -s http://127.0.0.1:9000/large | wc -cThe following matches a typical Ubuntu/VM deploy: install Go, build the binary, run under systemd, and put Nginx in front.
sudo apt update
sudo apt install -y golang
go versionFrom this repository:
go build -o json-load-backend .Install the binary (paths are examples):
sudo mkdir -p /opt/json-load-backend
sudo cp json-load-backend /opt/json-load-backend/Copy the unit file from deploy/json-load-backend.service to /etc/systemd/system/json-load-backend.service. Edit User= to match the account that should own the process (the sample uses azureuser).
sudo systemctl daemon-reload
sudo systemctl enable json-load-backend
sudo systemctl start json-load-backend
sudo systemctl status json-load-backendUse deploy/nginx.conf as a reference. On many distributions you merge snippets into /etc/nginx/nginx.conf or sites-enabled/ instead of replacing the whole file—adapt to your distro’s layout.
Key points in the sample config:
- High
worker_connections,keepaliveto the upstream, and proxy buffering tuned for large JSON responses. - Upstream
json_backend→127.0.0.1:9000.
Validate and reload:
sudo nginx -t
sudo systemctl restart nginx
sudo systemctl status nginxcurl -I http://127.0.0.1/health
curl -I http://127.0.0.1/small
curl -I http://127.0.0.1/medium
curl -I http://127.0.0.1/large| Path | Purpose |
|---|---|
main.go |
Go HTTP server |
go.mod |
Go module definition |
deploy/nginx.conf |
Sample full nginx.conf for high-connection proxying |
deploy/json-load-backend.service |
Sample systemd unit |
See LICENSE.