" class="title" title="home again woohoo">Home ?> pages bg right
Posted by Bruce on May 27, 2010


Two fixes..For the price of one :)

Wow.. Didnt hope to release fixes so soon.
Yesterday, Jacky Yuen contacted me about a bug in the mod. It didn’t look like
the mod’s fault, but i took a deeper look.

The issue :

On his windows server (win2003, and XP) the mod was working, but was unable to
reach high speeds (1MB/s). (i heard something like this before, and all you need is
to change the packet size).
However, doing this, didn’t fix the issue. I tried this on my server, and i was
able to get about 500KB/s. Setting the packet size to 16384 gave me 1MB/s.
Jacky told me he still had problems, so i tried all windows systems i got around.

A windows 2003 server,
and a Windows 7 (32bits) showed the problem (max speed was 490KB/s)
A Windows 7 64bits and Win 2003 SP2 didnt.

The most awesome part, is that if you run Google Chrome, a Flash application, or
Windows Media Player, the mod is able to deliver up to 1MB/s.

Took me a while, but i found that Windows doesnt run a high resolution timer
all the time. In the servers with the issue, the timer run every 10 ms.
Whenever you run some of the mentioned apps, they set the timer to the highest
speed possible (in my equipment, 1 ms). This setting affects all other
applications, so the mod was able to sleep small times to deliver data as it
needed.
So, i wrote 2 fixes. The first one, i didnt wanted to, but i made the mod to
set the timer to the highest resolution possible (it is written to the logs if
you want to peek). And the second, is to avoid waiting small times to send
data. Minimum time to sleep is 200ms now, and data is adjusted for this. (only
for windows). Both fixes are under defines that will compile just for windows,
so linux users won’t notice any changes.
The good thing, for windows users, is that with this fixes, i’ve been able
to get speeds up to 2.45MB/s under windows!. Using apache by itself, i just
got 1.2MB/s. Just enabling the mod and setting a high limit, the speed got
pumped up.

That’s it. Now i’ll be back working on the next release.

– (previous readme.txt text follows dated 24/May/2010)

Again… It has been a while since i’ve upted the code. (work, personal
life, money issues, the same stuff we all fight daily)
However, that doesn’t mean i forgot about it. I’ve just been working my
*** off. I’ve got many emails with suggestions, some bugs, etc..
I’m doing one of the last updates of this line of mod_bw (0.x). It’s
mainly a couple of bugfix, and a little callback to get stats on the running
mod. I hope it wont break anything.. (of course i’ve tested it a lot).

Ah!, i said this is one of the last updates. Yes. This is because this line
of code is limiting the possibilities of the mod, so i’ve started a new mod_bw
using other set of techniques. (so, it is highly experimental, and uses
completely new instructions). This new branch of the mod was born thanks to
the email sent by Borislav Borislavov (icn.bg), who needed some special features
to be implemented, not possible with the current code.
So, if you wanted the mod to do per-ip limiting, traffic limiting, etc..
keep checking my site. I’ll be releasing a new branch of mod_bw to public soon.
(Unfortunately, it won’t be released under the Apache license yet).

Now, back to this mod :

First, i’ve fixed two annoying bugs.
– MinBandWidth -1 was screwing things up sometimes. All because i was using
an unsigned integer to store the -1. Yeah, my bad.
– The limiting handler was leaking memory. A few bytes at a time, but for
large files (really, really large) this could mean one of the apache childs
consuming almost all memory. Thanks to Christian Spielberger who insisted
and helped me to find this. (i was sure there was something.. but my servers
recycle apache childs pretty often). Fun Fact : I found the bug, was cleaning
my test code, and he sent me an email with the exact same solution i came up.
Great minds think alike, eh ? :)

Then, i made a status callback for the mod. This callback will show some
stats on the running mod, for each memory segment used to limit bandwidth.
Is it a simple stat. However, i received many emails asking for this.

This is easy to achieve :

In your admin vhost (if you have one.. If not, any vhost you want to check),
use a location to set a handler for the callback.

Suppose the vhost for 127.0.0.1 :

  
    SetHandler modbw-handler
  

Now you can get information of the mod by visiting http://127.0.0.1/modbw
You can get the same information in csv format at http://127.0.0.1/modbw?csv

Please, test this changes, let me know how it works.
If you have some ideas (i.e. information to add in the stats), email me. If
it can or can’t be done in this branch of the mod, i’ll let you know.

Post a Comment


24 Responses to “Two fixes..For the price of one :)”

  1. Bruce says:

    Yes. A new version of the module.
    For the current version, only bug fixes.

  2. Du Keqin says:

    Windows 2008 x64 or Windows 7 Professional x64
    Apache 2.2.17
    mod_bw 0.92

    When parameter EnableMMAP was set to Off, max speed was 40KB/s. When it was set to On, mod_bw will works well.

  3. Bruce says:

    That’s normal.
    MMAP allows apache to use fast file access routines. If you dont enable it, file access could be slower on some platforms. (but can improve stability).
    mod_bw only limits the speed of the data apache is sending to the client. So if MMAP affects apache, it will affect mod_bw.

  4. david Wang says:

    Hi,

    I I have installed apache 1.3 on Window Server 2008 R2 64bit, now I want to use this mod_bw module to realize net restriction, such as download speed. Please give me some advice.

    Thank you.

  5. Bruce says:

    Hi,
    If you are using Apache 1.3, i cannot help you. You’ll have to look around to find the original Bandwidth Mod for 1.3.

  6. david Wang says:

    Hi,

    I have searched long time on the net, but fail to find “mod_bw.dll” running on Apache1.3, could any one help me? My email address is wangguancheng@parim.net.
    Thanks a lot.

    David

  7. RusTus says:

    Hello, I have been using this, on windows and have noticed that I cannot get the max speed to go over 40kbs. Anything lower it works, anything higher it throttles down to 40kbs. I have tried on different versions of apache all with same results, have tried every config known to man. It simply will not go over 40kbs. Is this a limit in windows?

    In the apache log it says allocating 40kb for mem, and seems a strange coincidence that is the DL limit as well. Any help would be great.

  8. Bruce says:

    The 40kb is just a coincidence (strange tho).
    Which version of the mod are you using ? which version of windows (and 32 or 64?) and apache (and 32 or 64?) ?

  9. RusTus says:

    AHHHHHH

    From Du Keqin above!

    When parameter EnableMMAP was set to Off, max speed was 40KB/s. When it was set to On, mod_bw will works well.

    Kicking myself that I didn’t see this.

    All working now :) ))

  10. Bruce says:

    Its good you told me :)
    I was going to start installing a virtualized environment to match your system and test..

    That MMAP always screws with speed.

Leave a Reply