今日已更新 177 条资讯 | 累计 42235 条内容
关于我们

Go with ARM

Allison Piovani 2026年09月12日 05:25 3 次阅读 来源:Dev.to

What is ARM An ARM processor is a chip that follows the ARM instruction set architecture, a set of rules that defines which instructions the processor understands and how it executes them. It's a RISC architecture: simple, fixed-length instructions, focused on running each one fast and with low power consumption. That's where the main difference from x86 (Intel/AMD) lies: x86 is CISC, with more complex and varied instructions, historically optimized for raw performance on desktops and servers. ARM was born in the embedded and mobile world, where battery life and heat dissipation are what matter most. Apple's M-series processors, Qualcomm's Snapdragon, and AWS's Graviton are examples of this architecture. What changes for Go Nothing changes in the code itself. What changes is how you build the project: you just add the GOARCH=arm64 parameter, plus CGO_ENABLED=0 for maximum compatibility, which produces a binary with no external dependencies by using a solution that's already native to the compiler. But we also need to pay attention to the Linux image we use as our base image. Example Dockerfile: FROM golang:1.27-alpine AS builder WORKDIR /src COPY . . RUN CGO_ENABLED = 0 GOOS = linux GOARCH = arm64 go build -trimpath -ldflags = "-s -w" -o /out/app ./cmd/app FROM gcr.io/distroless/static-debian13:nonroot COPY --from=build /out/app /app USER nonroot:nonroot EXPOSE 8080 ENTRYPOINT ["/app"] In the Cloud GCP, Azure, and AWS all have their own ARM-based machines. Here I'll focus on AWS, which I know best, and I used their documentation as a basis to fill in the gaps in my knowledge. Assume: 730 hrs/month; Prices in US dollars; Also: a = AMD, i = Intel, and g = Gravito In short, this averages out to roughly 20% savings overall — though of course that can shift depending on the application and the variables involved. Sources https://aws.amazon.com/ec2/graviton/ https://go.dev/wiki/MinimumRequirements https://docs.cloud.google.com/compute/docs/instances/arm-on-compute https:/

本文内容来源于互联网,版权归原作者所有
查看原文