IIS Home @ it-notebook.org

Shared Hosting: Limit data transfer and bandwidth for each website

(Kristofer Gafvert, May 29, 2005)

Introduction

Bandwidth costs. So in a shared hosting environment, you want to assure that no customer is using more bandwidth than you have calculated for. You also want to assure that one customer's bandwidth usages is not impacting other customers.IIS 6.0 is capable of hosting multiple websites on one server. This is done by separating the websites with unique combinations of host header name, IP number and port. This article will explain the different ways of hosting multiple websites using IIS, and will guide you thru setting IIS 6.0 up to host multiple websites using the host header approach.

Difference between Data Transfer and Bandwidth

Data transfer and bandwidth are often used synonymously, but they are in fact not the same. They are however somewhat related to each other. Bandwidth is the amount of data that can be transferred in a fixed amount of time (usually second), often measured in Mbps. Data transfer is usually defined as the amount of data actually transferred, often measured in MB. A website transferring 5000 MB of data each month may have smaller bandwidth usage than a website transferring 1000 MB of data each month (but all data is transferred the same day, and the website is idle the rest of the month).

Should I use a bandwidth limit, or a data transfer limit for each website?

The answer to this question depends on the situation. Bandwidth throttling has the disadvantage that it can deny a visitor access, although the webserver has plenty of bandwidth left (one website has a peak, while all other websites are idle). Limiting the data transfer on the other hand has the disadvantage that a website can use all bandwidth during a peak time, making other websites to be slow to access.

The risk of having one website consuming all bandwidth is however small (and can be detected if you monitor the webserver), and the overall customer experience is usually improved if you do not limit the bandwidth, but instead limit the amount of data transferred (and charge for the amount of data that is transferred above this limit).

Configure a bandwidth limit for each website (bandwidth throttling)

IIS Manager can be used to configure bandwidth throttling for individual websites. Follow these steps to configure bandwidth throttling:

  • Open IIS Manager
  • Expand the local computer, expand the "Web Sites" folder, right click the web site and click Properties.
  • Click the Performance tab, and in the "Bandwidth Throttling" section, select the "Limit the network bandwidth available to this Web site" check box.
  • In the "Maximum bandwidth (in kilobytes per second)" box, type the maximum number (at least 1024 Kbps) of kilobytes per second you want this web site to use.
  • Click Apply, click OK

Packet Scheduler will be installed unless it is not already installed

Limit data transfer for each website

IIS does not have any native way to limit the amount of data transferred each month (I will use month as an example, the time period can of course be another), so a third-party component is necessary. There are basically two ways to do this, live (with or without reading the log file), or at the end of each month. Weather you need to monitor this live, or not, depends on the situation. But keep in mind that everything that is running on the server is consuming valuable resources (CPU power and memory). So if you do not need to, do not monitor the amount of data transferred live.

There are already many products (free or commercial) that can show (and limit) the data transferred for a configurable amount of time. For example waeIISbm[1] (live, does not rely on the log files) from wae Technologies, LiveBandWidth[2] (live, uses the IIS log files) from LiveDns Ltd., Bandwidth Monitor[3] by ASPwebSoft, and of course, all decent log file analyzers can show the amount of data transferred for a specified amount of time.

Developing your own application to limit the amount of data that can be transferred per website is not difficult. All you actually need to do is read the log file (easiest, but other ways exists), and stop each website that has exceeded its allowed transfer limit. Reading the log files is easily done using the Log Parser Tool[4] from Microsoft. Stopping a website can be done using ADSI or WMI[5,6,7]. Also make sure you check out the Log Parser Repository[8], it contains a piece of code determining the total amount of traffic over a time period, using C# and the COM object.

Applies to [?]

IIS 6.0

Resources

[1] waeIISbm
[2] LiveBandWidth
[3] Bandwidth Monitor
[4] Log Parser
[5] IIsWebServer.Stop (ADSI)
[6] IIsWebServer.Stop (WMI)
[7] IIS Script Center - Stop a Web Server
[8] Log Parser Repository
Enabling Bandwidth Throttling (IIS 6.0)
Disabling Bandwidth Throttling (IIS 6.0)
LogParser.com