SlideShare a Scribd company logo
Concurrent	Programming	in	Golang
Jan	7,	2017	@ DILO	Surabaya
Noval Agung Prayogo
Short	about	me
• Noval Agung Prayogo
• Surabaya,	Indonesia
• Lead	Software	Engineer	@	EACIIT	Pte.	Ltd.
Golang
• Go is	an	open	source	programming	language	that	makes	it	easy	to	
build	simple,	reliable,	and	efficient	software	– golang.org
• Crafted	@	Google	@	2009
• Used	on	production by	many	big	companies
• Easy	to	learn,	develop,	compile,	run,	deploy
• Rich	support	for	concurrency,	and	etc …
Characteristic
• 99%	static	type,	1%	dynamic
• Garbage	collected
• Compiled
• Structural
• Memory	safe
• Multiplatform
Example:	Hello	World
Another	Example:	HTTP	Server
Yet	Another
Example:	SQL
Concurrency
• Concurrency is	the composition of	independently	executing	
processes.	Concurrency	is	about dealing	with lots	of	things	at	once
• Parallelism is	the	simultaneous execution of	(possibly	related)	
computations.	Parallelism	is	about doing lots	of	things	at	once
• Concurrency	is	about	structure,	parallelism	is	about	execution
• Concurrency	provides	a	way	to	structure	a	solution	to	solve	a	problem	
that	may	(but	not	necessarily)	be	parallelizable
Coffee	Machine
Coffee	Machine
Coffee	Machine
Coffee	Machine
Concurrent	=	Four	queues,	one	coffee	machine
Parallel	=	Three	queues,	three	coffee	machine
Coffee	Machine
Concurrent	(not	parallel)
Coffee	Machine
Concurrent	(parallel)
Coffee	machine	can	serve	one	people	at	time
I’m	not	sure	if	this	kind	of	coffee	machine	really	exists.	Maybe	it’ll	be	look	like	this
Coffee	machine	can	serve
multiple	people	at	time
• A goroutine is	a	lightweight	thread	managed	by	the	Go	runtime
• Not	free,	but	very	cheap	(4KB	~	8KB	per	each	goroutine)
• Stacks	start	small,	but	grow	and	shrink	as	required
Goroutine
Channel
• Channels allow	you	to	pass	references	to	data	structures	between	
goroutines
sync.WaitGroup
• A	WaitGroup waits	for	a	collection	of	goroutines to	finish
Race	Condition	Example
• A race	condition is	an	undesirable	situation	that	occurs	when	
attempting	to	perform	two	or	more	operations	at	the	same	time
sync.Mutex
• Mutex used	to	lock	&	unlock	certain	of	process
Real	life	Example	of	Concurrency
• Read	then	filter	csv	file	(7	million	records)
• Implements	worker	pool	technique	to	do	the	filter	concurrently
Open	CSV	file
Dispatch	all	workers
Worker	1
Worker	2
Worker	3
Worker	4
Read	file	line-by-line,	then
send	data	(as	job)	to	workers	
Kill	worker	which	is	finished	 doing	the	jobs
Retreive filtered	data
Start
Finish
Demo
Thank	you!
Q&A?
Reference
• https://golang.org
• https://tour.golang.org/concurrency/1
• https://talks.golang.org/2012/waza.slide#1
• https://golang.org/doc/codewalk/sharemem
• https://blog.golang.org/share-memory-by-communicating
• https://joearms.github.io/2013/04/05/concurrent-and-parallel-
programming.html
• http://searchstorage.techtarget.com/definition/race-condition

More Related Content

Similar to Concurrent Programming in Golang - DILo Surabaya

GoLang - Why It Matters
GoLang -  Why It MattersGoLang -  Why It Matters
GoLang - Why It Matters
rahul
 
Devops, the future is here, it's just not evenly distributed yet.
Devops, the future is here, it's just not evenly distributed yet.Devops, the future is here, it's just not evenly distributed yet.
Devops, the future is here, it's just not evenly distributed yet.
Kris Buytaert
 
From hello world to goodbye code
From hello world to goodbye codeFrom hello world to goodbye code
From hello world to goodbye code
Kim Moir
 
Introduction to GoLang
Introduction to GoLangIntroduction to GoLang
Introduction to GoLang
NVISIA
 
OS Accelerate London - 09/16/15
OS Accelerate London - 09/16/15OS Accelerate London - 09/16/15
OS Accelerate London - 09/16/15
Appnovation Technologies
 
Agile Software Development
Agile Software DevelopmentAgile Software Development
Agile Software Development
Ahmet Bulut
 
Java programming basics
Java programming basicsJava programming basics
Java programming basics
Pragya Rastogi
 
Optimizely for Developers
Optimizely for DevelopersOptimizely for Developers
Optimizely for Developers
Optimizely
 
Modern Continuous Software Delivery
Modern Continuous Software DeliveryModern Continuous Software Delivery
Modern Continuous Software Delivery
Martin Logan
 
Continuous integration - ThangTD
Continuous integration - ThangTDContinuous integration - ThangTD
Continuous integration - ThangTD
Framgia Vietnam
 
Go Language presentation
Go Language presentationGo Language presentation
Go Language presentation
Gh-Mohammed Eldadah
 
Go language
Go language Go language
Go language
jabedskakib
 
Devops for drupal
Devops for  drupalDevops for  drupal
Devops for drupal
Kris Buytaert
 
Top 7 Reasons Using Golang for Mobile App Development-Connect Infosoft.pptx
Top 7 Reasons Using Golang for Mobile App Development-Connect Infosoft.pptxTop 7 Reasons Using Golang for Mobile App Development-Connect Infosoft.pptx
Top 7 Reasons Using Golang for Mobile App Development-Connect Infosoft.pptx
Connect Infosoft Technologies Private Limited
 
Why use Go for web development?
Why use Go for web development?Why use Go for web development?
Why use Go for web development?
Weng Wei
 
Devops, Secops, Opsec, DevSec *ops *.* ?
Devops, Secops, Opsec, DevSec *ops *.* ?Devops, Secops, Opsec, DevSec *ops *.* ?
Devops, Secops, Opsec, DevSec *ops *.* ?
Kris Buytaert
 
Golang development go language services in kerala- go language development in...
Golang development go language services in kerala- go language development in...Golang development go language services in kerala- go language development in...
Golang development go language services in kerala- go language development in...
Zewia Software Solutions (P) Ltd
 
It's XP Stupid (2019)
It's XP Stupid (2019)It's XP Stupid (2019)
It's XP Stupid (2019)
Mike Harris
 
Devops Devops Devops, at Froscon
Devops Devops Devops, at FrosconDevops Devops Devops, at Froscon
Devops Devops Devops, at Froscon
Kris Buytaert
 
Presentation
PresentationPresentation
Presentation
Thomas Franz
 

Similar to Concurrent Programming in Golang - DILo Surabaya (20)

GoLang - Why It Matters
GoLang -  Why It MattersGoLang -  Why It Matters
GoLang - Why It Matters
 
Devops, the future is here, it's just not evenly distributed yet.
Devops, the future is here, it's just not evenly distributed yet.Devops, the future is here, it's just not evenly distributed yet.
Devops, the future is here, it's just not evenly distributed yet.
 
From hello world to goodbye code
From hello world to goodbye codeFrom hello world to goodbye code
From hello world to goodbye code
 
Introduction to GoLang
Introduction to GoLangIntroduction to GoLang
Introduction to GoLang
 
OS Accelerate London - 09/16/15
OS Accelerate London - 09/16/15OS Accelerate London - 09/16/15
OS Accelerate London - 09/16/15
 
Agile Software Development
Agile Software DevelopmentAgile Software Development
Agile Software Development
 
Java programming basics
Java programming basicsJava programming basics
Java programming basics
 
Optimizely for Developers
Optimizely for DevelopersOptimizely for Developers
Optimizely for Developers
 
Modern Continuous Software Delivery
Modern Continuous Software DeliveryModern Continuous Software Delivery
Modern Continuous Software Delivery
 
Continuous integration - ThangTD
Continuous integration - ThangTDContinuous integration - ThangTD
Continuous integration - ThangTD
 
Go Language presentation
Go Language presentationGo Language presentation
Go Language presentation
 
Go language
Go language Go language
Go language
 
Devops for drupal
Devops for  drupalDevops for  drupal
Devops for drupal
 
Top 7 Reasons Using Golang for Mobile App Development-Connect Infosoft.pptx
Top 7 Reasons Using Golang for Mobile App Development-Connect Infosoft.pptxTop 7 Reasons Using Golang for Mobile App Development-Connect Infosoft.pptx
Top 7 Reasons Using Golang for Mobile App Development-Connect Infosoft.pptx
 
Why use Go for web development?
Why use Go for web development?Why use Go for web development?
Why use Go for web development?
 
Devops, Secops, Opsec, DevSec *ops *.* ?
Devops, Secops, Opsec, DevSec *ops *.* ?Devops, Secops, Opsec, DevSec *ops *.* ?
Devops, Secops, Opsec, DevSec *ops *.* ?
 
Golang development go language services in kerala- go language development in...
Golang development go language services in kerala- go language development in...Golang development go language services in kerala- go language development in...
Golang development go language services in kerala- go language development in...
 
It's XP Stupid (2019)
It's XP Stupid (2019)It's XP Stupid (2019)
It's XP Stupid (2019)
 
Devops Devops Devops, at Froscon
Devops Devops Devops, at FrosconDevops Devops Devops, at Froscon
Devops Devops Devops, at Froscon
 
Presentation
PresentationPresentation
Presentation
 

More from DILo Surabaya

Craate Your Own PHP Package - DILo Surabaya
Craate Your Own PHP Package - DILo SurabayaCraate Your Own PHP Package - DILo Surabaya
Craate Your Own PHP Package - DILo Surabaya
DILo Surabaya
 
ERP an Introduction - DILo Surabaya
ERP an Introduction - DILo SurabayaERP an Introduction - DILo Surabaya
ERP an Introduction - DILo Surabaya
DILo Surabaya
 
Introduction to Polymer Project - DILo Surabaya
Introduction to Polymer Project - DILo SurabayaIntroduction to Polymer Project - DILo Surabaya
Introduction to Polymer Project - DILo Surabaya
DILo Surabaya
 
React Native - DILo Surabaya
React Native -  DILo SurabayaReact Native -  DILo Surabaya
React Native - DILo Surabaya
DILo Surabaya
 
Open API Secification with Swagger - DILo Surabaya
Open API Secification with Swagger - DILo SurabayaOpen API Secification with Swagger - DILo Surabaya
Open API Secification with Swagger - DILo Surabaya
DILo Surabaya
 
Having Fun with Kotlin Android - DILo Surabaya
Having Fun with Kotlin Android - DILo SurabayaHaving Fun with Kotlin Android - DILo Surabaya
Having Fun with Kotlin Android - DILo Surabaya
DILo Surabaya
 
Gitflow - DILo Surabaya
Gitflow - DILo SurabayaGitflow - DILo Surabaya
Gitflow - DILo Surabaya
DILo Surabaya
 

More from DILo Surabaya (7)

Craate Your Own PHP Package - DILo Surabaya
Craate Your Own PHP Package - DILo SurabayaCraate Your Own PHP Package - DILo Surabaya
Craate Your Own PHP Package - DILo Surabaya
 
ERP an Introduction - DILo Surabaya
ERP an Introduction - DILo SurabayaERP an Introduction - DILo Surabaya
ERP an Introduction - DILo Surabaya
 
Introduction to Polymer Project - DILo Surabaya
Introduction to Polymer Project - DILo SurabayaIntroduction to Polymer Project - DILo Surabaya
Introduction to Polymer Project - DILo Surabaya
 
React Native - DILo Surabaya
React Native -  DILo SurabayaReact Native -  DILo Surabaya
React Native - DILo Surabaya
 
Open API Secification with Swagger - DILo Surabaya
Open API Secification with Swagger - DILo SurabayaOpen API Secification with Swagger - DILo Surabaya
Open API Secification with Swagger - DILo Surabaya
 
Having Fun with Kotlin Android - DILo Surabaya
Having Fun with Kotlin Android - DILo SurabayaHaving Fun with Kotlin Android - DILo Surabaya
Having Fun with Kotlin Android - DILo Surabaya
 
Gitflow - DILo Surabaya
Gitflow - DILo SurabayaGitflow - DILo Surabaya
Gitflow - DILo Surabaya
 

Recently uploaded

DRUGS AND ITS classification slide share
DRUGS AND ITS classification slide shareDRUGS AND ITS classification slide share
DRUGS AND ITS classification slide share
taiba qazi
 
MARY JANE WILSON, A “BOA MÃE” .
MARY JANE WILSON, A “BOA MÃE”           .MARY JANE WILSON, A “BOA MÃE”           .
MARY JANE WILSON, A “BOA MÃE” .
Colégio Santa Teresinha
 
Walmart Business+ and Spark Good for Nonprofits.pdf
Walmart Business+ and Spark Good for Nonprofits.pdfWalmart Business+ and Spark Good for Nonprofits.pdf
Walmart Business+ and Spark Good for Nonprofits.pdf
TechSoup
 
The History of Stoke Newington Street Names
The History of Stoke Newington Street NamesThe History of Stoke Newington Street Names
The History of Stoke Newington Street Names
History of Stoke Newington
 
writing about opinions about Australia the movie
writing about opinions about Australia the moviewriting about opinions about Australia the movie
writing about opinions about Australia the movie
Nicholas Montgomery
 
The simplified electron and muon model, Oscillating Spacetime: The Foundation...
The simplified electron and muon model, Oscillating Spacetime: The Foundation...The simplified electron and muon model, Oscillating Spacetime: The Foundation...
The simplified electron and muon model, Oscillating Spacetime: The Foundation...
RitikBhardwaj56
 
South African Journal of Science: Writing with integrity workshop (2024)
South African Journal of Science: Writing with integrity workshop (2024)South African Journal of Science: Writing with integrity workshop (2024)
South African Journal of Science: Writing with integrity workshop (2024)
Academy of Science of South Africa
 
Azure Interview Questions and Answers PDF By ScholarHat
Azure Interview Questions and Answers PDF By ScholarHatAzure Interview Questions and Answers PDF By ScholarHat
Azure Interview Questions and Answers PDF By ScholarHat
Scholarhat
 
Community pharmacy- Social and preventive pharmacy UNIT 5
Community pharmacy- Social and preventive pharmacy UNIT 5Community pharmacy- Social and preventive pharmacy UNIT 5
Community pharmacy- Social and preventive pharmacy UNIT 5
sayalidalavi006
 
C1 Rubenstein AP HuG xxxxxxxxxxxxxx.pptx
C1 Rubenstein AP HuG xxxxxxxxxxxxxx.pptxC1 Rubenstein AP HuG xxxxxxxxxxxxxx.pptx
C1 Rubenstein AP HuG xxxxxxxxxxxxxx.pptx
mulvey2
 
How to Build a Module in Odoo 17 Using the Scaffold Method
How to Build a Module in Odoo 17 Using the Scaffold MethodHow to Build a Module in Odoo 17 Using the Scaffold Method
How to Build a Module in Odoo 17 Using the Scaffold Method
Celine George
 
Film vocab for eal 3 students: Australia the movie
Film vocab for eal 3 students: Australia the movieFilm vocab for eal 3 students: Australia the movie
Film vocab for eal 3 students: Australia the movie
Nicholas Montgomery
 
Life upper-Intermediate B2 Workbook for student
Life upper-Intermediate B2 Workbook for studentLife upper-Intermediate B2 Workbook for student
Life upper-Intermediate B2 Workbook for student
NgcHiNguyn25
 
Executive Directors Chat Leveraging AI for Diversity, Equity, and Inclusion
Executive Directors Chat  Leveraging AI for Diversity, Equity, and InclusionExecutive Directors Chat  Leveraging AI for Diversity, Equity, and Inclusion
Executive Directors Chat Leveraging AI for Diversity, Equity, and Inclusion
TechSoup
 
Cognitive Development Adolescence Psychology
Cognitive Development Adolescence PsychologyCognitive Development Adolescence Psychology
Cognitive Development Adolescence Psychology
paigestewart1632
 
ANATOMY AND BIOMECHANICS OF HIP JOINT.pdf
ANATOMY AND BIOMECHANICS OF HIP JOINT.pdfANATOMY AND BIOMECHANICS OF HIP JOINT.pdf
ANATOMY AND BIOMECHANICS OF HIP JOINT.pdf
Priyankaranawat4
 
BÀI TẬP BỔ TRỢ TIẾNG ANH 8 CẢ NĂM - GLOBAL SUCCESS - NĂM HỌC 2023-2024 (CÓ FI...
BÀI TẬP BỔ TRỢ TIẾNG ANH 8 CẢ NĂM - GLOBAL SUCCESS - NĂM HỌC 2023-2024 (CÓ FI...BÀI TẬP BỔ TRỢ TIẾNG ANH 8 CẢ NĂM - GLOBAL SUCCESS - NĂM HỌC 2023-2024 (CÓ FI...
BÀI TẬP BỔ TRỢ TIẾNG ANH 8 CẢ NĂM - GLOBAL SUCCESS - NĂM HỌC 2023-2024 (CÓ FI...
Nguyen Thanh Tu Collection
 
Pengantar Penggunaan Flutter - Dart programming language1.pptx
Pengantar Penggunaan Flutter - Dart programming language1.pptxPengantar Penggunaan Flutter - Dart programming language1.pptx
Pengantar Penggunaan Flutter - Dart programming language1.pptx
Fajar Baskoro
 
Digital Artefact 1 - Tiny Home Environmental Design
Digital Artefact 1 - Tiny Home Environmental DesignDigital Artefact 1 - Tiny Home Environmental Design
Digital Artefact 1 - Tiny Home Environmental Design
amberjdewit93
 
RPMS TEMPLATE FOR SCHOOL YEAR 2023-2024 FOR TEACHER 1 TO TEACHER 3
RPMS TEMPLATE FOR SCHOOL YEAR 2023-2024 FOR TEACHER 1 TO TEACHER 3RPMS TEMPLATE FOR SCHOOL YEAR 2023-2024 FOR TEACHER 1 TO TEACHER 3
RPMS TEMPLATE FOR SCHOOL YEAR 2023-2024 FOR TEACHER 1 TO TEACHER 3
IreneSebastianRueco1
 

Recently uploaded (20)

DRUGS AND ITS classification slide share
DRUGS AND ITS classification slide shareDRUGS AND ITS classification slide share
DRUGS AND ITS classification slide share
 
MARY JANE WILSON, A “BOA MÃE” .
MARY JANE WILSON, A “BOA MÃE”           .MARY JANE WILSON, A “BOA MÃE”           .
MARY JANE WILSON, A “BOA MÃE” .
 
Walmart Business+ and Spark Good for Nonprofits.pdf
Walmart Business+ and Spark Good for Nonprofits.pdfWalmart Business+ and Spark Good for Nonprofits.pdf
Walmart Business+ and Spark Good for Nonprofits.pdf
 
The History of Stoke Newington Street Names
The History of Stoke Newington Street NamesThe History of Stoke Newington Street Names
The History of Stoke Newington Street Names
 
writing about opinions about Australia the movie
writing about opinions about Australia the moviewriting about opinions about Australia the movie
writing about opinions about Australia the movie
 
The simplified electron and muon model, Oscillating Spacetime: The Foundation...
The simplified electron and muon model, Oscillating Spacetime: The Foundation...The simplified electron and muon model, Oscillating Spacetime: The Foundation...
The simplified electron and muon model, Oscillating Spacetime: The Foundation...
 
South African Journal of Science: Writing with integrity workshop (2024)
South African Journal of Science: Writing with integrity workshop (2024)South African Journal of Science: Writing with integrity workshop (2024)
South African Journal of Science: Writing with integrity workshop (2024)
 
Azure Interview Questions and Answers PDF By ScholarHat
Azure Interview Questions and Answers PDF By ScholarHatAzure Interview Questions and Answers PDF By ScholarHat
Azure Interview Questions and Answers PDF By ScholarHat
 
Community pharmacy- Social and preventive pharmacy UNIT 5
Community pharmacy- Social and preventive pharmacy UNIT 5Community pharmacy- Social and preventive pharmacy UNIT 5
Community pharmacy- Social and preventive pharmacy UNIT 5
 
C1 Rubenstein AP HuG xxxxxxxxxxxxxx.pptx
C1 Rubenstein AP HuG xxxxxxxxxxxxxx.pptxC1 Rubenstein AP HuG xxxxxxxxxxxxxx.pptx
C1 Rubenstein AP HuG xxxxxxxxxxxxxx.pptx
 
How to Build a Module in Odoo 17 Using the Scaffold Method
How to Build a Module in Odoo 17 Using the Scaffold MethodHow to Build a Module in Odoo 17 Using the Scaffold Method
How to Build a Module in Odoo 17 Using the Scaffold Method
 
Film vocab for eal 3 students: Australia the movie
Film vocab for eal 3 students: Australia the movieFilm vocab for eal 3 students: Australia the movie
Film vocab for eal 3 students: Australia the movie
 
Life upper-Intermediate B2 Workbook for student
Life upper-Intermediate B2 Workbook for studentLife upper-Intermediate B2 Workbook for student
Life upper-Intermediate B2 Workbook for student
 
Executive Directors Chat Leveraging AI for Diversity, Equity, and Inclusion
Executive Directors Chat  Leveraging AI for Diversity, Equity, and InclusionExecutive Directors Chat  Leveraging AI for Diversity, Equity, and Inclusion
Executive Directors Chat Leveraging AI for Diversity, Equity, and Inclusion
 
Cognitive Development Adolescence Psychology
Cognitive Development Adolescence PsychologyCognitive Development Adolescence Psychology
Cognitive Development Adolescence Psychology
 
ANATOMY AND BIOMECHANICS OF HIP JOINT.pdf
ANATOMY AND BIOMECHANICS OF HIP JOINT.pdfANATOMY AND BIOMECHANICS OF HIP JOINT.pdf
ANATOMY AND BIOMECHANICS OF HIP JOINT.pdf
 
BÀI TẬP BỔ TRỢ TIẾNG ANH 8 CẢ NĂM - GLOBAL SUCCESS - NĂM HỌC 2023-2024 (CÓ FI...
BÀI TẬP BỔ TRỢ TIẾNG ANH 8 CẢ NĂM - GLOBAL SUCCESS - NĂM HỌC 2023-2024 (CÓ FI...BÀI TẬP BỔ TRỢ TIẾNG ANH 8 CẢ NĂM - GLOBAL SUCCESS - NĂM HỌC 2023-2024 (CÓ FI...
BÀI TẬP BỔ TRỢ TIẾNG ANH 8 CẢ NĂM - GLOBAL SUCCESS - NĂM HỌC 2023-2024 (CÓ FI...
 
Pengantar Penggunaan Flutter - Dart programming language1.pptx
Pengantar Penggunaan Flutter - Dart programming language1.pptxPengantar Penggunaan Flutter - Dart programming language1.pptx
Pengantar Penggunaan Flutter - Dart programming language1.pptx
 
Digital Artefact 1 - Tiny Home Environmental Design
Digital Artefact 1 - Tiny Home Environmental DesignDigital Artefact 1 - Tiny Home Environmental Design
Digital Artefact 1 - Tiny Home Environmental Design
 
RPMS TEMPLATE FOR SCHOOL YEAR 2023-2024 FOR TEACHER 1 TO TEACHER 3
RPMS TEMPLATE FOR SCHOOL YEAR 2023-2024 FOR TEACHER 1 TO TEACHER 3RPMS TEMPLATE FOR SCHOOL YEAR 2023-2024 FOR TEACHER 1 TO TEACHER 3
RPMS TEMPLATE FOR SCHOOL YEAR 2023-2024 FOR TEACHER 1 TO TEACHER 3
 

Concurrent Programming in Golang - DILo Surabaya