NEWUse coupon code SMX20 to get 20% OFF your first billing cycle on any game server or VPS!Explore Store

TUTORIALS & GUIDES

AMD EPYC VPS for Go Applications

Run Go services efficiently on an AMD EPYC VPS: how Go uses vCores, GOMAXPROCS and GOMEMLIMIT, HTTP server timeouts, connection pooling, profiling with pprof, garbage collector tuning, static binaries and sizing.

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.Pool for frequently allocated temporary objects.
  • Stream large responses instead of building them in memory.
  • Benchmark with go test -bench . -benchmem to 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

WorkloadEPYC plan
API with a database on the same server2 vCores / 8 GB
High request rates, several services, Redis4 vCores / 16 GB
CPU-heavy processing, large in-memory caches8–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.Client or 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.

ServoMix 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.

PlanvCoresRAMStorageNetworkPriceGood forBuy
SMX vPro XS (AMD EPYC)28 GB DDR4 ECC40 GB NVMe SSD1 Gbps, unmetered₹420/moWebsites, small APIs, bots, staging and VPN serversOrder
SMX vPro S (AMD EPYC)416 GB DDR4 ECC80 GB NVMe SSD1 Gbps, unmetered₹560/moWooCommerce, Node.js/Python backends, Docker Compose stacks, CI runnersOrder
SMX vPro M (AMD EPYC)832 GB DDR4 ECC150 GB NVMe SSD1 Gbps, unmetered₹840/moProduction databases, high-traffic sites, multi-container appsOrder
SMX vPro L (AMD EPYC)1664 GB DDR4 ECC250 GB NVMe SSD1 Gbps, unmetered₹1,120/moLarge production workloads, SaaS platforms, analytics, in-memory cachesOrder

Prices are monthly in INR as listed on the ServoMix store (verified 2026-11-14). Stock and final pricing are shown on the product page at checkout.

Frequently Asked Questions

Does Go use all CPU cores automatically?
Yes. GOMAXPROCS defaults to the number of CPUs available, so one Go process uses every vCore.
What is GOMEMLIMIT?
A soft memory limit (Go 1.19+) that makes the garbage collector work harder as the process approaches it. Set it below the service's hard memory limit.
Why set HTTP server timeouts in Go?
The default server has none, so slow clients can hold connections indefinitely. Set ReadHeaderTimeout, ReadTimeout, WriteTimeout and IdleTimeout.
How do I profile a Go service in production?
Import net/http/pprof on a localhost-only port and connect through an SSH tunnel with go tool pprof.
Why is my goroutine count growing?
Usually goroutines blocked forever, on channels or requests without timeouts. Inspect the goroutine profile.
Should I set GOMAXPROCS manually?
Usually not on a VPS. In containers with CPU limits on older Go versions, set it to the limit or use automaxprocs.
How do I build a Go binary for a Linux VPS?
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build with -trimpath and -ldflags="-s -w" for a small static binary.
How many database connections should a Go app use?
Set SetMaxOpenConns to what the database can handle, often 10–50, regardless of how many goroutines you run.
How do I deploy Go without dropping requests?
Handle SIGTERM with srv.Shutdown(ctx), and restart behind Nginx or with socket activation; see our zero-downtime guide.
Which EPYC plan suits Go services?
2 vCores / 8 GB for most APIs with a database, 4 vCores / 16 GB for high request rates, 8–16 vCores for CPU-heavy processing.

Frequently Asked Questions

Does Go use all CPU cores automatically?

Yes. GOMAXPROCS defaults to the number of CPUs available, so one Go process uses every vCore.

What is GOMEMLIMIT?

A soft memory limit (Go 1.19+) that makes the garbage collector work harder as the process approaches it. Set it below the service's hard memory limit.

Why set HTTP server timeouts in Go?

The default server has none, so slow clients can hold connections indefinitely. Set ReadHeaderTimeout, ReadTimeout, WriteTimeout and IdleTimeout.

How do I profile a Go service in production?

Import net/http/pprof on a localhost-only port and connect through an SSH tunnel with go tool pprof.

Why is my goroutine count growing?

Usually goroutines blocked forever, on channels or requests without timeouts. Inspect the goroutine profile.

Should I set GOMAXPROCS manually?

Usually not on a VPS. In containers with CPU limits on older Go versions, set it to the limit or use automaxprocs.

How do I build a Go binary for a Linux VPS?

CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build with -trimpath and -ldflags="-s -w" for a small static binary.

How many database connections should a Go app use?

Set SetMaxOpenConns to what the database can handle, often 10–50, regardless of how many goroutines you run.

How do I deploy Go without dropping requests?

Handle SIGTERM with srv.Shutdown(ctx), and restart behind Nginx or with socket activation; see our zero-downtime guide.

Which EPYC plan suits Go services?

2 vCores / 8 GB for most APIs with a database, 4 vCores / 16 GB for high request rates, 8–16 vCores for CPU-heavy processing.

Was this article helpful?

Your feedback helps us continuously improve ServoMix guides.

Share this article

Know someone who may find this guide useful?

AMD EPYC VPS for Go Applications: Performance Guide | ServoMix