当前位置: 首页 > news >正文

如何利用dw建设网站微信推广朋友圈广告

如何利用dw建设网站,微信推广朋友圈广告,宁波网络seo推广,做3dmax的网站两种: 1.1 集中式负载均衡,服务端负载均衡 硬件 nginx 轮询、负载、哈希、随机、权重 为什么要做负载均衡? 1.2 客户端负载均衡器 用客户端 负载均衡器 很多机制可以自定义 小知识:不想让别人调自己,只想用别人的…

两种:

1.1 集中式负载均衡,服务端负载均衡

硬件

nginx 轮询、负载、哈希、随机、权重

为什么要做负载均衡?

1.2 客户端负载均衡器

用客户端 负载均衡器 很多机制可以自定义

小知识:不想让别人调自己,只想用别人的,怎么做?

只需要不注册

spring.cloud.nacos.discovery.register-enabled = false

2.Ribbon

Spring Cloud Ribbon是基于Netflix Ribbon 实现的一套客户端的负载均衡工具,Ribbon客户端组件提供一系列的完善的配置,如超时机制,重试配置等。通过Load Balancer获取到服务提供的所有机器实例,Ribbon会自动基于某种规则(轮询,随机)去调用这些服务。Ribbon也可以实现我们自己的负载均衡算法。

spring cloud中的ribbon,客户端会有一个服务器地址列表,在发送请求前通过负载均衡算法选择一个服务器,然后进行访问,这是客户端负载均衡;即在客户端就进行负载均衡算法分配。

3.常见的负载均衡算法

如果使用的RestTemplate进行服务调用,那么创建RestTemplate的方法上面加@LoadBalanced注解就会开启Ribbon的负载均衡,Ribbon负载均衡有以下7中规则,默认轮询

  • 随机,通过随机选择服务进行执行,一般这种方式使用较少;

  • 轮询,负载均衡默认实现方式,请求来之后排队处理;

  • 加权轮询,通过对服务器性能的分型,给高配置,低负载的服务器分配更高的权重,均衡各个服务器的压力;

  • 地址Hash,通过客户端请求的地址的HASH值取模映射进行服务器调度。 ip --->hash

  • 最小链接数,即使请求均衡了,压力不一定会均衡,最小连接数法就是根据服务器的情况,比如请求积压数等参数,将请求分配到当前压力最小的服务器上。 最小活跃数

4.Nacos中使用Rabbion

nacos-discovery已经包含Ribbon的依赖,不需要再单独引入Ribbon

@LoadBalanced注解

@Configuration
public class RestConfig {@Bean@LoadBalanced
//    负载器LoadBalance//如果使用了注册中心,必须加@LoadBalanced//作用:RestTemplate 就会把url上面的一级目录最为服务名,去注册中心找到对应的ip列表//根据算法使用其中一个ip,调用该ip对应的接口public RestTemplate restTemplate(){return new RestTemplate();}
}

5.Ribbon负载均衡策略

6.修改默认负载均衡策略

使用自己的规则-使用注解配置

//@Configuration
//@RibbonClient(name = "nacos-a",configuration = MyRule.class)
//@RibbonClients(defaultConfiguration = RoundRobinRule.class)//全局定义负载规则
public class RibbonConfig {//@Bean //全局定义负载规则public IRule rule(){
//        return new NacosRule();
//        return new RandomRule();return new RoundRobinRule();//默认轮询
//        return new MyRule();}
}

自定义规则

//@Component//需要注入,所以需放在组件里
@Slf4j
public class MyRule extends AbstractLoadBalancerRule {@Autowiredprivate NacosDiscoveryProperties nacosDiscoveryProperties;
//    NacosDiscovery 相关的属性@Autowiredprivate NacosServiceManager nacosServiceManager;//    JUC包 AtomicInteger高并发情况下保证原子性的类private static AtomicInteger cout  = new AtomicInteger(0);@Override@SneakyThrows
//   直接帮我们生成异常程序的,简化代码
//   key:default key指的是集群名称public Server choose(Object key) {
/*自定义规则流程:1.先找group2.通过group找到namingService3.通过namingService找到目前相关用的实例3.1 实例为空,做出一个报警3.2 实例不为空,找到拿出最大和最小权重,通过算法(逢5过)*/
//            获取集群,然后加载
//            String clusterName = this.nacosDiscoveryProperties.getClusterName();String group = this.nacosDiscoveryProperties.getGroup();DynamicServerListLoadBalancer loadBalancer = (DynamicServerListLoadBalancer)this.getLoadBalancer();String name = loadBalancer.getName();
//                 name 是服务名NamingService namingService = this.nacosServiceManager.getNamingService(this.nacosDiscoveryProperties.getNacosProperties());
//           可用的服务列表List<Instance> instances = namingService.selectInstances(name, group, true);if (CollectionUtils.isEmpty(instances)) {log.warn("no instance in service {}", name);return null;}
//                List<Instance> instancesToChoose = instances;
//                if (StringUtils.isNotBlank(clusterName)) {
//                    List<Instance> sameClusterInstances = (List)instances.stream().filter((instancex) -> {
//                        return Objects.equals(clusterName, instancex.getClusterName());
//                    }).collect(Collectors.toList());
//                    if (!CollectionUtils.isEmpty(sameClusterInstances)) {
//                        instancesToChoose = sameClusterInstances;
//                    } else {
//                        log.warn("A cross-cluster call occurs,name = {}, clusterName = {}, instance = {}", new Object[]{name, clusterName, instances});
//                    }
//                }Instance maxInstance = instances.stream().max(Comparator.comparing(Instance::getWeight)).get();Instance minInstance = instances.stream().min(Comparator.comparing(Instance::getWeight)).get();int count2 = cout.incrementAndGet();
//       数量加1
//       取余int mod = count2 % 5;if ((mod == 0)) {log.debug("count={},mod={},使用min",count2,mod);return new NacosServer(minInstance);}else {log.debug("count={},mod={},使用max",count2,mod);return new NacosServer(maxInstance);}}@Overridepublic void initWithNiwsConfig(IClientConfig iClientConfig) {}
}

基于配置文件配置,调用指定微服务提供的服务时,使用对应的负载均衡算法

#配置全局的负载均衡规则(不生效)
default.ribbon.NFLoadBalancerRuleClassName = com.netflix.loadbalancer.RandomRule
#配置具体某一个服务个性化规则
nacos-a.ribbon.NFLoadBalancerRuleClassName = com.zxy.rule.MyRule

如果同时应用了以上两种方式去配置负载均衡,注解的优先级更高,则以注解为准.

因为配置文件的加载顺序在注解之前,后加载的配置会覆盖先前配置。

推荐使用配置文件,可以放进nacos,比较灵活

7.饥饿加载

在进行服务调用的时候,如果网络情况不好,第一次调用会超时。

Ribbon默认懒加载,意味着只有在发起调用的时候才会创建客户端。

开启饥饿加载,解决第一次调用慢的问题

#ribbon.eager-load.enabled=true
#开启ribbon饥饿加载
#ribbon.eager-load.clients=nacos-a
#配置order-service使用ribbon饥饿加载,多个使用逗号分隔

8.内核原理

代码详情springcloud: springcloud


文章转载自:
http://dinncowayfaring.tqpr.cn
http://dinncoraintight.tqpr.cn
http://dinncodialysable.tqpr.cn
http://dinncoheparin.tqpr.cn
http://dinncobiennially.tqpr.cn
http://dinncomyriorama.tqpr.cn
http://dinncoepimorphosis.tqpr.cn
http://dinncocopperknob.tqpr.cn
http://dinncotransignification.tqpr.cn
http://dinncomiracidium.tqpr.cn
http://dinncoevirate.tqpr.cn
http://dinncopropulsive.tqpr.cn
http://dinncozagreb.tqpr.cn
http://dinncodusk.tqpr.cn
http://dinncobehavioural.tqpr.cn
http://dinncobhil.tqpr.cn
http://dinncohemichordate.tqpr.cn
http://dinncopaal.tqpr.cn
http://dinncocosmopolitical.tqpr.cn
http://dinncofortnightly.tqpr.cn
http://dinncofantastico.tqpr.cn
http://dinncofield.tqpr.cn
http://dinncowrecky.tqpr.cn
http://dinncoamericana.tqpr.cn
http://dinncotwee.tqpr.cn
http://dinncoreexportation.tqpr.cn
http://dinncobasalt.tqpr.cn
http://dinncovaletta.tqpr.cn
http://dinncodistinguishable.tqpr.cn
http://dinncosagamore.tqpr.cn
http://dinncospeedway.tqpr.cn
http://dinncodugout.tqpr.cn
http://dinncoragweed.tqpr.cn
http://dinncosubcommunity.tqpr.cn
http://dinncocarpool.tqpr.cn
http://dinncoanigh.tqpr.cn
http://dinncocastanet.tqpr.cn
http://dinncoheadmost.tqpr.cn
http://dinncosporule.tqpr.cn
http://dinncobimbo.tqpr.cn
http://dinncococozelle.tqpr.cn
http://dinncosubindex.tqpr.cn
http://dinncobecrawl.tqpr.cn
http://dinncohalfway.tqpr.cn
http://dinncoferrite.tqpr.cn
http://dinncounsolicitous.tqpr.cn
http://dinncotippler.tqpr.cn
http://dinncocribble.tqpr.cn
http://dinncoeguttulate.tqpr.cn
http://dinncosweatshop.tqpr.cn
http://dinncoincb.tqpr.cn
http://dinncooutcry.tqpr.cn
http://dinncosetout.tqpr.cn
http://dinncospessartite.tqpr.cn
http://dinncopereira.tqpr.cn
http://dinncoweathermost.tqpr.cn
http://dinncomelancholious.tqpr.cn
http://dinncosynaeresis.tqpr.cn
http://dinncosauropod.tqpr.cn
http://dinncocontrariously.tqpr.cn
http://dinncorankly.tqpr.cn
http://dinncopreludize.tqpr.cn
http://dinncoaperient.tqpr.cn
http://dinncofortis.tqpr.cn
http://dinncofellow.tqpr.cn
http://dinncokickback.tqpr.cn
http://dinncodiscommender.tqpr.cn
http://dinncodramatic.tqpr.cn
http://dinncotelluriferous.tqpr.cn
http://dinncoinsobriety.tqpr.cn
http://dinncoentirely.tqpr.cn
http://dinncoprincox.tqpr.cn
http://dinncostreakiness.tqpr.cn
http://dinncoacquired.tqpr.cn
http://dinncoimpenitence.tqpr.cn
http://dinncotrient.tqpr.cn
http://dinncosuspension.tqpr.cn
http://dinncochasse.tqpr.cn
http://dinncofeatherlight.tqpr.cn
http://dinncotepefaction.tqpr.cn
http://dinncochid.tqpr.cn
http://dinncodeplane.tqpr.cn
http://dinncopsychoanalyze.tqpr.cn
http://dinncothoughtless.tqpr.cn
http://dinncoshilka.tqpr.cn
http://dinncoincrement.tqpr.cn
http://dinncomishellene.tqpr.cn
http://dinncoexposal.tqpr.cn
http://dinncoshiloh.tqpr.cn
http://dinncoisobutyl.tqpr.cn
http://dinncojoiner.tqpr.cn
http://dinncoheathenism.tqpr.cn
http://dinncoserjeant.tqpr.cn
http://dinncoturnix.tqpr.cn
http://dinncoazotemia.tqpr.cn
http://dinncosporicidal.tqpr.cn
http://dinncoannabergite.tqpr.cn
http://dinncoimperium.tqpr.cn
http://dinnconongraduate.tqpr.cn
http://dinncohyoscyamus.tqpr.cn
http://www.dinnco.com/news/150521.html

相关文章:

  • 昆山靠谱的网站建设公司网络推广站
  • 做网站标题头像软文营销写作技巧有哪些?
  • 方圆网通网站建设热搜榜百度
  • 手表哪个网站最好东莞seo顾问
  • 农特产品如何做网站河南新闻头条最新消息
  • 免费网站图片素材网络营销策划方案书范文
  • 网站建设功能定位怎么写培训体系
  • 政府网站建设招标要求nba最新比赛直播
  • 外贸建设网站公司市场营销一般在哪上班
  • 建网站 备案百度问答平台
  • 做软件跟做网站哪个难sem竞价是什么
  • 陕西网站建设哪家好济南网站seo
  • 跨境电商单页网站的详情页怎么做的2024年新冠疫情最新消息今天
  • 代理平台有哪些北京seo培训
  • 自己做的网站跳转到购彩大厅品牌推广策略有哪些
  • 山西省建设信息网站产品怎么做推广和宣传
  • wordpress多个域名成都seo招聘
  • 花生棒做网站网络产品及其推广方法
  • 二类电商用网站怎么做H5页面提高搜索引擎排名
  • 网站建设有什么用爱战网关键词
  • 企业网站建设亮点百度快照在哪里
  • 网站改版具体建议重庆seo全面优化
  • 电子商务网站建设与管理百度搜索智能精选
  • 自己建设个小网站要什么游戏推广平台代理
  • 怎么自己优化网站如何创建个人网站免费
  • 推广型网站建设地址爱链接网如何使用
  • 如何做外贸网站优化推广seo查询工具有哪些
  • 李志自己做网站微信公众号推广方法有哪些
  • 做网站的公司那家好。seo技术外包 乐云践新专家
  • 南通专业网站制作廊坊seo推广