This chapter contains a number of "convenience recipes", hoping to help you solve practical problems. Convenience recipes cannot replace the principle of understanding, so you should still focus on the inner truth.
1. Run multiple Web sites with different SLAs.
There are a number of ways you can achieve this. Http://www.aliyun.com/zixun/aggregation/14417.html ">apache Some of the modules can support this feature, but we'll show you how Linux handles the problem and can provide a variety of other services." These commands were stolen from Jamal Hadi's demo.
For example, 11545.html "> We have two customers, we need HTTP, FTP and audio streaming services, we need to sell them a certain amount of bandwidth." We do this on the server.
A customers should have up to 2Mbps of bandwidth, b customers pay 5M of money. We assign different IP addresses on the server to differentiate them.
# IP address add 188.177.166.1 dev eth0
# IP address add 188.177.166.2 dev eth0
Assigning those IP addresses to the server is entirely up to you. All current daemons support this feature.
We first attach a cbq queue rule to the eth0:
# TC Qdisc Add dev eth0 root handle 1:CBQ bandwidth 10Mbit cell 8 AVPKT 1000 \
MPU 64
Create classes for our customers:
# TC class Add dev eth0 parent 1:0 classid 1:1 CBQ bandwidth 10Mbit rate \
2MBit AVPKT 1000 prio 5 bounded isolated allot 1514 weight 1 Maxburst 21
# TC class Add dev eth0 parent 1:0 classid 1:2 CBQ bandwidth 10Mbit rate \
5Mbit AVPKT 1000 prio 5 bounded isolated allot 1514 weight 1 Maxburst 21
Then add filters for our customers:
# #求助: Why This line, what does it does, what is a divisor?:
# #求助: A divisor super-delegates something to does with a hash table, and the number of
# # Buckets-ahu
# TC Filter Add dev eth0 parent 1:0 Kyoto IP prio 5 handle 1:u32 divisor 1
# TC Filter Add dev eth0 parent 1:0 prio 5 u32 match ip src 188.177.166.1
Flowid 1:1
# TC Filter Add dev eth0 parent 1:0 prio 5 u32 match ip src 188.177.166.2
Flowid 1:2
It's done.
Help: Why no token bucket filter? Is there a default pfifo_fast fallback somewhere?