nginx apache负载均衡测试
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负载均衡测试的更多相关文章
- nginx作为负载均衡服务器——测试
i. 需求 nginx作为负载均衡服务器,用户请求先到达nginx,再由nginx根据负载配置将请求转发至 tomcat服务器. nginx负载均衡服务器:192.168.101.3 tomcat1服 ...
- Nginx网络架构实战学习笔记(三):nginx gzip压缩提升网站速度、expires缓存提升网站负载、反向代理实现nginx+apache动静分离、nginx实现负载均衡
文章目录 nginx gzip压缩提升网站速度 expires缓存提升网站负载 反向代理实现nginx+apache动静分离 nginx实现负载均衡 nginx gzip压缩提升网站速度 网页内容的压 ...
- nginx+tomcat负载均衡
最近练习nginx+tomcat负载均衡.根据一些资料整理了大体思路,最终实现了1个nginx+2个tomcat负载均衡. 安装JDK 1>进入安装目录,给所有用户添加可执行的权限 #chmod ...
- nginx做负载均衡配置文件
nginx做负载均衡是在反向代理的基础上做的,代码如下: ## Basic reverse proxy server ## ## Apache backend for www.baidu.com ## ...
- linux+nginx+tomcat负载均衡,实现session同步
linux+nginx+tomcat负载均衡,实现session同步 花了一个上午的时间研究nginx+tomcat的负载均衡测试,集群环境搭建比较顺利,但是session同步的问题折腾了几个小时才搞 ...
- 利用nginx实现负载均衡和动静分离
1.Nginx介绍 Nginx ("engine x") 是一个高性能的 HTTP 和 反向代理 服务器,也是一个 IMAP/POP3/SMTP 代理服务器 . Nginx 是由 ...
- Nginx+Keepalived负载均衡高可用
Nginx+Keepalived负载均衡高可用方案: Nginx 使用平台:unix.linux.windows. 功能: A.www web服务 http 80 b.负载均衡(方向代理proxy) ...
- Nginx实现负载均衡功能
一.什么是Nginx? Nginx是一款轻量级的Web 服务器.反向代理服务器.电子邮件(IMAP/POP3)代理服务器. 二.Nginx的优点: 高并发连接:官方测试Nginx能够支撑5万并发连接, ...
- 若依项目利用nginx实现负载均衡及保持会话
记录一下若依项目利用nginx实现负载均衡及保持会话的步骤. 此次作为试验性的测试,为了方便在本地window的环境上实现. 具体步骤: 1.安装两个tomcat8,可以下载一个后,另一个复制即可,下 ...
随机推荐
- html__脚本之家
深入剖析Android的Volley库中的图片加载功能 Android图片加载缓存框架Glide Android程序开发ListView+Json+异步网络图片加载+滚动翻页的例子(图片能缓存,图片不 ...
- Java多线程-线程的同步与锁
一.同步问题提出 线程的同步是为了防止多个线程访问一个数据对象时,对数据造成的破坏.例如:两个线程ThreadA.ThreadB都操作同一个对象Foo对象,并修改Foo对象上的数据. package ...
- mybatis oracle insert 返回新增的主键值
<insert id="insertVmsTemplatePlayItem" parameterType="VmsTemplatePlayItem"> ...
- FPGA边缘检测
沿检测技术在项目应用中, 非常低广泛. 如要有效捕获信号跳变沿, 边沿 检测技术的应用是必不可少的.大致如下: (1) 将时钟边沿使能转换为边沿检测使能,使时钟同步化. (2) 捕获信号的突变( UA ...
- is not in the sudoers file 问题解决【转载】
解决方案:首需要切换到root身份$su - 或者 $sudo -s (注意有- ,这和su是不同的,在用命令"su"的时候只是切换到root,但没有把root的环境变量传过去,还 ...
- uploadify图片上传发生Security Error
今天在使用uploadify进行图片上传的时候出现security error.其根本原因是flash跨域问题.主要原因是因为配了两个域名www.ttyouni.com 和 ttyouni.com 在 ...
- listview java.lang.ArrayIndexOutOfBoundsException:
检测下BaseAdapter 下的getViewTypeCount()方法返回的值与getItemViewType返回的个数是否是相等的!
- 【转】Java日期计算之Joda-Time
Joda-Time提供了一组Java类包用于处理包括ISO8601标准在内的date和time.可以利用它把JDK Date和Calendar类完全替换掉,而且仍然能够提供很好的集成. http:// ...
- ORA-01720: grant option does not exist for 'xxx.xxxx' (ORA-01720 ‘XXX’ 不存在授权选项)
原因:用户A将表tab的SELECT权限授予了用户B,而用户B将视图v_tab的查询权限授予C时,也试图将表tab授予用户C,但用户B并没有这个权限(将表tab授予用户C),而引起的 用户B没有授权选 ...
- 如何用Jquery实现 ,比如点击图片之后 ,该图片变成向下的箭头,再点击向下箭头的图片 又变成原始图片呢
<!DOCTYPE html><html><head><meta charset="utf-8" /><title>切换 ...