Bug Vanquisher

1 July 2007

The background/foreground in Background Intelligent Transfer Service foreground priority jobs

Filed under: Rant vs Vent — Tanveer Badar @ 11:36 AM

There was no pun, honestly. BITS in Windows XP (built-in, installable on Windows 2000, and available in every Windows version onwards) allows anyone to download files from a HTTP server, or upload files to an IIS hosted HTTP server which has been sufficiently configured. BITS offers various job priorities like foreground, high, normal and background (default) which directly correspond to how these jobs compete for their share in network traffic with other foreground processes accessing sockets.

The controversy lies with the foreground priority. Foreground priority is really foreground globally, it competes with network traffic from all other programs, robbing them of their share. For these jobs, BITS acts as a foreground download program which will steal all bandwidth available on the machine. The usual throttling of bandwidth usage as is the case with other priorities does not happen. Any other program will starve, browsers will display timeout errors all the time. MSDN incorrectly says that BITS will try to use only that portion of bandwidth which it determines would have been wasted otherwise.

“Background transfers are optimal in that BITS uses idle network bandwidth to transfer the files and will increase or decrease the rate at which files are transferred based on the amount of idle network bandwidth available. If a network application begins to consume more bandwidth, BITS decreases its transfer rate to preserve the user’s interactive experience.”

Not the case with foreground priority, it uses all available bandwidth leaving nothing for others. Whenever Windows Update in WIndows Vista is downloading updates, you can sit back and watch hopelessly how it steal your right to browse the web with its hungry foreground jobs. Now it seems that microsoft has modified Windows Update client for Windows XP and the default priority for updates is also foreground which was previously high.

Background priority is really the reverse, the one no one in their right minds should ever use. It pauses the download every 10 seconds and downloads about 10 KB in one go. Therefore, if it is the sole process accessing network on a computer, you will be amazed how little progress is made over any period of time. MSDN again incorrectly says that BITS will use any remaining bandwidth which should be all in this case, but the real situation is not what is written.

BG_JOB_PRIORITY_LOW
Transfers the job in the background with a low priority. Background transfers use idle network bandwidth of the client to transfer files. This is the lowest background priority level.

However, this is not at all the case in reality. Background jobs go to hibernation repeatedly, only awakening long enough to grab 10 KB every so much seconds.

[Update 07/07/07 (again, no pun): With BITS 2.5 installed on my Windows XP system, foreground priority jobs seems to be a lot more docile. They don’t steal that much bandwidth from other programs as they used to be. I will never let any job run with background priority as long as I can do 2+2, therefore, it will be very hard to notice the difference in that case.]

Advertisements

4 Comments »

  1. Hi,
    Could you please tell me how did you measure the bandwidth used by BITS and the total available bandwidth?
    I am to trying to do the same tests with BITS 3.0

    Thanks,
    ed

    Comment by cccedi — 2 April 2009 @ 2:25 PM

  2. I don’t think there are any public APIs which give you that particular piece of information. Nevertheless, looking into http://msdn.microsoft.com/en-us/library/aa363034%28VS.85%29.aspx may help.

    The approach here will be passive, just like running bitsadmin /monitor from command line. You will need to call IBackgroundCopyJob::GetProgress repeatedly.

    Comment by Tanveer Badar — 2 April 2009 @ 7:19 PM

  3. Hi,
    Thanks for the reply.
    Could you please tell which tool did you use to check that BITS pauses every 10s and then downloads 10 KB?

    Thanks,
    ed

    Comment by cccedi — 3 April 2009 @ 1:15 PM

  4. bitsadmin /monitor

    :)

    You can specify refresh time too if you want. Programmatically, it will be function I described earlier.

    Comment by Tanveer Badar — 4 April 2009 @ 10:14 PM


RSS feed for comments on this post. TrackBack URI

Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Create a free website or blog at WordPress.com.

%d bloggers like this: