I require a high performing script calling an in-house web service. So I wrote a powershell script to create runspace threads which each make a request to a common Web Service proxy object (New-WebServiceProxy).
I figured out that regardless of the number of threads I create and the number of web service application pool worker processes, I am only making 2 HTTP connections simultaneously from of the computer running the script and therefore only two processes are occurring within the web service. That's not giving me fast enough results.
By running my script on multiple client computers I can raise my worker processes up to 8 before I stress the web server. I need to get there in code with one powershell script.
I tried setting this registry key to 8:
That did seem like it possibly increased the performance of my script but I still only see 2 HTTP connections to the web service.
It seems like the real solution is to manage this .Net property:
Can someone explain to me how in the powershell I can deal with this? I can't figure out any connection between the object returned by New-WebServiceProxy and the ServicePoint class ? So what to set in Powershell to change that 2 connection limitation?
I think you just need to set the default connection limit to a larger value in your script, for example:
[System.Net.ServicePointManager]::DefaultConnectionLimit = 8
The connection between the
ServicePointManager and the generated class is that the generated class inherits from
SoapHttpClientProtocol which internally uses
System.Net.HttpWebRequest to make network calls. Internally,
ServicePointManager to control the number of simultaneous in-flight calls you can have going.