I wish it'd be that simple for my money
The checks were made with k6 and pprof. k6 results:
| Metric | Value | Interpretation |
|---|---|---|
| Peak Throughput | 5,000 RPS | API capacity |
| Total Requests | 170,292 | Processed during the 1m test |
| Success Rate | 99.86% | Reliability under stress |
| Median Latency | 3.14 ms | Rsponse under normal load |
| Lock Contention | 1,500 RPS | Write-rate for a single row |
pprof results:
| Resource | Value | Profile Analysis |
|---|---|---|
| Memory (Heap) | ~46.2 MB | Efficient memory management and GC |
| Top Allocator | bufio (35%) | Most memory spent on I/O buffering |
| DB Driver | pgx (28%) | Stable connection pooling (pgxpool) |
| Concurrency | 2,527 VUs | Lightweight goroutines for parallel tasks |
- I'm assuming this service is made for financial txs where its important not to lose data
- Error messages can be imporoved
- Logs're just for console, they should be tunned to write to files
- Some security checks were skipped on purpose. Security can be improved
Running basic isolated tests for all logic:
go test -v ./internal/transport/...Running load tests:
- install k6 first: https://grafana.com/docs/k6/latest/set-up/install-k6/
- lift the image:
docker compose up --build- run tests:
k6 run .\testing\load_test.jsAssuming you didn't change the default port (5000) from .env.example
Check if this crap works. Should return timestamp:
GET http://localhost:5000/api/v1/ping
Create new wallet (new for each request):
POST http://localhost:5000/api/v1/wallet/new
Response:
{
"id": "c07a5615-10a7-4774-bced-d45474cb1702",
"balance": 0
}Get wallet balance:
GET http://localhost:5000/api/v1/wallets/{UUID}
Response is just a raw balance:
300Make transaction
POST http://localhost:5000/api/v1/wallet
Payload:
{
"walletId": "c07a5615-10a7-4774-bced-d45474cb1702",
"operationType": "deposit", // Or "withdraw"
"amount": 10
}Response is ok or error message:
ok