Programmatically Throttling IIS

Ran across an issue where I needed to throttle WSUS bandwidth coming back to a server.  While WUS uses BITS, each machine knows of it’s network availability and utilization but has no knowledge of the network congestion to the server.  So, throttling IIS allows us to keep update traffic low and allows other traffic in and out of the site.  Here’s some VBScript

'Connect to local default website
Set IISConn = GetObject("IIS://localhost/W3SVC/1")
'Define kilobits for easier number manipulation
kBits = 1024

'Define the maximum bandwidth when throttled
minBandwidth = 10240 * kBits
minConnections = 300

'Define the unthrottled bandwidth value
maxBandwidth = -1
maxConnections = -1

'WScript.Echo IISConn.MaxBandwidth
'WScript.Echo IISConn.MaxConnections

'Detect current bandwidth setting and change appropriately
If IISConn.MaxBandwidth = minBandwidth Then
IISConn.Put "MaxBandwidth", maxBandwith
IISConn.Put "MaxBandwidth", minBandwidth
End If

'Write the value to the metadata

Two things of note…

1) Change the IISConn path to which ever service is running the website you want to throttle.

2) The values of the bandwidth entered to be multiplied should already be by 1024 (10 Mbps x 1024 = 10240 as listed above).

Thursday, April 8th, 2010 Code, Microsoft

Leave a Reply

Enter your email address to subscribe to this blog and receive notifications of new posts by email.

WordPress SEO fine-tune by Meta SEO Pack from Poradnik Webmastera