Go services are some of the easiest to host: compile, copy one binary, run it under systemd. Our Go deployment guide covers that process. This guide focuses on running Go well: how it uses the CPU and memory of a VPS, the settings that matter in production, and how to find performance problems.
How Go Uses vCores
The Go runtime schedules goroutines onto operating-system threads, running Go code on up to GOMAXPROCS threads at once, which defaults to the number of CPUs the process can see. On a 4-vCore EPYC VPS, one Go process uses all four cores without extra configuration, unlike Node.js or CPython, which need several processes. Since Go 1.25 the runtime also considers cgroup CPU limits when choosing the default; on older versions running in containers with CPU limits, set GOMAXPROCS to the limit (or use the automaxprocs package) to avoid oversubscription.
Memory and GOMEMLIMIT
Go's garbage collector by default lets the heap grow to roughly twice the live data before collecting (GOGC=100). That is efficient but can surprise you under a strict memory limit. Since Go 1.19, GOMEMLIMIT sets a soft limit: as the process approaches it, the collector runs more often to stay under it.
# systemd unit
[Service]
Environment=GOMEMLIMIT=1500MiB
MemoryMax=2G
Set GOMEMLIMIT somewhat below the hard limit so the collector has room to work before the kernel kills the process. If the live data itself exceeds the limit, the collector cannot help; profile the heap.
HTTP Server Timeouts
The default http.Server has no timeouts, so slow or malicious clients can hold connections open indefinitely. Always set them:
srv := &http.Server{
Addr: "127.0.0.1:8080",
Handler: mux,
ReadHeaderTimeout: 5 * time.Second,
ReadTimeout: 15 * time.Second,
WriteTimeout: 30 * time.Second,
IdleTimeout: 60 * time.Second,
MaxHeaderBytes: 1 << 20,
}
Use per-request deadlines with context.WithTimeout for database and outbound calls, and handle SIGTERM with srv.Shutdown(ctx) so in-flight requests finish during deploys.
Connection Pools
db.SetMaxOpenConns(25)
db.SetMaxIdleConns(25)
db.SetConnMaxLifetime(30 * time.Minute)
client := &http.Client{
Timeout: 10 * time.Second,
Transport: &http.Transport{MaxIdleConnsPerHost: 50, IdleConnTimeout: 90 * time.Second},
}
Goroutines make it easy to start thousands of concurrent database queries; the pool limit protects the database. Reuse one http.Client across requests so connections are kept alive, and always close response bodies.
Profiling with pprof
import _ "net/http/pprof"
go func() { log.Println(http.ListenAndServe("127.0.0.1:6060", nil)) }()
# through an SSH tunnel from your computer
ssh -L 6060:127.0.0.1:6060 server
go tool pprof http://127.0.0.1:6060/debug/pprof/profile?seconds=30 # CPU
go tool pprof http://127.0.0.1:6060/debug/pprof/heap # memory
curl http://127.0.0.1:6060/debug/pprof/goroutine?debug=1 | head # goroutines
Keep pprof on localhost only. A steadily rising goroutine count usually means goroutines blocked forever, for example on channels nobody reads or requests without timeouts.
Reducing Garbage Collection Work
- Avoid unnecessary allocations in hot paths: reuse buffers, preallocate slices with known sizes.
- Use
sync.Poolfor frequently allocated temporary objects. - Stream large responses instead of building them in memory.
- Benchmark with
go test -bench . -benchmemto see allocations per operation.
Building for Production
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -trimpath -ldflags="-s -w" -o app ./cmd/app
A static binary has no runtime dependencies and runs on any x86-64 Linux, including the EPYC and Intel plans. Profile-guided optimisation (place a CPU profile as default.pgo in the main package) can improve performance by a few percent with no code changes.
Observability
Expose Prometheus metrics (request counts, latency histograms, goroutines, GC pauses; the Go client library includes runtime metrics), log with log/slog in JSON format, and add a /health endpoint (see our monitoring guide).
Sizing
| Workload | EPYC plan |
|---|---|
| API with a database on the same server | 2 vCores / 8 GB |
| High request rates, several services, Redis | 4 vCores / 16 GB |
| CPU-heavy processing, large in-memory caches | 8–16 vCores |
Because Go is efficient, the database is usually the first thing that needs more resources; give it memory before scaling the Go service.
Deploying Go Services
A Go deploy is usually a single file: build in CI, copy the binary into a new release directory, switch a symlink and restart the systemd service. Because Go starts in milliseconds, a restart behind Nginx with a retry on the upstream causes almost no visible interruption; for strict zero-downtime, run two instances on different ports and restart them one at a time, or use systemd socket activation so the listening socket stays open across restarts (see our zero-downtime guide). Keep the previous binary for instant rollback.
Configuration and Secrets
Read configuration from environment variables or a file outside the release directory, validate it at startup and fail fast with a clear message if something is missing. Keep secrets out of the binary and out of the repository; systemd's EnvironmentFile= with permissions 600 is a simple, reliable option.
Common Mistakes
- No timeouts on the HTTP server or on outbound calls.
- Creating a new
http.Clientor database connection per request. - Unbounded goroutines started per request with no limit or cancellation.
- Exposing pprof on a public port.
- Ignoring errors from
rows.Close()or forgetting to close response bodies, which leaks connections.
Why Go Suits Small Servers
Compiled code, cheap goroutines and modest memory use mean a Go service often handles traffic that would need several processes in other runtimes. That makes Go a strong choice when you want to keep a plan small, and it leaves more of the server's memory for the database, which is where it usually helps most.
Next Steps
Deploy the service with our Go deployment guide, add metrics and alerts, then load test the busiest endpoints so you know how much traffic one plan handles before you need to scale. Revisit memory settings after the first weeks of real traffic, using the heap profile and GC metrics rather than guesses.
In Short
Set timeouts, pool connections, use GOMEMLIMIT with a hard memory cap, and profile with pprof before optimising; Go then uses every vCore efficiently.
SkyRainCloud Plans for This Workload
Go services are efficient: a single binary uses all vCores automatically and modest memory. 2 vCores / 8 GB runs most APIs with a database; choose 4–8 vCores for high request rates or CPU-heavy processing.
AMD EPYC 7C13 VPS
Dedicated KVM vCores on AMD EPYC 7C13 (up to 3.70 GHz) with DDR4 ECC memory, NVMe SSD and an unmetered 1 Gbps port.
| Plan | vCores | RAM | Storage | Network | Price | Good for | Buy |
|---|---|---|---|---|---|---|---|
| VPS 1 — AMD | 2 | 8 GB DDR4 ECC | 40 GB NVMe SSD | 1 Gbps, unmetered | ₹649/month | Websites, small APIs, bots, staging and VPN servers | Order |
| VPS 2 — AMD | 4 | 16 GB DDR4 ECC | 80 GB NVMe SSD | 1 Gbps, unmetered | ₹1,299/month | WooCommerce, Node.js/Python backends, Docker Compose stacks, CI runners | Order |
| VPS 3 — AMD | 8 | 32 GB DDR4 ECC | 150 GB NVMe SSD | 1 Gbps, unmetered | ₹2,499/month | Production databases, high-traffic sites, multi-container apps | Order |
| VPS 4 — AMD | 16 | 64 GB DDR4 ECC | 250 GB NVMe SSD | 1 Gbps, unmetered | ₹4,899/month | Large production workloads, SaaS platforms, analytics, in-memory caches | Order |
Prices are monthly in INR as listed on the SkyRainCloud store (verified 2026-11-14). Stock and final pricing are shown on the product page at checkout.