Mastering Concurrency in Go

Discover and harness Go's powerful concurrency features to develop and build fast, scalable network systems
Preview in Mapt

Mastering Concurrency in Go

Nathan Kozyra

1 customer reviews
Discover and harness Go's powerful concurrency features to develop and build fast, scalable network systems
Mapt Subscription
FREE
$29.99/m after trial
eBook
$21.70
RRP $30.99
Save 29%
Print + eBook
$50.99
RRP $50.99
What do I get with a Mapt Pro subscription?
  • Unlimited access to all Packt’s 5,000+ eBooks and Videos
  • Early Access content, Progress Tracking, and Assessments
  • 1 Free eBook or Video to download and keep every month after trial
What do I get with an eBook?
  • Download this book in EPUB, PDF, MOBI formats
  • DRM FREE - read and interact with your content when you want, where you want, and how you want
  • Access this title in the Mapt reader
What do I get with Print & eBook?
  • Get a paperback copy of the book delivered to you
  • Download this book in EPUB, PDF, MOBI formats
  • DRM FREE - read and interact with your content when you want, where you want, and how you want
  • Access this title in the Mapt reader
What do I get with a Video?
  • Download this Video course in MP4 format
  • DRM FREE - read and interact with your content when you want, where you want, and how you want
  • Access this title in the Mapt reader
$0.00
$21.70
$50.99
$29.99p/m after trial
RRP $30.99
RRP $50.99
Subscription
eBook
Print + eBook
Start 30 Day Trial

Frequently bought together


Mastering Concurrency in Go Book Cover
Mastering Concurrency in Go
$ 30.99
$ 21.70
Learning Functional Programming in Go Book Cover
Learning Functional Programming in Go
$ 35.99
$ 25.20
Buy 2 for $35.00
Save $31.98
Add to Cart
Subscribe and access every Packt eBook & Video.
 
  • 5,000+ eBooks & Videos
  • 50+ New titles a month
  • 1 Free eBook/Video to keep every month
Start Free Trial
 

Book Details

ISBN 139781783983483
Paperback328 pages

Book Description

This book will take you through the history of concurrency, how Go utilizes it, how Go differs from other languages, and the features and structures of Go's concurrency core. Each step of the way, the book will present real, usable examples with detailed descriptions of the methodologies used. By the end, you will feel comfortable designing a safe, data-consistent, high-performance concurrent application in Go.

The focus of this book is on showing you how Go can be used to program high-performance, robust concurrent programs with Go's unique form of multithreading, which employs goroutines that communicate and synchronize across channels. Designed for any curious developer or systems administrator with an interest in fast, non-blocking, and resource-thrifty systems applications, this book is an invaluable resource to help you understand Go's powerful concurrency focus.

Table of Contents

Chapter 1: An Introduction to Concurrency in Go
Introducing goroutines
Implementing the defer control mechanism
Understanding goroutines versus coroutines
Implementing channels
Closures and goroutines
Building a web spider using goroutines and channels
Summary
Chapter 2: Understanding the Concurrency Model
Understanding the working of goroutines
Synchronous versus asynchronous goroutines
Visualizing concurrency
RSS in action
A little bit about CSP
Go and the actor model
Object orientation
Using concurrency
Managing threads
Using sync and mutexes to lock data
Summary
Chapter 3: Developing a Concurrent Strategy
Applying efficiency in complex concurrency
Identifying race conditions with race detection
Synchronizing our concurrent operations
The project – multiuser appointment calendar
A multiuser Appointments Calendar
A note on style
A note on immutability
Summary
Chapter 4: Data Integrity in an Application
Getting deeper with mutexes and sync
The cost of goroutines
Working with files
Getting low – implementing C
Distributed Go
Some common consistency models
Using memcached
Summary
Chapter 5: Locks, Blocks, and Better Channels
Understanding blocking methods in Go
Cleaning up goroutines
Creating channels of channels
Pprof – yet another awesome tool
Handling deadlocks and errors
Summary
Chapter 6: C10K – A Non-blocking Web Server in Go
Attacking the C10K problem
Building our C10K web server
Serving pages
Multithreading and leveraging multiple cores
Exploring our web server
Summary
Chapter 7: Performance and Scalability
High performance in Go
Using the App Engine
Distributed Go
Some helpful libraries
Memory preservation
Summary
Chapter 8: Concurrent Application Architecture
Designing our concurrent application
Identifying our requirements
Using NoSQL as a data store in Go
Monitoring filesystem changes
Managing logfiles
Handling configuration files
Detecting file changes
Backing up our files
Designing our web interface
Reverting a file's history – command line
Checking the health of our server
Summary
Chapter 9: Logging and Testing Concurrency in Go
Handling errors and logging
Using the log4go package for robust logging
Using the runtime package for granular stack traces
Summary
Chapter 10: Advanced Concurrency and Best Practices
Going beyond the basics with channels
Building workers
Implementing nil channel blocks
Implementing more granular control over goroutines with tomb
Timing out with channels
Building a load balancer with concurrent patterns
Choosing unidirectional and bidirectional channels
Using an indeterminate channel type
Using Go with unit testing
Using Google App Engine
Utilizing best practices
Summary

What You Will Learn

  • Create goroutines as the building blocks of concurrency in Go
  • Extend the goroutines to include channels to open up communication
  • Design concurrent patterns to apply toward our examples and future applications
  • Explore methods to ensure data consistency remains paramount in concurrent and multi-core Go applications
  • Tune performance to squeeze the most out of existing hardware to keep your applications below resource thresholds
  • Utilize advanced concurrency patterns and best practices to stay low-level without compromising the simplicity of Go itself
  • Build several servers in Go that strongly utilize concurrency features

Authors

Table of Contents

Chapter 1: An Introduction to Concurrency in Go
Introducing goroutines
Implementing the defer control mechanism
Understanding goroutines versus coroutines
Implementing channels
Closures and goroutines
Building a web spider using goroutines and channels
Summary
Chapter 2: Understanding the Concurrency Model
Understanding the working of goroutines
Synchronous versus asynchronous goroutines
Visualizing concurrency
RSS in action
A little bit about CSP
Go and the actor model
Object orientation
Using concurrency
Managing threads
Using sync and mutexes to lock data
Summary
Chapter 3: Developing a Concurrent Strategy
Applying efficiency in complex concurrency
Identifying race conditions with race detection
Synchronizing our concurrent operations
The project – multiuser appointment calendar
A multiuser Appointments Calendar
A note on style
A note on immutability
Summary
Chapter 4: Data Integrity in an Application
Getting deeper with mutexes and sync
The cost of goroutines
Working with files
Getting low – implementing C
Distributed Go
Some common consistency models
Using memcached
Summary
Chapter 5: Locks, Blocks, and Better Channels
Understanding blocking methods in Go
Cleaning up goroutines
Creating channels of channels
Pprof – yet another awesome tool
Handling deadlocks and errors
Summary
Chapter 6: C10K – A Non-blocking Web Server in Go
Attacking the C10K problem
Building our C10K web server
Serving pages
Multithreading and leveraging multiple cores
Exploring our web server
Summary
Chapter 7: Performance and Scalability
High performance in Go
Using the App Engine
Distributed Go
Some helpful libraries
Memory preservation
Summary
Chapter 8: Concurrent Application Architecture
Designing our concurrent application
Identifying our requirements
Using NoSQL as a data store in Go
Monitoring filesystem changes
Managing logfiles
Handling configuration files
Detecting file changes
Backing up our files
Designing our web interface
Reverting a file's history – command line
Checking the health of our server
Summary
Chapter 9: Logging and Testing Concurrency in Go
Handling errors and logging
Using the log4go package for robust logging
Using the runtime package for granular stack traces
Summary
Chapter 10: Advanced Concurrency and Best Practices
Going beyond the basics with channels
Building workers
Implementing nil channel blocks
Implementing more granular control over goroutines with tomb
Timing out with channels
Building a load balancer with concurrent patterns
Choosing unidirectional and bidirectional channels
Using an indeterminate channel type
Using Go with unit testing
Using Google App Engine
Utilizing best practices
Summary

Book Details

ISBN 139781783983483
Paperback328 pages
Read More
From 1 reviews

Read More Reviews

Recommended for You

Go Programming Blueprints Book Cover
Go Programming Blueprints
$ 29.99
$ 21.00
Mastering Web Application Development with AngularJS Book Cover
Mastering Web Application Development with AngularJS
$ 26.99
$ 5.40
Mastering Go Web Services Book Cover
Mastering Go Web Services
$ 39.99
$ 28.00
Building Machine Learning Systems with Python Book Cover
Building Machine Learning Systems with Python
$ 29.99
$ 6.00
Mastering Object-oriented Python Book Cover
Mastering Object-oriented Python
$ 26.99
$ 18.90
Learning Docker Book Cover
Learning Docker
$ 39.99
$ 8.00