Concurrency In Go Golang

Learn the Why's and How's of concurrency in Go.

Last updated 2022-01-10 | 4.6

- How to spin Goroutines and communicate data between them.
- How to avoid Race conditions and Deadlocks.
- How to synchronize the execution of Goroutines.

What you'll learn

How to spin Goroutines and communicate data between them.
How to avoid Race conditions and Deadlocks.
How to synchronize the execution of Goroutines.
How Go Scheduler works.
How to build streaming pipelines with Goroutines and Channels.
How to propagate data across API boundary.

* Requirements

* Basic knowledge of Go Programming Language like loops
* functions
* methods.
* Installation of Go compiler and any IDE on the laptop.

Description

Questions that comes to all Developers is whether they are utilising the available Computing resource efficiently? 

Course Overview

The course could be divided into five parts.

  • Concurrency Primitives

  • Deep Dive into Concurrency Primitives

  • Concurrency Patterns

  • Context Package

  • Bonus Section - Interfaces

In the course we try to answer these questions.

Concurrency Primitives

  • What are the limitations of Threads?

  • What are advantages of goroutines over OS threads?

  • How do we avoid race condition?

  • How Channels are used to communicate data?

  • How do we implement timeout and non-blocking communication?

  • When do we use mutex and channels?

  • How to synchronise execution of goroutines?

  • How to detect race condition in Go?

Deep Dives into Concurrency Primitives

  • How Go scheduler works?

  • How does context switching works?

  • How channel send and receive works underneath?

Concurrency Patterns

  • How to construct streaming pipelines with Goroutines and Channels?

  • How to Fan-out and Fan-in computationally intensive stages?

  • How do we avoid Goroutine Leaks?

Context Package

  • How we can propagate request scoped data and cancellation signal across API boundaries?

Coding Exercises

  • Each concept is followed by a Coding Exercise.

  • Exercises blueprint are shared on Github.

Sample Applications

We will build

  • Blueprint of web crawler.

  • Image processing pipeline.

  • HTTP Server Timeouts with Context Package.

Bonus Section - Interfaces

  • How to define common behaviour between different objects as abstract type?

  • How Interface provides an abstraction for higher level functions?

Who this course is for:

  • Students looking for Basic to Advanced Go Programming Concepts

Course content

14 sections • 76 lectures

Introduction Preview 06:05

Course Overview Preview 05:06

Processes and Threads Preview 07:51

Why Concurrency is hard Preview 06:27

Goroutines Preview 04:37

Exercise-Hello Preview 04:25

Exercise-ClientServer Preview 04:44

WaitGroups Preview 05:28

Exercise-WaitGroup Preview 01:48

Goroutines & Closures Preview 00:48

Exercise-Closure Preview 01:37

Exercise-Closure02 Preview 02:02

Deep Dive - Go Scheduler Preview 06:53

Deep Dive - Go Scheduler - Context Switching due to synchronous system call Preview 03:16

Deep Dive - Go Scheduler - Context Switching due to Asynchronous system call Preview 05:40

Deep Dive - Go Scheduler - Work Stealing Preview 03:14

Channels Preview 03:39

Exercise - Channels Preview 01:22

Range, Buffered Channels Preview 02:06

Exercise - Range Preview 01:41

Exercise - Buffered Channel Preview 01:24

Channel Direction Preview 01:05

Exercise - Channel Direction Preview 03:35

Channel Ownership Preview 01:43

Exercise - Channel Ownership Preview 02:18

Deep Dive - Channels Preview 03:01

Deep Dive - Channels - Send and Recieve Preview 02:30

Deep Dive - Channels - Buffer full Preview 03:00

Deep Dive - Channels - Buffer empty Preview 03:01

Deep Dive - Channels - Unbuffer channel Preview 02:01

Deep Dive - Channels - Summary Preview 01:11

Select Preview 04:14

Exercise - Select Preview 02:28

Exercise - Timeout Preview 01:43

Exercise - Non-blocking communication Preview 01:58

Mutex Preview 02:54

Exercise - Mutex Preview 03:13

Atomic Preview 00:46

Exercise - Atomic Preview 02:22

Conditional Variable Preview 05:51

Exercise - Conditional Variable - Signal Preview 02:06

Exercise - Conditional Variable - Broadcast Preview 02:55

Sync Once Preview 00:46

Exercise - Sync Once Preview 03:17

Sync Pool Preview 01:14

Exercise - Sync Pool Preview 03:54

Web Crawler - Sequential Preview 02:30

Web Crawler - Concurrent Preview 07:30

Pipelines Preview 04:29

Exercise - Pipelines Preview 05:41

Fan-out & Fan-in Preview 03:09

Exercise - Fan-out & Fan-in Preview 05:05

Cancelling Goroutines Preview 03:10

Exercise - Cancelling Goroutines Preview 04:51

Image Processing Sequential Preview 05:31

Image Processing Pipeline Preview 16:10

Context Package Preview 05:14

Context Package for Cancellation Preview 08:15

Context Package as Data bag Preview 01:57

Exercise - WithCancel Preview 04:21

Exercise - WithDeadline Preview 04:52

Exercise - WithTimeout Preview 02:36

Exercise - WithValue Preview 04:28

Context Package - Go Idioms Preview 04:44

Interface Preview 12:20

Interface-implicit Preview 02:31

Interfaces from standard library Preview 05:24

Exercise io.Writer interface Preview 02:20

Exercise Stringer interface Preview 02:10

Interface Satisfaction Preview 04:15

Type Assertion Preview 04:57

Exercise Type Assertion Preview 05:47

Empty Interface Preview 03:21