杭州BGP43.227.216验证负载均衡服务器租用

杭州BGP43.227.216验证负载均衡和 Session 复制

测试环境

使用两台 PC 部署 Tomcat,对应关系是:172.31.1.41-Tomcat1,172.31.1.42-Tomcat2

部署基于使用 Tomcat 自带的 SessionExample 程序,编写了一个 tomcat-benchmark 的 web 应用

结合 Tomcat 自带的 Manager 应用,查看已部署应用内部 Session 池

负载均衡

修改 tomcat-benchmark 部署描述符文件中的 context-param 为 "I'm Tomcat 1/2" 用于区分两个 Tomcat,启动 Nginx 和 Tomcat,在浏览器访问 172.31.1.42:8000 可以看到请求在两个服务器间切换:

为了方便理解,这里先把 Nginx 的负载均衡策略设置成 ip_hash:

假设 Nginx 始终将请求定位到 Tomcat1 上,然后在 Tomcat1 BGP服务器上创建会话,往会话中添加一些属性

关闭 Tomcat1 模拟故障,此时 Nginx 会带着之前的会话 Cookie 将请求转发到 Tomcat2,上查看 Tomcat2 上是否存在与 Cookie(JSESSIONID) 关联的 Session 信息,若有表示复制成功。

43.227.216.99 43.227.216.1 43.227.216.101 43.227.216.201 43.227.216.156 43.227.216.56 43.227.216.246
43.227.216.100 43.227.216.2 43.227.216.102 43.227.216.202 43.227.216.157 43.227.216.57 43.227.216.247
43.227.216.243 43.227.216.3 43.227.216.103 43.227.216.203 43.227.216.158 43.227.216.58 43.227.216.248
43.227.216.244 43.227.216.4 43.227.216.104 43.227.216.204 43.227.216.159 43.227.216.59 43.227.216.249
43.227.216.245 43.227.216.5 43.227.216.105 43.227.216.205 43.227.216.160 43.227.216.60 43.227.216.250
43.227.216.94 43.227.216.6 43.227.216.106 43.227.216.206 43.227.216.161 43.227.216.61 43.227.216.251
43.227.216.95 43.227.216.7 43.227.216.107 43.227.216.207 43.227.216.162 43.227.216.62 43.227.216.252
43.227.216.198 43.227.216.8 43.227.216.108 43.227.216.208 43.227.216.163 43.227.216.63 43.227.216.253
43.227.216.199 43.227.216.9 43.227.216.109 43.227.216.209 43.227.216.164 43.227.216.64 43.227.216.254
43.227.216.200 43.227.216.10 43.227.216.110 43.227.216.210 43.227.216.165 43.227.216.65 43.227.216.255
43.227.216.194 43.227.216.11 43.227.216.111 43.227.216.211 43.227.216.166 43.227.216.66 43.227.216.146
43.227.216.195 43.227.216.12 43.227.216.112 43.227.216.212 43.227.216.167 43.227.216.67 43.227.216.147
43.227.216.196 43.227.216.13 43.227.216.113 43.227.216.213 43.227.216.168 43.227.216.68 43.227.216.148
43.227.216.197 43.227.216.14 43.227.216.114 43.227.216.214 43.227.216.169 43.227.216.69 43.227.216.149
43.227.216.15 43.227.216.115 43.227.216.215 43.227.216.170 43.227.216.70 43.227.216.150
43.227.216.239 43.227.216.16 43.227.216.116 43.227.216.216 43.227.216.171 43.227.216.71 43.227.216.151
43.227.216.240 43.227.216.17 43.227.216.117 43.227.216.217 43.227.216.172 43.227.216.72 43.227.216.152
43.227.216.241 43.227.216.18 43.227.216.118 43.227.216.218 43.227.216.173 43.227.216.73 43.227.216.153
43.227.216.242 43.227.216.19 43.227.216.119 43.227.216.219 43.227.216.174 43.227.216.74 43.227.216.154
43.227.216.** 43.227.216.20 43.227.216.120 43.227.216.220 43.227.216.175 43.227.216.75 43.227.216.155
43.227.216.139 43.227.216.21 43.227.216.121 43.227.216.76 43.227.216.46 43.227.216.221 43.227.216.176
43.227.216.140 43.227.216.22 43.227.216.122 43.227.216.77 43.227.216.47 43.227.216.222 43.227.216.177
43.227.216.141 43.227.216.23 43.227.216.123 43.227.216.78 43.227.216.48 43.227.216.223 43.227.216.178
43.227.216.142 43.227.216.24 43.227.216.124 43.227.216.79 43.227.216.49 43.227.216.224 43.227.216.179
43.227.216.X 43.227.216.25 43.227.216.125 43.227.216.80 43.227.216.50 43.227.216.225 43.227.216.180
43.227.216.39 43.227.216.26 43.227.216.126 43.227.216.81 43.227.216.51 43.227.216.226 43.227.216.181
43.227.216.40 43.227.216.27 43.227.216.127 43.227.216.82 43.227.216.52 43.227.216.227 43.227.216.182
43.227.216.143 43.227.216.28 43.227.216.128 43.227.216.83 43.227.216.53 43.227.216.228 43.227.216.183
43.227.216.144 43.227.216.29 43.227.216.129 43.227.216.84 43.227.216.54 43.227.216.229 43.227.216.184
43.227.216.145 43.227.216.30 43.227.216.130 43.227.216.85 43.227.216.55 43.227.216.230 43.227.216.185
43.227.216.93 43.227.216.31 43.227.216.131 43.227.216.86 43.227.216.41 43.227.216.231 43.227.216.186
43.227.216.98 43.227.216.32 43.227.216.132 43.227.216.87 43.227.216.42 43.227.216.232 43.227.216.187
43.227.216.193 43.227.216.33 43.227.216.133 43.227.216.88 43.227.216.43 43.227.216.233 43.227.216.188
43.227.216.238 43.227.216.34 43.227.216.134 43.227.216.89 43.227.216.44 43.227.216.234 43.227.216.189
43.227.216.138 43.227.216.35 43.227.216.135 43.227.216.90 43.227.216.45 43.227.216.235 43.227.216.190
43.227.216.38 43.227.216.36 43.227.216.136 43.227.216.91 43.227.216.96 43.227.216.236 43.227.216.191
43.227.216.37 43.227.216.137 43.227.216.92 43.227.216.97 43.227.216.237 43.227.216.192

 

您可能还会对下面的文章感兴趣:

COPYRIGHT © 2010-2018 东莞云悫计算机系统有限公司 All Rights Reserved.

粤ICP备16096532号
客服中心 customer service center

大客户经理咨询 (投诉建议QQ:1635789366 电话:183-0000-3210)

售后服务 (网维技术QQ:404634181 值班电话:18929-444-536)

工作时间: 周一至周五 9:30至17:30 周六13:30至17:30,其它日期按国家法定节假日休假,如果有不便之请敬请谅解! 售后技术支持:多部门7*24小时机制。

客户投诉留言

电话和QQ,以便我们为您提供优质服务! *为必填项