-
-
Notifications
You must be signed in to change notification settings - Fork 1
PERFORMANCE
github-actions[bot] edited this page Mar 22, 2026
·
1 revision
| Metric | Value |
|---|---|
| Latency (avg) | ~3-5ms |
| Latency (p95) | ~8ms |
| Latency (p99) | ~12ms |
| Throughput | ~10,000 req/s |
| Memory (idle) | ~8MB |
| Memory (under load) | ~15MB |
| CPU (idle) | <1% |
| CPU (under load) | ~15-20% |
| Concurrent connections | ~1,000 |
Tested on: Intel i7-10700K, 16GB RAM, Ubuntu 22.04
{
"proxies": [{
"connection_timeout": "5s",
"keep_alive": true,
"max_idle_time": "60s"
}]
}# Increase file descriptor limits
ulimit -n 65535
# TCP tuning
sysctl -w net.ipv4.tcp_tw_reuse=1
sysctl -w net.ipv4.tcp_fin_timeout=30
sysctl -w net.core.somaxconn=1024services:
modbus-proxy:
ulimits:
nofile:
soft: 65535
hard: 65535# Set GOMAXPROCS to number of CPUs
export GOMAXPROCS=4
# Adjust GC target percentage
export GOGC=100# Run all benchmarks
make bench
# Or manually
go test -bench=. -benchmem ./...
# With profiling
go test -bench=. -cpuprofile=cpu.prof -memprofile=mem.prof ./...# CPU profile
go tool pprof cpu.prof
# Memory profile
go tool pprof mem.prof
# Web interface
go tool pprof -http=:8080 cpu.profAdd to main.go:
import _ "net/http/pprof"
// In main()
go func() {
log.Println(http.ListenAndServe("localhost:6060", nil))
}()Access at: http://localhost:6060/debug/pprof/
# prometheus.yml
scrape_configs:
- job_name: 'modbridge'
static_configs:
- targets: ['localhost:8080']- Enable connection keep-alive
- Increase file descriptor limits
- Tune TCP settings
- Use appropriate GOMAXPROCS
- Implement connection pooling
- Add request caching (if applicable)
- Optimize logging (reduce verbosity)
- Use binary logging format
- Profile and optimize hot paths
- Implement object pooling (sync.Pool)
- Consider lock-free data structures
- Use memory-mapped files for large datasets
# Install vegeta
go install github.com/tsenart/vegeta@latest
# Create target file
echo "GET http://localhost:8080/api/status" > targets.txt
# Run load test
vegeta attack -targets=targets.txt -rate=1000 -duration=30s | \
vegeta report
# With results
vegeta attack -targets=targets.txt -rate=1000 -duration=30s | \
tee results.bin | vegeta report
# Plot results
vegeta plot results.bin > plot.html# Install hey
go install github.com/rakyll/hey@latest
# Run test
hey -n 10000 -c 100 http://localhost:8080/api/statusFor 1,000 concurrent connections:
- CPU: 2 cores minimum
- Memory: 512MB minimum
- Network: 100Mbps
For 10,000 concurrent connections:
- CPU: 4-8 cores
- Memory: 2GB
- Network: 1Gbps
For 100,000 concurrent connections:
- CPU: 16+ cores
- Memory: 8-16GB
- Network: 10Gbps
- Multiple instances recommended
- ✅ Latency (p99) < 2ms
- ✅ Throughput > 50,000 req/s
- ✅ Memory < 8MB idle
- ✅ Support 5,000 concurrent connections
- ✅ Latency (p99) < 1ms
- ✅ Throughput > 100,000 req/s
- ✅ Memory < 50MB under load
- ✅ Support 10,000 concurrent connections
- ✅ Latency (p99) < 0.5ms
- ✅ Throughput > 1,000,000 req/s
- ✅ Memory < 100MB at scale
- ✅ Support 50,000+ concurrent connections
Symptoms: Request latency > 10ms
Causes:
- Network latency to Modbus devices
- DNS resolution delays
- Lock contention
- Inefficient logging
Solutions:
- Use connection pooling
- Cache DNS lookups
- Reduce lock scope
- Use structured logging with levels
Symptoms: Memory grows unbounded
Causes:
- Goroutine leaks
- Unclosed connections
- Large ring buffers
Solutions:
- Use pprof to find leaks
- Ensure proper connection cleanup
- Tune buffer sizes
- Implement resource limits
Symptoms: CPU > 80% consistently
Causes:
- Too many goroutines
- Inefficient parsing
- Excessive logging
Solutions:
- Use worker pools
- Optimize hot paths
- Reduce log verbosity
- Profile with pprof
- Always benchmark before optimizing
- Profile in production-like environments
- Monitor metrics continuously
- Set performance budgets
- Test at expected scale + 50%
- Document performance characteristics
- Automate performance regression tests
Last Updated: December 2025