Nginx Apache load Balancing test

Source: Internet
Author: User

Apache Configuration

(Monitor intranet IP and port)

Listen 10.163.170.8:8001Listen10.163.170.8:8002Listen10.163.170.8:8003<virtualhost *:8001> documentroot/website/111. com ServerName localhost:8001directoryindex index.html index.php errorlog logs/111. Com-error_log Customlog logs/111. Com-access_log Common</virtualhost><virtualhost *:8002> documentroot/website/222. com ServerName localhost:8002directoryindex index.html index.php errorlog logs/222. Com-error_log Customlog logs/222. Com-access_log Common</virtualhost><virtualhost *:8003> documentroot/website/333. com ServerName localhost:8003directoryindex index.html index.php errorlog logs/333. Com-error_log Customlog logs/333. Com-access_log common</virtualhost>

Nginx Configuration

http {include/etc/nginx/mime.types;Default_type Application/octet-stream;Log_format main ' $remote _addr-$remote _user[$time _local]"$request""$status $body _bytes_sent"$http _referer""'"$http _user_agent" "$http _x_forwarded_for" ';Access_log/var/log/nginx/access.log Main;Sendfile on;#tcp_nopush on;#keepalive_timeout0;Keepalive_timeout 65;#gzip on;# Load config files from the/etc/nginx/conf.d directory # The default server was in conf.d/default.conf # include/etc/nginx/conf.d/*.conf ;        Upstream webservers {server 10.163.170.8:8001 weight=1;        Server 10.163.170.8:8002 weight=2;    Server 10.163.170.8:8003 weight=3;        } server {Listen 80;        server_name localhost;            Location/{Proxy_pass http://webservers; Proxy_set_header x-real-ip $remote _addr;        }    }}

PHP test

(nginx_upstream_test.php)

<?PHP$url= ' http://114.215.107.17/';$count= 100;$webservers=Array(); for($i= 1;$i<=$count;$i++){    Echo($i." \ n "); $data= Test ($url); $webservers[$data]++;}Var_dump($webservers);functionTest$url){    $data=file_get_contents($url); return Trim($data);}?>

Test Results 1

Array (3) {  [222]=>  int (over)  [ 333 ]=>  int ($)  [111]=>  Int ()}

Test Results 2

Array (3) {  [333]=>  int (Wuyi)  [  222]=>  int (+)  [111]= >  int (+)}

Nginx Apache load Balancing test

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.