博客
关于我
nginx--实现负载均衡(二)
阅读量:627 次
发布时间:2019-03-14

本文共 508 字,大约阅读时间需要 1 分钟。

关于nginx的下载和部署见上一篇博客,话不多说,直接上案例。

1、准备两个springboot服务(,8/)

2、配置nginx配置文件,重启nginx服务

配置监听的地址和端口localhost 9990,通过(upstream)定义一个变量tomcatserver1配置负载均衡的多个节点(localhost:9999,localhost:9998),指定代理到tomcatserver1,具体如下图

3、测试负载均衡效果:

由上面两个图可以看出,访问9990的代理端口时,可以正常且负载均衡的获取9999和9998两个服务。

 

扩展:

配置权重的负载均衡(weight),如下配置后,访问9999端口服务的概率为90%,9998的服务概率为10%。

实现根据ip只代理到一个服务,防止随机造成session跨域的问题,加上(ip_hash),之后这个ip发出的请求只会访问到9999或9998中的一个

响应时间短,优先分配

按照url的hash结果分配请求,使每个url定向到同一个后端服务器,后端服务器为缓存时比较有效。这种情况不能配置weight等其他参数

以上仅为个人学习结果,不喜勿喷,学海无涯苦作舟!

转载地址:http://fraoz.baihongyu.com/

你可能感兴趣的文章
NMAP网络扫描工具的安装与使用
查看>>
NMF(非负矩阵分解)
查看>>
nmon_x86_64_centos7工具如何使用
查看>>
NN&DL4.1 Deep L-layer neural network简介
查看>>
NN&DL4.3 Getting your matrix dimensions right
查看>>
NN&DL4.7 Parameters vs Hyperparameters
查看>>
NN&DL4.8 What does this have to do with the brain?
查看>>
nnU-Net 终极指南
查看>>
No 'Access-Control-Allow-Origin' header is present on the requested resource.
查看>>
No 'Access-Control-Allow-Origin' header is present on the requested resource.
查看>>
NO 157 去掉禅道访问地址中的zentao
查看>>
no available service ‘default‘ found, please make sure registry config corre seata
查看>>
No compiler is provided in this environment. Perhaps you are running on a JRE rather than a JDK?
查看>>
no connection could be made because the target machine actively refused it.问题解决
查看>>
No Datastore Session bound to thread, and configuration does not allow creation of non-transactional
查看>>
No fallbackFactory instance of type class com.ruoyi---SpringCloud Alibaba_若依微服务框架改造---工作笔记005
查看>>
No Feign Client for loadBalancing defined. Did you forget to include spring-cloud-starter-loadbalanc
查看>>
No mapping found for HTTP request with URI [/...] in DispatcherServlet with name ...的解决方法
查看>>
No mapping found for HTTP request with URI [/logout.do] in DispatcherServlet with name 'springmvc'
查看>>
No module named 'crispy_forms'等使用pycharm开发
查看>>