How does Apache limit concurrent connections and download speeds under Linux _linux

Source: Internet
Author: User

Mod_limitipconn, this is an unofficial module of Apache, based on the same source IP for concurrent connection control, Bw_mod, it can be based on the source IP bandwidth constraints, they are Apache Third-party modules.

1. Download:

wget http://dominia.org/djao/limit/mod_limitipconn-0.22.tar.gz

wget http://bwmod.sourceforge.net/files/mod_bw-0.7.tgz

2. Installation

#tar-ZXVF mod_limitipconn-0.22.tar.gz
#cd mod_limitipconn-0.22
#vi Makefile
Modified: APXS = "/usr/local/apache2/bin/apxs" # here is their Apache APXS path, loading module

Or

#/usr/local/apache2/bin/apxs-i-c-a mod_limitipconn.c to load modules
#make
#make Install

#tar-XVF mod_bw-0.7.tgz
#cd MOD_BW
#/usr/local/apache2/bin/apxs-i-c-a/home/kenami/mod_bw/mod_bw.c

Below use VI to open Apache configuration file httpd.conf

The following two lines were found:

LoadModule Limitipconn_module modules/mod_limitipconn.so


LoadModule Bw_module modules/mod_bw.so

3. Configure

<ifmodule mod_limitipconn.c>
<location /home/bo@jb51.net/attachments/month _*> #需要控制的路径
Maxconnperip 3 #限制的线程数
Noiplimit index.htm #对此文件不做限制
</Location>
</IfModule>

Under the virtual host configuration file, add:

Bandwidthmodule on
Forcebandwidthmodule on
Bandwidth all 10000 #限速10K
Minbandwidth ALL-1


Configuration parameters are described as follows:
A. Bandwidthmodule on| Off

Whether to turn on the MOD_BW bandwidth throttling feature.

B. bandwidth [from] [BYTES/S]

Sets the maximum bandwidth for the specified client, 0 means no Limit

Bandwidth u:[user-agent] [BYTES/S]

C. minbandwidth [from] [BYTES/S]

Sets the minimum value for the specified client bandwidth, 0 for each client bandwidth maximum of 256bytes/s, and 1 for the maximum bandwith value

D. largefilelimit [Type] [Minimum Size] [bytes/s]

Sets the maximum bandwidth to access a file that exceeds a certain size, with a file type size of unit Kbytes

E. maxconnection [from] [Max]

Set the maximum number of concurrent connections for a specified client

F. Forcebandwidthmodule [on| OFF]

The default BW module will apply all requests, on to set the filter type

About from, that is, the client source can be divided into the following situations:

IP Specifies a single host

192.168.1.22

Specify network Segment

192.168.1.0/24 or

192.168.1.0/255.255.255.0

Domain Name Single host

Client1.jb51.net

Domain name specified range

. jb51.net

All clients

All

The above configuration can be configured for all clients as well as for a virtual host

Example one:

Bandwidthmodule on

Bandwidth All 307200

Bandwidth 192.168.1.2 102400

Bandwidth "U:^MOZILLA/5 (. *)" 102400

Bandwidth "U:wget" 204800

Forcebandwidthmodule on

Largefilelimit. avi 600 204800

Maxconnection all 100

Maxconnnection 192.168.1.2 5

The above configuration meaning:

Open MOD_BW, restrict all file types also open

All clients have a maximum bandwidth of 300k and a maximum concurrent connection of 100

The maximum bandwidth of the 192.168.1.2 is 100k and the maximum concurrent connection is 5

100k client Maximum bandwidth using Firefox

Maximum bandwidth for clients using wget is 200k

Maximum bandwidth for files exceeding 600k in AVI format is 200kbyte/s

Example two:

<virtualhost *>

Bandwidthmodule on

Forcebandwidthmodule on

Largefilelimit. avi 1 20000

Largefilelimit mpg 1 20000

Servername www.jb51.net

</Virtualhost>

This instance restricts the virtual host, specifying the file type AVI and the MPG maximum bandwidth of 20k,forcebandwidthmodule on must have.

Example three:

<virtualhost *>

Bandwidthmodule on

Addoutputfilterbytype MOD_BW text/html Text/plain

Bandwidth All 5000

Servername www.jb51.net

</Virtualhost>

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.