Why do Go routines take up just 2KB space while

Arpit Bhayani

Arpit Bhayani

Sep 25, 2023 • 1 min read


Why do Go routines take up just 2KB space while threads take up 1MB? ⚡

The core reason for this efficiency is because goroutines are stackless. Whenever a regular thread is created, it gets its own stack (with a copy of all local data) while a goroutine does not.

Instead, all goroutines share the stack with the Go runtime. By sharing the stack, the Go runtime avoids the overhead or allocation and copying of the data.

This is a high-level overview of the stackless design, and I have written a detailed answer on Duggup, where I was asked this question by Vikhyat.

Read the complete answer - https://lnkd.in/ghPztKeU

⚡ I keep writing and sharing these engineering nuggets, so if you are keen on learning them, follow along.

duggup.com/arpit

Arpit Bhayani

Principal Engineer II at Razorpay - building Agent Studio, Ex-staff engg at GCP Memorystore & Dataproc, Creator of DiceDB, ex-Amazon Fast Data, ex-Director of Engg. SRE and Data Engineering at Unacademy. I spark engineering curiosity through my no-fluff engineering videos on YouTube and my courses