Search icon CANCEL
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Conferences
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
Distributed Computing with Go

You're reading from   Distributed Computing with Go Practical concurrency and parallelism for Go applications

Arrow left icon
Product type Paperback
Published in Feb 2018
Publisher Packt
ISBN-13 9781787125384
Length 246 pages
Edition 1st Edition
Languages
Tools
Arrow right icon
Author (1):
Arrow left icon
V.N. Nikhil Anurag V.N. Nikhil Anurag
Author Profile Icon V.N. Nikhil Anurag
V.N. Nikhil Anurag
Arrow right icon
View More author details
Toc

Table of Contents (11) Chapters Close

Preface 1. Developer Environment for Go 2. Understanding Goroutines FREE CHAPTER 3. Channels and Messages 4. The RESTful Web 5. Introducing Goophr 6. Goophr Concierge 7. Goophr Librarian 8. Deploying Goophr 9. Foundations of Web Scale Architecture 10. Other Books You May Enjoy

Controlling parallelism

We know that spawned goroutines will start executing as soon as possible and in a simultaneous fashion. However, there is an inherent risk involved when the said goroutines need to work on a common source that has a lower limit on the number of simultaneous tasks it can handle. This might cause the common source to significantly slow down or in some cases even fail. As you might guess, this is not a new problem in the field of computer science, and there are many ways to handle it. As we shall see throughout the chapter, Go provides mechanisms to control parallelism in a simple and intuitive fashion. Let's start by looking at an example to simulate the problem of burdened common source, and then proceed to solve it.

Imagine a cashier who has to process orders, but has a limit to process only 10 orders in a day. Let's look at how to present this...

lock icon The rest of the chapter is locked
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at £16.99/month. Cancel anytime