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. [家里蹲大学数学杂志]第056期Tikhonov 泛函的变分

    设 $\scrX$, $\scrY$ 是 Hilbert 空间, $T\in \scrL(\scrX,\scrY)$, $y_0\in\scrY$, $\alpha>0$. 则 Tikhonov ...

  2. GDI+系列

    1.GDI+的概述 2.绘图表面 3.GDI+坐标系 4.用Pen对象画图 1.使用GDI+画线 2.使用GDI+画弧线 3.使用GDI+画曲线 4.使用GDI+画椭圆 5.使用GDI+画矩形.多边形 ...

  3. java 线程的堵塞

    //线程的阻塞 // //线程 class xc1 implements Runnable{ public void run(){ for(int i=1;i<=30;i++){ System. ...

  4. Java锁 到底锁的是哪个对象?

    更新:在一次和一位专家的交谈中,他对一下代码能否能够成功同步,给予了否定的答案, 他的理由是”以构造函数的成员变量作为synchronized的锁,在多线程的情况下,每一个线程都持有自己私有变量的锁, ...

  5. 解决eclipse中安装AIX2插件问题

    为了做webservice,查了下,需要用到AXIS2(当然也有别的方法,貌似更复杂,详情可以参看:java开发webservice的几种方式).可试了N次,下载的codegen和service插件始 ...

  6. LVM原理及实现过程

    这里引用鸟哥说明 LVM 的重点在於『可以弹性的调整 filesystem 的容量!』而并非在於效能与数据保全上面. 需要文件的读写效能或者是数据的可靠性,请参考前面的 RAID 小节. LVM 可以 ...

  7. archlinux 内核编译笔记

    # cp linux-3.10.5.tar.gz /usr/src/linux-3.10.5.tar.gz# cd /usr/src# tar xvzf linux-3.10.5.tar.gz lin ...

  8. windows 上执行python pywin32.exe

    大家熟知的python脚本可以在linux系统上直接运行,因为linux上会安装python编译器 然而windows不会安装,如果想要别人直接运行你发布的python脚本,一种方法是在他的windo ...

  9. jquery datatable 参数

    DataTables(http://www.datatables.net/)应该是我到目前为止见过的,功能最强大的表格解决方案(当然,不计算其它整套框架中的table控件在内). 先把它主页上写的特性 ...

  10. python调用jar包类

    #!/usr/bin/python2.7#coding:utf8import sysimport jpypeimport os.path phone_num = sys.argv[1]#jarpath ...