SlideShare a Scribd company logo
1 of 13
Download to read offline
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.

More Related Content

What's hot

ClojureScript: I can't believe this is JavaScript
ClojureScript: I can't believe this is JavaScriptClojureScript: I can't believe this is JavaScript
ClojureScript: I can't believe this is JavaScriptEric Normand
 
New Server in an Hour
New Server in an HourNew Server in an Hour
New Server in an HourMike 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)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 CoffeescriptIntroduction to Coffeescript
Introduction to CoffeescriptIndies Services
 
Performance - When, What and How
Performance - When, What and HowPerformance - When, What and How
Performance - When, What and HowAstrails
 
GETTING STARTED WITH JavaScript and ReactJS
GETTING STARTED WITH JavaScript and ReactJSGETTING STARTED WITH JavaScript and ReactJS
GETTING STARTED WITH JavaScript and ReactJSIftekher Islam Sunny
 
DevOps for Drupal: Why We Cook With Chef
DevOps for Drupal: Why We Cook With ChefDevOps for Drupal: Why We Cook With Chef
DevOps for Drupal: Why We Cook With ChefPromet Source
 
Coffee script final
Coffee script finalCoffee script final
Coffee script finalpriyankazope
 
Raven db byexample
Raven db byexampleRaven db byexample
Raven db byexampleEmil Cardell
 
Zeev Suraski "The PHP 7 Story, and beyond"
Zeev Suraski "The PHP 7 Story, and beyond"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 ScalesNo More Cowboy Coding: Modern WordPress Development Workflow That Scales
No More Cowboy Coding: Modern WordPress Development Workflow That ScalesTom Howard
 
Coding for the cloud - development of modern web applications
Coding for the cloud - development of modern web applicationsCoding for the cloud - development of modern web applications
Coding for the cloud - development of modern web applicationsWekoslav Stefanovski
 
It Sounded Good on Paper - Lessons Learned with Puppet
It Sounded Good on Paper - Lessons Learned with PuppetIt Sounded Good on Paper - Lessons Learned with Puppet
It Sounded Good on Paper - Lessons Learned with PuppetJeffery Smith
 
Db migration automation
Db migration automationDb migration automation
Db migration automationThomas Queste
 
Supporting large scale React applications
Supporting large scale React applicationsSupporting large scale React applications
Supporting large scale React applicationsMaurice De Beijer [MVP]
 
Building large scalable mission critical business applications on the web
Building large scalable mission critical business applications on the webBuilding large scalable mission critical business applications on the web
Building large scalable mission critical business applications on the webMaurice De Beijer [MVP]
 
Getting started with dev tools (atl)
Getting started with dev tools (atl)Getting started with dev tools (atl)
Getting started with dev tools (atl)Thinkful
 

What's hot (20)

ClojureScript: I can't believe this is JavaScript
ClojureScript: I can't believe this is JavaScriptClojureScript: I can't believe this is JavaScript
ClojureScript: I can't believe this is JavaScript
 
Why puppet? Why now?
Why puppet? Why now?Why puppet? Why now?
Why puppet? Why now?
 
New Server in an Hour
New Server in an HourNew Server in an Hour
New Server in an Hour
 
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)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)
 
Introduction to Coffeescript
Introduction to CoffeescriptIntroduction to Coffeescript
Introduction to Coffeescript
 
Kanban @ nine.ch
Kanban @ nine.chKanban @ nine.ch
Kanban @ nine.ch
 
Performance - When, What and How
Performance - When, What and HowPerformance - When, What and How
Performance - When, What and How
 
GETTING STARTED WITH JavaScript and ReactJS
GETTING STARTED WITH JavaScript and ReactJSGETTING STARTED WITH JavaScript and ReactJS
GETTING STARTED WITH JavaScript and ReactJS
 
DevOps for Drupal: Why We Cook With Chef
DevOps for Drupal: Why We Cook With ChefDevOps for Drupal: Why We Cook With Chef
DevOps for Drupal: Why We Cook With Chef
 
Coffee script final
Coffee script finalCoffee script final
Coffee script final
 
Raven db byexample
Raven db byexampleRaven db byexample
Raven db byexample
 
Zeev Suraski "The PHP 7 Story, and beyond"
Zeev Suraski "The PHP 7 Story, and beyond"Zeev Suraski "The PHP 7 Story, and beyond"
Zeev Suraski "The PHP 7 Story, and beyond"
 
No More Cowboy Coding: Modern WordPress Development Workflow That Scales
No More Cowboy Coding: Modern WordPress Development Workflow That ScalesNo More Cowboy Coding: Modern WordPress Development Workflow That Scales
No More Cowboy Coding: Modern WordPress Development Workflow That Scales
 
Coding for the cloud - development of modern web applications
Coding for the cloud - development of modern web applicationsCoding for the cloud - development of modern web applications
Coding for the cloud - development of modern web applications
 
It Sounded Good on Paper - Lessons Learned with Puppet
It Sounded Good on Paper - Lessons Learned with PuppetIt Sounded Good on Paper - Lessons Learned with Puppet
It Sounded Good on Paper - Lessons Learned with Puppet
 
Db migration automation
Db migration automationDb migration automation
Db migration automation
 
Developer Week
Developer WeekDeveloper Week
Developer Week
 
Supporting large scale React applications
Supporting large scale React applicationsSupporting large scale React applications
Supporting large scale React applications
 
Building large scalable mission critical business applications on the web
Building large scalable mission critical business applications on the webBuilding large scalable mission critical business applications on the web
Building large scalable mission critical business applications on the web
 
Getting started with dev tools (atl)
Getting started with dev tools (atl)Getting started with dev tools (atl)
Getting started with dev tools (atl)
 

Similar to PowerShell Runspaces

I6 - State of the art SharePoint PowerShell Nation 2017 - Spencer Harbar
I6 - State of the art SharePoint PowerShell Nation 2017 - Spencer HarbarI6 - State of the art SharePoint PowerShell Nation 2017 - Spencer Harbar
I6 - State of the art SharePoint PowerShell Nation 2017 - Spencer HarbarSPS 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"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 gamesErlang, the big switch in social games
Erlang, the big switch in social gamesWooga
 
How to get started with Site Reliability Engineering
How to get started with Site Reliability EngineeringHow to get started with Site Reliability Engineering
How to get started with Site Reliability EngineeringAndrew Kirkpatrick
 
Devops in with the old, in with the new
Devops   in with the old, in with the newDevops   in with the old, in with the new
Devops in with the old, in with the newJan Collijs
 
Learn from my Mistakes - Building Better Solutions in SPFx
Learn from my  Mistakes - Building Better Solutions in SPFxLearn from my  Mistakes - Building Better Solutions in SPFx
Learn from my Mistakes - Building Better Solutions in SPFxThomas Daly
 
Bringing Open-Source Practices to Your Day Job
Bringing Open-Source Practices to Your Day JobBringing Open-Source Practices to Your Day Job
Bringing Open-Source Practices to Your Day JobBen Coe
 
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
 
CI_CONF 2012: Scaling
CI_CONF 2012: ScalingCI_CONF 2012: Scaling
CI_CONF 2012: ScalingChris Miller
 
HyperDB, MySQL Performance, & Flavors of MySQL
HyperDB, MySQL Performance, & Flavors of MySQLHyperDB, MySQL Performance, & Flavors of MySQL
HyperDB, MySQL Performance, & Flavors of MySQLEvan Volgas
 
Untangling spring week11
Untangling spring week11Untangling spring week11
Untangling spring week11Derek Jacoby
 
The Characteristics of a Successful SPA
The Characteristics of a Successful SPAThe Characteristics of a Successful SPA
The Characteristics of a Successful SPAGil Fink
 
PostgreSQL worst practices, version FOSDEM PGDay 2017 by Ilya Kosmodemiansky
PostgreSQL worst practices, version FOSDEM PGDay 2017 by Ilya KosmodemianskyPostgreSQL worst practices, version FOSDEM PGDay 2017 by Ilya Kosmodemiansky
PostgreSQL worst practices, version FOSDEM PGDay 2017 by Ilya KosmodemianskyPostgreSQL-Consulting
 
Profiling and Tuning a Web Application - The Dirty Details
Profiling and Tuning a Web Application - The Dirty DetailsProfiling and Tuning a Web Application - The Dirty Details
Profiling and Tuning a Web Application - The Dirty DetailsAchievers Tech
 
Untangling spring week1
Untangling spring week1Untangling spring week1
Untangling spring week1Derek Jacoby
 
Apache Con 2008 Top 10 Mistakes
Apache Con 2008 Top 10 MistakesApache Con 2008 Top 10 Mistakes
Apache Con 2008 Top 10 MistakesJohn Coggeshall
 
Untangling - fall2017 - week 7
Untangling - fall2017 - week 7Untangling - fall2017 - week 7
Untangling - fall2017 - week 7Derek Jacoby
 
Neo4j Training Cypher
Neo4j Training CypherNeo4j Training Cypher
Neo4j Training CypherMax De Marzi
 

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 HarbarI6 - State of the art SharePoint PowerShell Nation 2017 - Spencer Harbar
I6 - State of the art SharePoint PowerShell Nation 2017 - Spencer Harbar
 
Erlang factory SF 2011 "Erlang and the big switch in social games"
Erlang factory SF 2011 "Erlang and the big switch in social games"Erlang factory SF 2011 "Erlang and the big switch in social games"
Erlang factory SF 2011 "Erlang and the big switch in social games"
 
Erlang, the big switch in social games
Erlang, the big switch in social gamesErlang, the big switch in social games
Erlang, the big switch in social games
 
How to get started with Site Reliability Engineering
How to get started with Site Reliability EngineeringHow to get started with Site Reliability Engineering
How to get started with Site Reliability Engineering
 
Devops in with the old, in with the new
Devops   in with the old, in with the newDevops   in with the old, in with the new
Devops in with the old, in with the new
 
Learn from my Mistakes - Building Better Solutions in SPFx
Learn from my  Mistakes - Building Better Solutions in SPFxLearn from my  Mistakes - Building Better Solutions in SPFx
Learn from my Mistakes - Building Better Solutions in SPFx
 
Bringing Open-Source Practices to Your Day Job
Bringing Open-Source Practices to Your Day JobBringing Open-Source Practices to Your Day Job
Bringing Open-Source Practices to Your Day Job
 
Why use Go for web development?
Why use Go for web development?Why use Go for web development?
Why use Go for web development?
 
CI_CONF 2012: Scaling - Chris Miller
CI_CONF 2012: Scaling - Chris MillerCI_CONF 2012: Scaling - Chris Miller
CI_CONF 2012: Scaling - Chris Miller
 
CI_CONF 2012: Scaling
CI_CONF 2012: ScalingCI_CONF 2012: Scaling
CI_CONF 2012: Scaling
 
HyperDB, MySQL Performance, & Flavors of MySQL
HyperDB, MySQL Performance, & Flavors of MySQLHyperDB, MySQL Performance, & Flavors of MySQL
HyperDB, MySQL Performance, & Flavors of MySQL
 
Untangling spring week11
Untangling spring week11Untangling spring week11
Untangling spring week11
 
The Characteristics of a Successful SPA
The Characteristics of a Successful SPAThe Characteristics of a Successful SPA
The Characteristics of a Successful SPA
 
PostgreSQL worst practices, version FOSDEM PGDay 2017 by Ilya Kosmodemiansky
PostgreSQL worst practices, version FOSDEM PGDay 2017 by Ilya KosmodemianskyPostgreSQL worst practices, version FOSDEM PGDay 2017 by Ilya Kosmodemiansky
PostgreSQL worst practices, version FOSDEM PGDay 2017 by Ilya Kosmodemiansky
 
Profiling and Tuning a Web Application - The Dirty Details
Profiling and Tuning a Web Application - The Dirty DetailsProfiling and Tuning a Web Application - The Dirty Details
Profiling and Tuning a Web Application - The Dirty Details
 
Software development fundamentals
Software development fundamentalsSoftware development fundamentals
Software development fundamentals
 
Untangling spring week1
Untangling spring week1Untangling spring week1
Untangling spring week1
 
Apache Con 2008 Top 10 Mistakes
Apache Con 2008 Top 10 MistakesApache Con 2008 Top 10 Mistakes
Apache Con 2008 Top 10 Mistakes
 
Untangling - fall2017 - week 7
Untangling - fall2017 - week 7Untangling - fall2017 - week 7
Untangling - fall2017 - week 7
 
Neo4j Training Cypher
Neo4j Training CypherNeo4j Training Cypher
Neo4j Training Cypher
 

Recently uploaded

New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024
New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024
New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024BookNet Canada
 
Maximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxMaximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxOnBoard
 
Scanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsScanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsRizwan Syed
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxMalak Abu Hammad
 
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...shyamraj55
 
Key Features Of Token Development (1).pptx
Key  Features Of Token  Development (1).pptxKey  Features Of Token  Development (1).pptx
Key Features Of Token Development (1).pptxLBM Solutions
 
Streamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupStreamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupFlorian Wilhelm
 
Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Scott Keck-Warren
 
Benefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other FrameworksBenefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other FrameworksSoftradix Technologies
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationRidwan Fadjar
 
APIForce Zurich 5 April Automation LPDG
APIForce Zurich 5 April  Automation LPDGAPIForce Zurich 5 April  Automation LPDG
APIForce Zurich 5 April Automation LPDGMarianaLemus7
 
Install Stable Diffusion in windows machine
Install Stable Diffusion in windows machineInstall Stable Diffusion in windows machine
Install Stable Diffusion in windows machinePadma Pradeep
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking MenDelhi Call girls
 
Transcript: New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024BookNet Canada
 
Unleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubUnleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubKalema Edgar
 
Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationSlibray Presentation
 
Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Mattias Andersson
 
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersEnhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersThousandEyes
 

Recently uploaded (20)

New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024
New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024
New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024
 
Maximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxMaximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptx
 
Scanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsScanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL Certs
 
DMCC Future of Trade Web3 - Special Edition
DMCC Future of Trade Web3 - Special EditionDMCC Future of Trade Web3 - Special Edition
DMCC Future of Trade Web3 - Special Edition
 
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptxE-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptx
 
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
 
Key Features Of Token Development (1).pptx
Key  Features Of Token  Development (1).pptxKey  Features Of Token  Development (1).pptx
Key Features Of Token Development (1).pptx
 
Streamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupStreamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project Setup
 
Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024
 
Benefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other FrameworksBenefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other Frameworks
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 Presentation
 
APIForce Zurich 5 April Automation LPDG
APIForce Zurich 5 April  Automation LPDGAPIForce Zurich 5 April  Automation LPDG
APIForce Zurich 5 April Automation LPDG
 
Install Stable Diffusion in windows machine
Install Stable Diffusion in windows machineInstall Stable Diffusion in windows machine
Install Stable Diffusion in windows machine
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
 
Transcript: New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024
 
Unleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubUnleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding Club
 
Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck Presentation
 
Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?
 
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersEnhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
 

PowerShell Runspaces

  • 1. Multithreading in PowerShell with runspaces 1/18/2017 Drew Furgiuele Senior DBA, IGS Energy
  • 2. 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.
  • 3. AGENDA 1/18/2017 3 1. Multithreading in PowerShell: Why? 2. How it works 3. Differences between runspaces and Invoke-Job 4. Examples!
  • 4. 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
  • 5. 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
  • 6. 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
  • 7. “… 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
  • 9. 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
  • 10. 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
  • 11. Practical Example • Master Data Management 1/18/2017 11
  • 12. 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
  • 13. 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.