apache配置

(监听内网ip和端口)

Listen 10.163.170.8:8001
Listen 10.163.170.8:8002
Listen 10.163.170.8:8003 <VirtualHost *:8001>
DocumentRoot /website/111.com
ServerName localhost:8001
DirectoryIndex 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:8002
DirectoryIndex 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:8003
DirectoryIndex index.html index.php
ErrorLog logs/333.com-error_log
CustomLog logs/333.com-access_log common
</VirtualHost>

nginx配置

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_timeout 0;
keepalive_timeout 65; #gzip on; # Load config files from the /etc/nginx/conf.d directory
# The default server is 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测试

(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); function test($url){
$data = file_get_contents($url);
return trim($data);
}
?>

测试结果1

array(3) {
[]=>
int(34)
[]=>
int(49)
[]=>
int(17)
}

测试结果2

array(3) {
[]=>
int(51)
[]=>
int(33)
[]=>
int(16)
}

nginx apache负载均衡测试的更多相关文章

  1. nginx作为负载均衡服务器——测试

    i. 需求 nginx作为负载均衡服务器,用户请求先到达nginx,再由nginx根据负载配置将请求转发至 tomcat服务器. nginx负载均衡服务器:192.168.101.3 tomcat1服 ...

  2. Nginx网络架构实战学习笔记(三):nginx gzip压缩提升网站速度、expires缓存提升网站负载、反向代理实现nginx+apache动静分离、nginx实现负载均衡

    文章目录 nginx gzip压缩提升网站速度 expires缓存提升网站负载 反向代理实现nginx+apache动静分离 nginx实现负载均衡 nginx gzip压缩提升网站速度 网页内容的压 ...

  3. nginx+tomcat负载均衡

    最近练习nginx+tomcat负载均衡.根据一些资料整理了大体思路,最终实现了1个nginx+2个tomcat负载均衡. 安装JDK 1>进入安装目录,给所有用户添加可执行的权限 #chmod ...

  4. nginx做负载均衡配置文件

    nginx做负载均衡是在反向代理的基础上做的,代码如下: ## Basic reverse proxy server ## ## Apache backend for www.baidu.com ## ...

  5. linux+nginx+tomcat负载均衡,实现session同步

    linux+nginx+tomcat负载均衡,实现session同步 花了一个上午的时间研究nginx+tomcat的负载均衡测试,集群环境搭建比较顺利,但是session同步的问题折腾了几个小时才搞 ...

  6. 利用nginx实现负载均衡和动静分离

    1.Nginx介绍 Nginx ("engine x") 是一个高性能的 HTTP 和 反向代理 服务器,也是一个 IMAP/POP3/SMTP 代理服务器 . Nginx 是由 ...

  7. Nginx+Keepalived负载均衡高可用

    Nginx+Keepalived负载均衡高可用方案: Nginx 使用平台:unix.linux.windows. 功能: A.www web服务  http 80 b.负载均衡(方向代理proxy) ...

  8. Nginx实现负载均衡功能

    一.什么是Nginx? Nginx是一款轻量级的Web 服务器.反向代理服务器.电子邮件(IMAP/POP3)代理服务器. 二.Nginx的优点: 高并发连接:官方测试Nginx能够支撑5万并发连接, ...

  9. 若依项目利用nginx实现负载均衡及保持会话

    记录一下若依项目利用nginx实现负载均衡及保持会话的步骤. 此次作为试验性的测试,为了方便在本地window的环境上实现. 具体步骤: 1.安装两个tomcat8,可以下载一个后,另一个复制即可,下 ...

随机推荐

  1. RMAN_学习笔记4_RMAN Virtual Catalog虚拟恢复目录

    2014-01-01 Created By BaoXinjian Thanks and Regards

  2. Farey Sequence

    Description The Farey Sequence Fn for any integer n with n >= 2 is the set of irreducible rationa ...

  3. Chap2: question: 1 - 10

    1. 赋值运算符函数(或应说复制拷贝函数问题) class A { private: int value; public: A(int n) : value(n) {} A(A O) { value ...

  4. 使用opencv设置图像的格式以及帧率

    最近楼主正在写一个关于图像存储的程序,LZ有一颗求知心,想要了解保存的图像的格式以及获取摄像头帧率.晚些时候会写一篇关于opencv获取摄像头并且保存每帧图像信息方法. 1.修改图像的像素显示: 首先 ...

  5. 关于@property()的那些属性及ARC简介

    @property()常用的属性有:nonatomic,atomic,assign,retain,strong,weak,copy. 其中atomic和nonatomic用来决定编译器生成的gette ...

  6. apache+tomcat分布式集群搭建

    今天搭建apche+tomcat分布式集群,遇到很多问题,在网上找到的很多都不成功,然后和同事一起研究了一下,最终搭建成功了.做个笔记,以备自己以后参考. 1,下载apache.在下载Apache(2 ...

  7. MongoDB-MMS使用总结

    环境:阿里云 系统:ubuntu 12.04 数据库:MongoDB shell version: 2.0.4 登录MMS,注册相应用户 根据文档开始安装:Install the Monitoring ...

  8. 文件读写方法1.FileInputStream和FileOutputStream

    package fileTest; import java.io.File; import java.io.FileInputStream; import java.io.FileNotFoundEx ...

  9. 解决Ubuntu下 Could NOT find CURL (missing: CURL_LIBRARY CURL_INCLUDE_DIR)

    Ubuntu下CMake 编译时出现问题:Could NOT find CURL (missing: CURL_LIBRARY CURL_INCLUDE_DIR) 查找发现  # sudo apt-g ...

  10. lucene源码地址

    http://archive.apache.org/dist/lucene/java/