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
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
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 :
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.
Apache Modules :
Changelog for v0.92 :
If you have any comments, bug reports, feature request, etc, post it right here.
Bw Mod v0.8 [Readme]
Bw Mod v0.7 [Readme]
Bw_Mod v0.6 Still available, and with its README here.
Bw_Mod v0.5 Stable is obsoleted, and should not be used, unless you want to play with it.
Bw_Mod v0.5 RC1 is obsoleted, and should not be used, unless you want to play with it.
Mod_bandwidth v0.1 is obsoleted, and should not be used.
Restrict the number of simultaneous connections per vhost
If ExtendedStatus is Off, it wont work. Anyways, you’ll be warned
I was based on mod_vhost_limit from Takato Satsuma [email@example.com]
who wrote it for Apache1.3. Download it here
If you run into problems, be sure ExtendedStatus is set On before the
LoadModule sentence.Also note, that the MaxVhostClients must be after
the ServerName directive.