3

Update: I'm looking for an automated "95th percentile bandwidth limiter". I was originally hoping for something part of the traffic shaping code in the kernel but I think it doesn't exist. I'm aware that I can manually limit at 3Mbps and be safe, but that would be wasting a lot of bandwidth that I could be using.

Original:

Let's assume I have a set of co-located servers and I pay for 3Mbps at 95th percentile. I would like to use as much of that as possible without incurring overage charges. Without any throttling, the servers would generate 10Mbps of traffic, leading to overage charges. What I'm asking is for something that would not throttle at all for 5% of the time becuase the 95th percentile billing rules will throw those out, while keeping me under the 3Mbps the rest of the time.

kbyrd
  • 3,604
  • 2
  • 23
  • 34
  • I don't think that you're wasting "a lot" of bandwidth by not using that 5% overage. However, if you want, you could write a cron job that turns off traffic caps for the last so many hours of the month, or the first so many, or whateer. – Bill Weiss Aug 24 '09 at 21:04
  • s/whateer/whatever – Bill Weiss Aug 24 '09 at 21:05
  • Sure I am! If I pay for 3Mps at 95th, and I've got a 100Mpbs line, that's 1.5 days at 100Mbps full blast. That will serve a lot of people quickly. – kbyrd Sep 02 '09 at 22:51

3 Answers3

6

If you're using linux, check out the Linux Advanced Routing and Traffic Control HOWTO for an introduction on how to use tc and other tools to perform traffic shaping and qos on your link.

There are management systems for tc which abstract away some of the pain, such as MasterShaper and WonderShaper. I've not used either of those, and wondershaper appears to be very poorly maintained, but you might get some use out of them.

Or you can use a bundled firewall/management system like pfsense, m0n0wall, etc.

For a simple task like setting a single cap on traffic, I'd just write a tc script using the LARTC howto though.

And finally, if you want to monitor your link usage to keep a visual and historical record of your utilisation (and your 95th percentile mark), use a tool like cacti or munin to visualise it.

Daniel Lawson
  • 5,426
  • 21
  • 27
  • 1
    I'll edit the question in second to be more clear. I know how to do basic throttling with tc. The problem is the 95th percentile part. I want to have tc (or whatever) dynamically throttle and use everything I am allowed under the 95th percentile rules. – kbyrd May 31 '09 at 23:13
  • 2
    So use a cron job to turn off TC for one hour a day during your busiest traffic period. That will get you close to the 95% with a bit of leeway for stuff ups. – Haakon May 31 '09 at 23:39
  • I'm specifically asking for something more automated. The routing machine has all the information it needs. – kbyrd Jun 01 '09 at 01:05
  • I'll just accept this answer. It's useful even thought I didn't get exactly what I was looking for. I expect the thing I want doesn't exist. – kbyrd Mar 29 '10 at 16:05
0

95th percentile works roughly like this:

  • Count bytes transferred every 5 minutes (see byte counters in ifconfig)
  • Make a list of all 5-minute buckets and sort them by size (*/5 in cron)
  • Throw out the top 5%
  • The highest remaining value is your 95% value. (Remember to convert Mbytes/sec to Mbits/sec!)
  • Reset the counters on your carrier's billing interval and check with their NOC to see when that should be. Also find out if TX and RX are counted together, separate, or if only one (or the other) matters for billing.
  • Compare your numbers to your carrier's numbers and make sure they jive.

You could then write a script for 95th percentile that checks the current 95th percentile and then throttle/police your traffic with 'tc' accordingly.

As time goes on, you will get more samples, so if you go over the target 95% mark then you might still have "time" for those high valued samples to fall off if you throttle. For safety you might shoot for an 80% target and play with the numbers until it behaves the way that you want.

Since it is burstable you can start each month without a limit, and then crank up the limit as time goes on because the highest 5% of the traffic isn't included in the calculation.

This article has more:

KJ7LNW
  • 131
  • 3
0

Many routers have the ability to throttle bandwidth to within a Mb/s or so (lots are within a few kb/s, but I like to be cautious) of accuracy. The actual configuration of your router depends a great deal on what router you're using. If you set the throttle at 14Mb/s, you shouldn't have any problems.

As for keeping the pipe filled...well...that part is up to you!

Matt Simmons
  • 20,218
  • 10
  • 67
  • 114