株式会社MMMの柳沼と申します。好きなリージョンは東京リージョンです。 弊社ではGo言語をプロダクションで使っています。 Go言語の特徴のひとつに、 goroutine を使って並列処理を容易に書ける、ということがあります。しかし、並列処理って同時にいくつ走らせればいいのか?について考えました。 まだ試行錯誤している最中で、内容に間違い・もっとこうするといいよ!などがあれば教えていただけると助かります。m(_ _)m また、実際goroutineを使った処理を実装するときはsync.WaitGroupを使うことが多いと思うので、記事内でもちょこちょこ使っています。 よく見るやり方 CPU数を使う、というのを割りとよく見ます(たぶん)。 func main() { fmt.Println("Start") loop("A") fmt.Println("Finish") } // ヘビーな処理