Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6951691
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T14:15:08+00:00 2026-05-27T14:15:08+00:00

How many goroutines can I use painless? For example wikipedia says, in Erlang 20

  • 0

How many goroutines can I use painless? For example wikipedia says, in Erlang 20 million processes can be created without degrading performance.

Update: I’ve just investigated in goroutines performance a little and got such a results:

  • It looks like goroutine lifetime is more then calculating sqrt() 1000 times ( ~45µs for me ), the only limitation is memory
  • Goroutine costs 4 — 4.5 KB
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T14:15:09+00:00Added an answer on May 27, 2026 at 2:15 pm

    If a goroutine is blocked, there is no cost involved other than:

    • memory usage
    • slower garbage-collection

    The costs (in terms of memory and average time to actually start executing a goroutine) are:

    Go 1.6.2 (April 2016)
      32-bit x86 CPU (A10-7850K 4GHz)
        | Number of goroutines: 100000
        | Per goroutine:
        |   Memory: 4536.84 bytes
        |   Time:   1.634248 µs
      64-bit x86 CPU (A10-7850K 4GHz)
        | Number of goroutines: 100000
        | Per goroutine:
        |   Memory: 4707.92 bytes
        |   Time:   1.842097 µs
    
    Go release.r60.3 (December 2011)
      32-bit x86 CPU (1.6 GHz)
        | Number of goroutines: 100000
        | Per goroutine:
        |   Memory: 4243.45 bytes
        |   Time:   5.815950 µs
    

    On a machine with 4 GB of memory installed, this limits the maximum number of goroutines to slightly less than 1 million.


    Source code (no need to read this if you already understand the numbers printed above):

    package main
    
    import (
        "flag"
        "fmt"
        "os"
        "runtime"
        "time"
    )
    
    var n = flag.Int("n", 1e5, "Number of goroutines to create")
    
    var ch = make(chan byte)
    var counter = 0
    
    func f() {
        counter++
        <-ch // Block this goroutine
    }
    
    func main() {
        flag.Parse()
        if *n <= 0 {
                fmt.Fprintf(os.Stderr, "invalid number of goroutines")
                os.Exit(1)
        }
    
        // Limit the number of spare OS threads to just 1
        runtime.GOMAXPROCS(1)
    
        // Make a copy of MemStats
        var m0 runtime.MemStats
        runtime.ReadMemStats(&m0)
    
        t0 := time.Now().UnixNano()
        for i := 0; i < *n; i++ {
                go f()
        }
        runtime.Gosched()
        t1 := time.Now().UnixNano()
        runtime.GC()
    
        // Make a copy of MemStats
        var m1 runtime.MemStats
        runtime.ReadMemStats(&m1)
    
        if counter != *n {
                fmt.Fprintf(os.Stderr, "failed to begin execution of all goroutines")
                os.Exit(1)
        }
    
        fmt.Printf("Number of goroutines: %d\n", *n)
        fmt.Printf("Per goroutine:\n")
        fmt.Printf("  Memory: %.2f bytes\n", float64(m1.Sys-m0.Sys)/float64(*n))
        fmt.Printf("  Time:   %f µs\n", float64(t1-t0)/float64(*n)/1e3)
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Many applications use emails for accounts verification and other different purposes.You can see that
There are many solutions geared toward implementing user-space threads. Be it golang.org goroutines, python's
Many people use this method to add animation on switching views. When I try
Many ARIA demonstration websites use code such as: <label for=name id=label-name>Your Name</label> <input id=name
Many functions in my code use this structure: options = {param1: yes, param2 :
Many methods of my Servlet use HTTPSession. It is thread-safety to declare HTTPSession variable
Many of my company's clients use our data acquisition software in a research basis.
Many many sites uses this technique (facebook, google as well) For example, open facebook.com
Many .NET assemblies are accompanied with an XML file. For example, System.Web.WebPages.Razor.dll comes together
Many of us have seen / use the following: var t=!0; (t will equal

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.