SlideShare a Scribd company logo
Rob Keefer, PhD

@rbkeefer
A Brief Introduction to Concurrent
Programming
pomiet.com @rbkeefer
Goal
Goal of Concurrency is to get more done in less time.
Multiple independent tasks
Repeat same task
Solution: Parallelism
pomiet.com @rbkeefer
Parallelism
pomiet.com @rbkeefer
Direction
Processes
Problems with Concurrency
Traditional Solutions
New Approaches
pomiet.com @rbkeefer
Turn the Crank
pomiet.com @rbkeefer
Processor
pomiet.com @rbkeefer
Processor
pomiet.com @rbkeefer
Processor
pomiet.com @rbkeefer
Processor
pomiet.com @rbkeefer
Take Advantage of the Tech
pomiet.com @rbkeefer
Problems
1. Starting / maintaining processes
2. Communication between processes
• Remote procedure call (RPC)
• Message passing
3. Shared Resources
• Deadlock
• Livelock
• Race conditions
• Starvation
pomiet.com @rbkeefer
Five Volunteers
pomiet.com @rbkeefer
Problems: Deadlock
pomiet.com @rbkeefer
Problems: Livelock
pomiet.com @rbkeefer
Problems: Race Condition
pomiet.com @rbkeefer
Problems: Starvation
pomiet.com @rbkeefer
Approaches
Traditional Object Oriented
Modern Functional
General Philosophy: Failure Prevention
General Philosophy: Embrace Failure
Monitor
Mutual Exclusion (Mutex)
Prioritization Algorithms
Support process death and resurrection
Support atomic functions
Fairness algorithms embedded in VM
pomiet.com @rbkeefer
Monitor
pomiet.com @rbkeefer
Mutex
pomiet.com @rbkeefer
def call(process_name, message, timeout  5000)
ref = Process.monitor(process_name)
try do
send(process_name, {:message, {ref, self()}, message})
rescue
_ -> :error
end
receive do
{:reply, ref, reply} ->
Process.demonitor(ref, [:flush])
reply
{:DOWN, ref, :process, _, reason} ->
{:error, reason}
exit(reason)
after timeout -> exit(:timeout)
end
end
Elixir - Lock Prevention
<- exit on timeout
pomiet.com @rbkeefer
def answer(process_name, message, timeout  5000)
receive do
{:knock, ref, reply} ->
reply # "Who's there?"
{:DOWN, ref, :process, _, reason} ->
{:error, reason}
exit(reason) # No one knocking
after timeout -> exit(:timeout)
end
. . .
def knock(process_name, message, timeout  5000)
receive do
{:reply, ref, reply} ->
reply # Tell who you are
{:DOWN, ref, :process, _, reason} ->
{:error, reason}
exit(reason) # No one home
after timeout -> exit(:timeout)
end
. . .
Elixir - Race Condition
<- exit on timeout
<- exit on timeout
pomiet.com @rbkeefer
Note on Garbage Collection
Credit: Greg Mefford
pomiet.com @rbkeefer
A Few Facts
Traditional Object Oriented
Modern Functional
Bring data and behaviors together
Simulation of behavior (heuristics)
Overhead: Java threads 512 Kb / thread
Require thread pools / execution management
Shared heap
Hard limits on memory use
Separate data from behaviors
Data manipulation (algorithms)
Overhead: Elixir 512 b / process
Processes easily accessible
Individual private heap
Unbounded memory
pomiet.com @rbkeefer
Scale with Resilience
Resilience: ability of a system to adapt or keep
working when challenges occur
pomiet.com @rbkeefer
Questions to Consider
Think Different:
Fault Tolerance:
What happens if a
dependency starts failing
slowly?
What’s the worse-scenario for
total failure?
Efficiency:
Is it possible to precompute
data?
Are you doing as little work as
possible?
Is load testing part of the
regression test suite?
Operability:
Where are the nonlinearities in
load or failure responses?
What are the capacity needs?
How does the system scale?
pomiet.com @rbkeefer
Continue the Conversation
Rob Keefer, PhD
rob.Keefer@pomiet.com
@rbkeefer

More Related Content

PPT
GC free coding in @Java presented @Geecon
PPTX
Apache flink
PPTX
Project Reactor By Example
PPT
Shell Scripting
PPTX
Caching
PDF
Data Storage Tips for Optimal Spark Performance-(Vida Ha, Databricks)
PDF
Spark 2.x Troubleshooting Guide
 
PPT
Intro to MySQL Master Slave Replication
GC free coding in @Java presented @Geecon
Apache flink
Project Reactor By Example
Shell Scripting
Caching
Data Storage Tips for Optimal Spark Performance-(Vida Ha, Databricks)
Spark 2.x Troubleshooting Guide
 
Intro to MySQL Master Slave Replication

What's hot (20)

PDF
Introduction to Apache Flink - Fast and reliable big data processing
PPT
Apache Flink Crash Course by Slim Baltagi and Srini Palthepu
PPTX
Cephfs jewel mds performance benchmark
PDF
Troubleshooting redis
PPTX
Kafka PPT.pptx
PDF
2. 從 REPL 到 IDE
PPTX
Spark etl
PPTX
Kafka at Peak Performance
PDF
Neo4j: Graph-like power
PDF
Top 5 mistakes when writing Spark applications
PDF
Linux programming - Getting self started
PDF
KFServing and Feast
PPTX
High performance and high availability proxies for MySQL
PDF
Spark overview
PPTX
Kafka Tutorial: Advanced Producers
PDF
Automation with ansible
PDF
Linux systems - Linux Commands and Shell Scripting
PDF
Flink Forward Berlin 2017: Stefan Richter - A look at Flink's internal data s...
PPTX
PDF
BeagleBone Black Bootloaders
Introduction to Apache Flink - Fast and reliable big data processing
Apache Flink Crash Course by Slim Baltagi and Srini Palthepu
Cephfs jewel mds performance benchmark
Troubleshooting redis
Kafka PPT.pptx
2. 從 REPL 到 IDE
Spark etl
Kafka at Peak Performance
Neo4j: Graph-like power
Top 5 mistakes when writing Spark applications
Linux programming - Getting self started
KFServing and Feast
High performance and high availability proxies for MySQL
Spark overview
Kafka Tutorial: Advanced Producers
Automation with ansible
Linux systems - Linux Commands and Shell Scripting
Flink Forward Berlin 2017: Stefan Richter - A look at Flink's internal data s...
BeagleBone Black Bootloaders
Ad

Similar to Brief Introduction to Concurrent Programming (20)

PDF
Awesome Concurrency with Elixir Tasks
PDF
Yurii Bodarev - OTP, Phoenix & Ecto: Three Pillars of Elixir
PDF
Elixir Programming Language 101
PPTX
Repeating History...On Purpose...with Elixir
PDF
Ruby's Concurrency Management: Now and Future
PDF
Concurrency: Rubies, Plural
PDF
Concurrency: Rubies, plural
PDF
Elixir/OTP for PHP developers
PPTX
A sip of elixir
PDF
GenServer in action
PDF
GenServer in Action – Yurii Bodarev
PDF
Overview of Scientific Workflows - Why Use Them?
PPTX
PMIx Updated Overview
PDF
Xen Project Contributor Training Part 2 - Processes and Conventions v1.0
PDF
Eventdriven I/O - A hands on introduction
PDF
Building Distributed Systems
PDF
PyCon HK 2018 - Heterogeneous job processing with Apache Kafka
PDF
Bootstrap |> Elixir - Easy fun for busy developers
PDF
Advanced task management with Celery
PPT
A Practical Event Driven Model
Awesome Concurrency with Elixir Tasks
Yurii Bodarev - OTP, Phoenix & Ecto: Three Pillars of Elixir
Elixir Programming Language 101
Repeating History...On Purpose...with Elixir
Ruby's Concurrency Management: Now and Future
Concurrency: Rubies, Plural
Concurrency: Rubies, plural
Elixir/OTP for PHP developers
A sip of elixir
GenServer in action
GenServer in Action – Yurii Bodarev
Overview of Scientific Workflows - Why Use Them?
PMIx Updated Overview
Xen Project Contributor Training Part 2 - Processes and Conventions v1.0
Eventdriven I/O - A hands on introduction
Building Distributed Systems
PyCon HK 2018 - Heterogeneous job processing with Apache Kafka
Bootstrap |> Elixir - Easy fun for busy developers
Advanced task management with Celery
A Practical Event Driven Model
Ad

More from Rob Keefer (17)

PDF
Goldilocks and AI
PDF
7 Habits of Highly Effective Stakeholders
PDF
Tranquilty Over Tubulence
PDF
Project Peace of Mind
PDF
MVP in Complex Environments
PDF
Technostress in Healthcare
PDF
Fail Smart, Not Just Fast: FMEA Workshop
PDF
Embrace Complexity
PDF
Do Go Map
PDF
Developer Flow
PDF
Brain Sketching
PDF
Blocks to DevOps
PDF
Agile UX
PDF
DoGo Map Workshop
PDF
Team Peace of Mind
PDF
Design Innovation
PDF
Agile UX
Goldilocks and AI
7 Habits of Highly Effective Stakeholders
Tranquilty Over Tubulence
Project Peace of Mind
MVP in Complex Environments
Technostress in Healthcare
Fail Smart, Not Just Fast: FMEA Workshop
Embrace Complexity
Do Go Map
Developer Flow
Brain Sketching
Blocks to DevOps
Agile UX
DoGo Map Workshop
Team Peace of Mind
Design Innovation
Agile UX

Recently uploaded (20)

PPTX
Lecture 3: Operating Systems Introduction to Computer Hardware Systems
PDF
Wondershare Filmora 15 Crack With Activation Key [2025
PPTX
Agentic AI Use Case- Contract Lifecycle Management (CLM).pptx
PPTX
history of c programming in notes for students .pptx
PDF
PTS Company Brochure 2025 (1).pdf.......
PPTX
Introduction to Artificial Intelligence
PDF
Audit Checklist Design Aligning with ISO, IATF, and Industry Standards — Omne...
PDF
medical staffing services at VALiNTRY
PDF
System and Network Administraation Chapter 3
PPTX
VVF-Customer-Presentation2025-Ver1.9.pptx
PDF
Design an Analysis of Algorithms I-SECS-1021-03
PPTX
Agentic AI : A Practical Guide. Undersating, Implementing and Scaling Autono...
PPTX
ai tools demonstartion for schools and inter college
PDF
Why TechBuilder is the Future of Pickup and Delivery App Development (1).pdf
PDF
Adobe Premiere Pro 2025 (v24.5.0.057) Crack free
PDF
Upgrade and Innovation Strategies for SAP ERP Customers
PPTX
CHAPTER 2 - PM Management and IT Context
PDF
Internet Downloader Manager (IDM) Crack 6.42 Build 42 Updates Latest 2025
PDF
Understanding Forklifts - TECH EHS Solution
PDF
top salesforce developer skills in 2025.pdf
Lecture 3: Operating Systems Introduction to Computer Hardware Systems
Wondershare Filmora 15 Crack With Activation Key [2025
Agentic AI Use Case- Contract Lifecycle Management (CLM).pptx
history of c programming in notes for students .pptx
PTS Company Brochure 2025 (1).pdf.......
Introduction to Artificial Intelligence
Audit Checklist Design Aligning with ISO, IATF, and Industry Standards — Omne...
medical staffing services at VALiNTRY
System and Network Administraation Chapter 3
VVF-Customer-Presentation2025-Ver1.9.pptx
Design an Analysis of Algorithms I-SECS-1021-03
Agentic AI : A Practical Guide. Undersating, Implementing and Scaling Autono...
ai tools demonstartion for schools and inter college
Why TechBuilder is the Future of Pickup and Delivery App Development (1).pdf
Adobe Premiere Pro 2025 (v24.5.0.057) Crack free
Upgrade and Innovation Strategies for SAP ERP Customers
CHAPTER 2 - PM Management and IT Context
Internet Downloader Manager (IDM) Crack 6.42 Build 42 Updates Latest 2025
Understanding Forklifts - TECH EHS Solution
top salesforce developer skills in 2025.pdf

Brief Introduction to Concurrent Programming