SlideShare a Scribd company logo
Multithreading in
PowerShell with runspaces
1/18/2017
Drew Furgiuele
Senior DBA, IGS Energy
1/18/2017 2
About me
dfurgiuele@igsenergy.com
@pittfurg
http://www.port1433.com
http://www.genesface.com
Contact Info
I’m a Senior SQL Server DBA at
IGS Energy in Dublin, Ohio. I’ve
been using SQL Server since SQL
Server 2000 and I love it. I also
enjoy DevOps, release
management, and PowerShell.
AGENDA
1/18/2017 3
1. Multithreading in PowerShell: Why?
2. How it works
3. Differences between runspaces and Invoke-Job
4. Examples!
Multithreading with PowerShell
• Most PowerShell scripts execute serially
• Which is usually fine!
• … Except when it isn’t
• Some things don’t always run fast, despite all the
optimization in the world
• And if something runs “fast” when applied to n+1
targets, it might become slow
1/18/2017 4
Runspaces – The good
• Runspaces spin up new threads on an existing
process for parallel execution.
• Threads can be invoked asynchronously
• Can automatically manage the number of
threads executing (so you don’t overwhelm
your CPU)
• Can return pretty much anything you want
1/18/2017 5
Runspaces – The not so good
1/18/2017 6
• Can be complex to set up and configure
• Need monitored
• Need cleaned up
• Are hard to troubleshoot
• Modules don’t persist
“… so preoccupied with whether or not you could…”
• “…that you didn't stop to think if you should.”
• Multithreading is a great tool to keep in your
toolbox, but it’s not a hammer looking for a nail
• Ever heard of failing at scale?
• How about failing at scalex?
1/18/2017 7
Creating Runspaces
• CODE!
1/18/2017 8
What about Start-Job / Receive-Job?
• Start-Job incurs a lot of overhead
• No throttling
• Same goes for –AsJob and Invoke-Command
• Does have a –ThrottleLimit, but that just limits
concurrent commands, NOT sessions
• How much of a difference? Let’s see it in action.
1/18/2017 9
Practical Example #1
• Reading Error Logs
• Text parsing in PowerShell is an expensive, slow
process
• Breaking up the workload into threads can vastly
improve performance
1/18/2017 10
Practical Example
• Master Data Management
1/18/2017 11
Learning More
• Runspaces – Hey Scripting Guy!
https://blogs.technet.microsoft.com/heyscriptingguy/
2015/11/26/beginning-use-of-powershell-runspaces-
part-1/
• Runspaces simplified as much as possible:
https://blog.netnerds.net/2016/12/runspaces-
simplified/
• Joe Prox’s PoshRSJob:
https://github.com/proxb/PoshRSJob
1/18/2017 12
1/18/2017 13
About me
dfurgiuele@igsenergy.com
@pittfurg
http://www.port1433.com
http://www.genesface.com
Contact Info
I’m a Senior SQL Server DBA at
IGS Energy in Dublin, Ohio. I’ve
been using SQL Server since SQL
Server 2000 and I love it. I also
enjoy DevOps, release
management, and PowerShell.
Ad

Recommended

Full stack development using javascript what and why - ajay chandravadiya
Full stack development using javascript what and why - ajay chandravadiya
ajayrcgmail
 
Creating Hyper Performant Web Apps with React
Creating Hyper Performant Web Apps with React
Jp DeVries
 
Saving Time By Testing With Jest
Saving Time By Testing With Jest
Ben McCormick
 
Seven Jobs You Should Be Running #sqlsat126
Seven Jobs You Should Be Running #sqlsat126
Mike Hillwig
 
Composer manager module for Drupal
Composer manager module for Drupal
Le Thanh Sang
 
SQL Server Days 2014 - How to (not) torment your fellow SSIS developer
SQL Server Days 2014 - How to (not) torment your fellow SSIS developer
KoenVerbeeck
 
The Five Stages of Chef Grief: My First 6 months with Chef, and Getting Aroun...
The Five Stages of Chef Grief: My First 6 months with Chef, and Getting Aroun...
DevOpsDays Austin 2014
 
Tech writing in a continuous deployment environment
Tech writing in a continuous deployment environment
Christine Burwinkle
 
ClojureScript: I can't believe this is JavaScript
ClojureScript: I can't believe this is JavaScript
Eric Normand
 
Why puppet? Why now?
Why puppet? Why now?
Server Density
 
New Server in an Hour
New Server in an Hour
Mike Hillwig
 
An introduction in to the world of front end automation - frontend ne (02 07-15)
An introduction in to the world of front end automation - frontend ne (02 07-15)
frontendne
 
Introduction to Coffeescript
Introduction to Coffeescript
Indies Services
 
Kanban @ nine.ch
Kanban @ nine.ch
Matías E. Fernández
 
Performance - When, What and How
Performance - When, What and How
Astrails
 
GETTING STARTED WITH JavaScript and ReactJS
GETTING STARTED WITH JavaScript and ReactJS
Iftekher Islam Sunny
 
DevOps for Drupal: Why We Cook With Chef
DevOps for Drupal: Why We Cook With Chef
Promet Source
 
Coffee script final
Coffee script final
priyankazope
 
Raven db byexample
Raven db byexample
Emil Cardell
 
Zeev Suraski "The PHP 7 Story, and beyond"
Zeev Suraski "The PHP 7 Story, and beyond"
Fwdays
 
No More Cowboy Coding: Modern WordPress Development Workflow That Scales
No More Cowboy Coding: Modern WordPress Development Workflow That Scales
Tom Howard
 
Coding for the cloud - development of modern web applications
Coding for the cloud - development of modern web applications
Wekoslav Stefanovski
 
It Sounded Good on Paper - Lessons Learned with Puppet
It Sounded Good on Paper - Lessons Learned with Puppet
Jeffery Smith
 
Developer Week
Developer Week
Docker, Inc.
 
Supporting large scale React applications
Supporting large scale React applications
Maurice De Beijer [MVP]
 
Building large scalable mission critical business applications on the web
Building large scalable mission critical business applications on the web
Maurice De Beijer [MVP]
 
Getting started with dev tools (atl)
Getting started with dev tools (atl)
Thinkful
 
Devops at Startup Weekend BXL
Devops at Startup Weekend BXL
Kris Buytaert
 
I6 - State of the art SharePoint PowerShell Nation 2017 - Spencer Harbar
I6 - State of the art SharePoint PowerShell Nation 2017 - Spencer Harbar
SPS Paris
 
Erlang factory SF 2011 "Erlang and the big switch in social games"
Erlang factory SF 2011 "Erlang and the big switch in social games"
Paolo Negri
 

More Related Content

What's hot (20)

ClojureScript: I can't believe this is JavaScript
ClojureScript: I can't believe this is JavaScript
Eric Normand
 
Why puppet? Why now?
Why puppet? Why now?
Server Density
 
New Server in an Hour
New Server in an Hour
Mike Hillwig
 
An introduction in to the world of front end automation - frontend ne (02 07-15)
An introduction in to the world of front end automation - frontend ne (02 07-15)
frontendne
 
Introduction to Coffeescript
Introduction to Coffeescript
Indies Services
 
Kanban @ nine.ch
Kanban @ nine.ch
Matías E. Fernández
 
Performance - When, What and How
Performance - When, What and How
Astrails
 
GETTING STARTED WITH JavaScript and ReactJS
GETTING STARTED WITH JavaScript and ReactJS
Iftekher Islam Sunny
 
DevOps for Drupal: Why We Cook With Chef
DevOps for Drupal: Why We Cook With Chef
Promet Source
 
Coffee script final
Coffee script final
priyankazope
 
Raven db byexample
Raven db byexample
Emil Cardell
 
Zeev Suraski "The PHP 7 Story, and beyond"
Zeev Suraski "The PHP 7 Story, and beyond"
Fwdays
 
No More Cowboy Coding: Modern WordPress Development Workflow That Scales
No More Cowboy Coding: Modern WordPress Development Workflow That Scales
Tom Howard
 
Coding for the cloud - development of modern web applications
Coding for the cloud - development of modern web applications
Wekoslav Stefanovski
 
It Sounded Good on Paper - Lessons Learned with Puppet
It Sounded Good on Paper - Lessons Learned with Puppet
Jeffery Smith
 
Developer Week
Developer Week
Docker, Inc.
 
Supporting large scale React applications
Supporting large scale React applications
Maurice De Beijer [MVP]
 
Building large scalable mission critical business applications on the web
Building large scalable mission critical business applications on the web
Maurice De Beijer [MVP]
 
Getting started with dev tools (atl)
Getting started with dev tools (atl)
Thinkful
 
Devops at Startup Weekend BXL
Devops at Startup Weekend BXL
Kris Buytaert
 
ClojureScript: I can't believe this is JavaScript
ClojureScript: I can't believe this is JavaScript
Eric Normand
 
New Server in an Hour
New Server in an Hour
Mike Hillwig
 
An introduction in to the world of front end automation - frontend ne (02 07-15)
An introduction in to the world of front end automation - frontend ne (02 07-15)
frontendne
 
Introduction to Coffeescript
Introduction to Coffeescript
Indies Services
 
Performance - When, What and How
Performance - When, What and How
Astrails
 
GETTING STARTED WITH JavaScript and ReactJS
GETTING STARTED WITH JavaScript and ReactJS
Iftekher Islam Sunny
 
DevOps for Drupal: Why We Cook With Chef
DevOps for Drupal: Why We Cook With Chef
Promet Source
 
Coffee script final
Coffee script final
priyankazope
 
Raven db byexample
Raven db byexample
Emil Cardell
 
Zeev Suraski "The PHP 7 Story, and beyond"
Zeev Suraski "The PHP 7 Story, and beyond"
Fwdays
 
No More Cowboy Coding: Modern WordPress Development Workflow That Scales
No More Cowboy Coding: Modern WordPress Development Workflow That Scales
Tom Howard
 
Coding for the cloud - development of modern web applications
Coding for the cloud - development of modern web applications
Wekoslav Stefanovski
 
It Sounded Good on Paper - Lessons Learned with Puppet
It Sounded Good on Paper - Lessons Learned with Puppet
Jeffery Smith
 
Supporting large scale React applications
Supporting large scale React applications
Maurice De Beijer [MVP]
 
Building large scalable mission critical business applications on the web
Building large scalable mission critical business applications on the web
Maurice De Beijer [MVP]
 
Getting started with dev tools (atl)
Getting started with dev tools (atl)
Thinkful
 
Devops at Startup Weekend BXL
Devops at Startup Weekend BXL
Kris Buytaert
 

Similar to PowerShell Runspaces (20)

I6 - State of the art SharePoint PowerShell Nation 2017 - Spencer Harbar
I6 - State of the art SharePoint PowerShell Nation 2017 - Spencer Harbar
SPS Paris
 
Erlang factory SF 2011 "Erlang and the big switch in social games"
Erlang factory SF 2011 "Erlang and the big switch in social games"
Paolo Negri
 
Erlang, the big switch in social games
Erlang, the big switch in social games
Wooga
 
How to get started with Site Reliability Engineering
How to get started with Site Reliability Engineering
Andrew Kirkpatrick
 
Devops in with the old, in with the new
Devops in with the old, in with the new
Jan Collijs
 
Learn from my Mistakes - Building Better Solutions in SPFx
Learn from my Mistakes - Building Better Solutions in SPFx
Thomas Daly
 
Bringing Open-Source Practices to Your Day Job
Bringing Open-Source Practices to Your Day Job
Ben Coe
 
Why use Go for web development?
Why use Go for web development?
Weng Wei
 
CI_CONF 2012: Scaling - Chris Miller
CI_CONF 2012: Scaling - Chris Miller
The Huffington Post Tech Team
 
CI_CONF 2012: Scaling
CI_CONF 2012: Scaling
Chris Miller
 
HyperDB, MySQL Performance, & Flavors of MySQL
HyperDB, MySQL Performance, & Flavors of MySQL
Evan Volgas
 
Untangling spring week11
Untangling spring week11
Derek Jacoby
 
The Characteristics of a Successful SPA
The Characteristics of a Successful SPA
Gil Fink
 
PostgreSQL worst practices, version FOSDEM PGDay 2017 by Ilya Kosmodemiansky
PostgreSQL worst practices, version FOSDEM PGDay 2017 by Ilya Kosmodemiansky
PostgreSQL-Consulting
 
Profiling and Tuning a Web Application - The Dirty Details
Profiling and Tuning a Web Application - The Dirty Details
Achievers Tech
 
Software development fundamentals
Software development fundamentals
Alfred Jett Grandeza
 
Untangling spring week1
Untangling spring week1
Derek Jacoby
 
Apache Con 2008 Top 10 Mistakes
Apache Con 2008 Top 10 Mistakes
John Coggeshall
 
Untangling - fall2017 - week 7
Untangling - fall2017 - week 7
Derek Jacoby
 
Neo4j Training Cypher
Neo4j Training Cypher
Max De Marzi
 
I6 - State of the art SharePoint PowerShell Nation 2017 - Spencer Harbar
I6 - State of the art SharePoint PowerShell Nation 2017 - Spencer Harbar
SPS Paris
 
Erlang factory SF 2011 "Erlang and the big switch in social games"
Erlang factory SF 2011 "Erlang and the big switch in social games"
Paolo Negri
 
Erlang, the big switch in social games
Erlang, the big switch in social games
Wooga
 
How to get started with Site Reliability Engineering
How to get started with Site Reliability Engineering
Andrew Kirkpatrick
 
Devops in with the old, in with the new
Devops in with the old, in with the new
Jan Collijs
 
Learn from my Mistakes - Building Better Solutions in SPFx
Learn from my Mistakes - Building Better Solutions in SPFx
Thomas Daly
 
Bringing Open-Source Practices to Your Day Job
Bringing Open-Source Practices to Your Day Job
Ben Coe
 
Why use Go for web development?
Why use Go for web development?
Weng Wei
 
CI_CONF 2012: Scaling
CI_CONF 2012: Scaling
Chris Miller
 
HyperDB, MySQL Performance, & Flavors of MySQL
HyperDB, MySQL Performance, & Flavors of MySQL
Evan Volgas
 
Untangling spring week11
Untangling spring week11
Derek Jacoby
 
The Characteristics of a Successful SPA
The Characteristics of a Successful SPA
Gil Fink
 
PostgreSQL worst practices, version FOSDEM PGDay 2017 by Ilya Kosmodemiansky
PostgreSQL worst practices, version FOSDEM PGDay 2017 by Ilya Kosmodemiansky
PostgreSQL-Consulting
 
Profiling and Tuning a Web Application - The Dirty Details
Profiling and Tuning a Web Application - The Dirty Details
Achievers Tech
 
Untangling spring week1
Untangling spring week1
Derek Jacoby
 
Apache Con 2008 Top 10 Mistakes
Apache Con 2008 Top 10 Mistakes
John Coggeshall
 
Untangling - fall2017 - week 7
Untangling - fall2017 - week 7
Derek Jacoby
 
Neo4j Training Cypher
Neo4j Training Cypher
Max De Marzi
 
Ad

Recently uploaded (20)

“Key Requirements to Successfully Implement Generative AI in Edge Devices—Opt...
“Key Requirements to Successfully Implement Generative AI in Edge Devices—Opt...
Edge AI and Vision Alliance
 
“Why It’s Critical to Have an Integrated Development Methodology for Edge AI,...
“Why It’s Critical to Have an Integrated Development Methodology for Edge AI,...
Edge AI and Vision Alliance
 
FIDO Seminar: Authentication for a Billion Consumers - Amazon.pptx
FIDO Seminar: Authentication for a Billion Consumers - Amazon.pptx
FIDO Alliance
 
Reducing Conflicts and Increasing Safety Along the Cycling Networks of East-F...
Reducing Conflicts and Increasing Safety Along the Cycling Networks of East-F...
Safe Software
 
Security Tips for Enterprise Azure Solutions
Security Tips for Enterprise Azure Solutions
Michele Leroux Bustamante
 
Providing an OGC API Processes REST Interface for FME Flow
Providing an OGC API Processes REST Interface for FME Flow
Safe Software
 
Securing Account Lifecycles in the Age of Deepfakes.pptx
Securing Account Lifecycles in the Age of Deepfakes.pptx
FIDO Alliance
 
Can We Use Rust to Develop Extensions for PostgreSQL? (POSETTE: An Event for ...
Can We Use Rust to Develop Extensions for PostgreSQL? (POSETTE: An Event for ...
NTT DATA Technology & Innovation
 
SAP Modernization Strategies for a Successful S/4HANA Journey.pdf
SAP Modernization Strategies for a Successful S/4HANA Journey.pdf
Precisely
 
ENERGY CONSUMPTION CALCULATION IN ENERGY-EFFICIENT AIR CONDITIONER.pdf
ENERGY CONSUMPTION CALCULATION IN ENERGY-EFFICIENT AIR CONDITIONER.pdf
Muhammad Rizwan Akram
 
Enabling BIM / GIS integrations with Other Systems with FME
Enabling BIM / GIS integrations with Other Systems with FME
Safe Software
 
TrustArc Webinar - 2025 Global Privacy Survey
TrustArc Webinar - 2025 Global Privacy Survey
TrustArc
 
National Fuels Treatments Initiative: Building a Seamless Map of Hazardous Fu...
National Fuels Treatments Initiative: Building a Seamless Map of Hazardous Fu...
Safe Software
 
FIDO Seminar: Perspectives on Passkeys & Consumer Adoption.pptx
FIDO Seminar: Perspectives on Passkeys & Consumer Adoption.pptx
FIDO Alliance
 
FME for Distribution & Transmission Integrity Management Program (DIMP & TIMP)
FME for Distribution & Transmission Integrity Management Program (DIMP & TIMP)
Safe Software
 
“From Enterprise to Makers: Driving Vision AI Innovation at the Extreme Edge,...
“From Enterprise to Makers: Driving Vision AI Innovation at the Extreme Edge,...
Edge AI and Vision Alliance
 
vertical-cnc-processing-centers-drillteq-v-200-en.pdf
vertical-cnc-processing-centers-drillteq-v-200-en.pdf
AmirStern2
 
Artificial Intelligence in the Nonprofit Boardroom.pdf
Artificial Intelligence in the Nonprofit Boardroom.pdf
OnBoard
 
Raman Bhaumik - Passionate Tech Enthusiast
Raman Bhaumik - Passionate Tech Enthusiast
Raman Bhaumik
 
The State of Web3 Industry- Industry Report
The State of Web3 Industry- Industry Report
Liveplex
 
“Key Requirements to Successfully Implement Generative AI in Edge Devices—Opt...
“Key Requirements to Successfully Implement Generative AI in Edge Devices—Opt...
Edge AI and Vision Alliance
 
“Why It’s Critical to Have an Integrated Development Methodology for Edge AI,...
“Why It’s Critical to Have an Integrated Development Methodology for Edge AI,...
Edge AI and Vision Alliance
 
FIDO Seminar: Authentication for a Billion Consumers - Amazon.pptx
FIDO Seminar: Authentication for a Billion Consumers - Amazon.pptx
FIDO Alliance
 
Reducing Conflicts and Increasing Safety Along the Cycling Networks of East-F...
Reducing Conflicts and Increasing Safety Along the Cycling Networks of East-F...
Safe Software
 
Security Tips for Enterprise Azure Solutions
Security Tips for Enterprise Azure Solutions
Michele Leroux Bustamante
 
Providing an OGC API Processes REST Interface for FME Flow
Providing an OGC API Processes REST Interface for FME Flow
Safe Software
 
Securing Account Lifecycles in the Age of Deepfakes.pptx
Securing Account Lifecycles in the Age of Deepfakes.pptx
FIDO Alliance
 
Can We Use Rust to Develop Extensions for PostgreSQL? (POSETTE: An Event for ...
Can We Use Rust to Develop Extensions for PostgreSQL? (POSETTE: An Event for ...
NTT DATA Technology & Innovation
 
SAP Modernization Strategies for a Successful S/4HANA Journey.pdf
SAP Modernization Strategies for a Successful S/4HANA Journey.pdf
Precisely
 
ENERGY CONSUMPTION CALCULATION IN ENERGY-EFFICIENT AIR CONDITIONER.pdf
ENERGY CONSUMPTION CALCULATION IN ENERGY-EFFICIENT AIR CONDITIONER.pdf
Muhammad Rizwan Akram
 
Enabling BIM / GIS integrations with Other Systems with FME
Enabling BIM / GIS integrations with Other Systems with FME
Safe Software
 
TrustArc Webinar - 2025 Global Privacy Survey
TrustArc Webinar - 2025 Global Privacy Survey
TrustArc
 
National Fuels Treatments Initiative: Building a Seamless Map of Hazardous Fu...
National Fuels Treatments Initiative: Building a Seamless Map of Hazardous Fu...
Safe Software
 
FIDO Seminar: Perspectives on Passkeys & Consumer Adoption.pptx
FIDO Seminar: Perspectives on Passkeys & Consumer Adoption.pptx
FIDO Alliance
 
FME for Distribution & Transmission Integrity Management Program (DIMP & TIMP)
FME for Distribution & Transmission Integrity Management Program (DIMP & TIMP)
Safe Software
 
“From Enterprise to Makers: Driving Vision AI Innovation at the Extreme Edge,...
“From Enterprise to Makers: Driving Vision AI Innovation at the Extreme Edge,...
Edge AI and Vision Alliance
 
vertical-cnc-processing-centers-drillteq-v-200-en.pdf
vertical-cnc-processing-centers-drillteq-v-200-en.pdf
AmirStern2
 
Artificial Intelligence in the Nonprofit Boardroom.pdf
Artificial Intelligence in the Nonprofit Boardroom.pdf
OnBoard
 
Raman Bhaumik - Passionate Tech Enthusiast
Raman Bhaumik - Passionate Tech Enthusiast
Raman Bhaumik
 
The State of Web3 Industry- Industry Report
The State of Web3 Industry- Industry Report
Liveplex
 
Ad

PowerShell Runspaces