4

I am on CentOS 6.4 and am using Plesk v11.5.30 although this doesn't necessarily need to be done via plesk.

I am looking to limit the connection speed to a specific website. However the only options Plesk gives me are "Maximum bandwidth usage" and "limit connections".

Maximum bandwidth usage is the total bandwidth used by a domain while connections is the number of connections (obviously). What I want to do is limit the speed to 200kb/s irrespective of how many people are accessing the domain. Even if only one person is accessing, I don't want them to be able to use all the bandwidth, I want them to be limited to 200kb/s

Is there a way for me to limit all individual connections to just 200kb/s so that no one can ever use over 200kb/s, but of course if traffic is high they may use less than 200kb/s?

To avoid this being plesk specific, this is what is in my conf and I'm happy to modify it manually if there is some other parameter I can use:

<IfModule mod_bw.c>
    BandwidthModule On
    ForceBandWidthModule On
    Bandwidth all "0"
    MaxConnection all "0"
    BandWidthError 510
</IfModule>

2 Answers 2

4

I've never used this module but the documentation seems fairly straight forward.

The directives are valid inside a <VirtualHost> block and will only apply to that virtual host if so. It also looks like they don't inherit from higher parts of the config so you should put every relevant directive in the virtual host.

Your current config sets the bandwidth limit to "0" which means no limit. You want 200KB (I presume you meant kilobytes and not kilobits).

Put this in the virtual host you want to limit:

BandwidthModule On
ForceBandWidthModule On
Bandwidth all 204800

The default MinBandwidth is 256 bytes/s so you can handle 800 simultaneous users before any of them will start getting error messages. If you think 256 bytes/s is a bit low, you can also add MinBandwidth all 1024 which will mean that when you have more than 200 simultaneous requests the 201st will get an error message instead of the page they requested and all of the 200 before that will be guaranteed at least 1KB/s.

I don't usually bother with those <IfModule> blocks because all they do is hide your mistakes and make you think mod_bw is working when it hasn't even loaded.

2

I figured this out using LargeFileLimit:

<IfModule mod_bw.c>
BandwidthModule On
ForceBandWidthModule On
Bandwidth all "52428800"
MaxConnection all "400"
LargeFileLimit * 1024 204800
BandWidthError 510
</IfModule>

This will mean that the domain is limited to 50mb bandwidth (52428800), that it can only have 400 connections at once and that any files over 1mb will be limited to 200kb/s (204800).

For anyone reading this later you can also put an extension instead of * to limit just zips,rars,avis or whatever.

1
  • Hi, can you tell me where you found the file to put that config in? Thanks
    – FMC
    May 8, 2015 at 1:32

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .