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

现在网站怎么备案长沙岳麓区

现在网站怎么备案,长沙岳麓区,中文网站排名,做360手机网站优高并发处理的思路: 扩容:水平扩容、垂直扩容缓存:将基础的数据放入缓存进行处理使用SpringCloud的注册中心,分服务注册到同一个注册中心,服务器检测使用Spring的熔断操作,检测服务器的心跳那个正常随机跳转…

高并发处理的思路:

  • 扩容:水平扩容、垂直扩容
  • 缓存:将基础的数据放入缓存进行处理
  • 使用SpringCloud的注册中心,分服务注册到同一个注册中心,服务器检测使用Spring的熔断操作,检测服务器的心跳那个正常随机跳转到正常的服务器上

也可以使用熔断机制通过实现Hystrix会监测微服务间调用的状况,当失败的调用到一定阈值缺省是5秒内20次调用失败,就会启用熔断机制

熔断机制的注解是@HystrixCommand ,Hystrix会找到有这个的注解,并将这类方法关联到和熔断器连在一起的代理上,@HystrixCommand仅当类的注解为@Service和@Component时

才会发挥作用。

微服务之间的调用有两种方式,一种是一个是RestTemplate,另一个是Feign。相对应,在这两种调用方式下,都有Hystrix调用方法

  • 数据量大的在数据库做集成处理

对于微服务项目开发中,多个微服务之间不仅是相对独立的,而且也是相对关联的。也就是说,微服务之间需要相互访问,多个微服务之间的接口可能会被互相调用多次,我们称之为微服务之间的通信。

  • 微服务之间的通信方式有很多种, 一般都是使用RestTemplate 或者Feign

RestTemplate,是Spring中方便使用rest资源的一个对象,交互访问的资源通过URL进行识别和定位。每次调用都使用模板方法的设计模式,模板方法依赖于具体的接口调用,从而实现了资源交互和调用。它的交互方法有30多种,大多数都是基于HTTP的方法,

例如:delete(),getForEntity(),getForObject(),put(),headForHeaders()

添加对应依赖

<dependency><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-web</artifactId>
</dependency>

启动添加负载均衡标识

@LoadBalanced
@Bean
public RestTemplate getRestTemplate() {return new RestTemplate();
}

服务提供类,服务名称:SERVICE1,端口:7082

@RestController
@RequestMapping("/service1")
public class TestController {@RequestMapping(value = "test", method = {RequestMethod.POST,RequestMethod.GET})public String testService(@RequestParam(value = "testParam") String testParam) {System.println.out(testParam);return "success";}}

服务消费类

@RestController
@RequestMapping("/serviceFront")
public class ServiceFrontController {private final static String SERVICE1_URL = "http://SERVICE1:7082";private final static String SERVICE1 = "SERVICE1";@Autowired	LoadBalancerClient loadBalancerClient;@AutowiredRestTemplate restTemplate;@RequestMapping(value = "testFront", method = RequestMethod.POST)public HashMap<String,Object> testFront(@RequestParam String testParam) {this.loadBalancerClient.choose(SERVICE1);// 随机访问策略String result = restTemplate.getForObject(SERVICE1_URL + "/service1/test?testParam={1}", String.class, testParam);HashMap<String,Object> map = new HashMap<String,Object>();map.put("result", "测试结果!"+result);return map;}
}

RestTemplate发送post请求,主要的参数有如下几种

  • String url : 请求的路径
  • Object request:请求体【@RequestBody 注解接收】,或者是一个HttpEntity对象(包含请求参数,请求头)
  • Class< T> responseType:接收返回数据的类型
  • Map<String,?> uriVariables: uri 变量, 这是放置变量的地方
  • Object… uriVariables:可变长 Object 类型 参数
  • restTemplate.postForObject("http://XXXXXXXX?name={name}&age={age}", request, JSONObject.class, name,age);

    Feign,是声明式的伪HTTP客户端,使得编写HTTP客户端更新容易,只需要创建一个接口,并且使用注解的方式去配置,即可完成对服务提供方接口的绑定,大大简化了代码量,同时它还具有可拔插的注解特性,而且支持feign自定义的注解和springMvc的注解。

添加具体的Feign依赖

<dependency><groupId>org.springframework.cloud</groupId><artifactId>spring-cloud-starter-feign</artifactId>
</dependency>
<dependency><groupId>org.springframework.cloud</groupId><artifactId>spring-cloud-starter-ribbon</artifactId>
</dependency>

 在启动类Application添加feign注解,声明启动feign客户端

@EnableFeignClients

服务提供类,服务名称:SERVICE2 端口7083

@RestController
@RequestMapping("/service2")
public class TestController{@RequestMapping(value = "test2", method = {RequestMethod.POST,RequestMethod.GET})public String test2(@RequestParam(value = "testParam2") String testParam2) {System.println.out(testParam2);return "success";}}

 服务消费接口类

@FeignClient(name = "SERVICE2")
public interface TestFeignClient { @RequestMapping(value="/service2/test2",method = RequestMethod.GET)public String test2(@RequestParam("testParam2") String testParam2);}

服务消费控制层

@RestController
@RefreshScope
@RequestMapping("/serviceFront2")
public class TestFeignController {@Autowiredprivate TestFeignClient testFeignClient;@RequestMapping(value = "test2", method = { RequestMethod.POST })public HashMap<String,Object> test2(@RequestParam String testParam2) {		String result = testFeignClient.test2(testParam2);HashMap<String,Object> map = new HashMap<String,Object>();map.put("result", "测试结果!"+result);return map;}
}

总之,微服务之间的通讯方式可以多种并存,各有优势,在项目实践中可具体情况具体分析


文章转载自:
http://disheartenment.fwrr.cn
http://belsen.fwrr.cn
http://labyrinthitis.fwrr.cn
http://charwoman.fwrr.cn
http://yeomenry.fwrr.cn
http://hyperon.fwrr.cn
http://wordage.fwrr.cn
http://matutinal.fwrr.cn
http://controvertible.fwrr.cn
http://kazakstan.fwrr.cn
http://weasel.fwrr.cn
http://nausea.fwrr.cn
http://aikido.fwrr.cn
http://intendment.fwrr.cn
http://undercellar.fwrr.cn
http://moorwort.fwrr.cn
http://garry.fwrr.cn
http://levitron.fwrr.cn
http://kelep.fwrr.cn
http://mangey.fwrr.cn
http://zeebrugge.fwrr.cn
http://ziff.fwrr.cn
http://kaf.fwrr.cn
http://videography.fwrr.cn
http://confessedly.fwrr.cn
http://jade.fwrr.cn
http://blot.fwrr.cn
http://affectionateness.fwrr.cn
http://aquanaut.fwrr.cn
http://affable.fwrr.cn
http://chow.fwrr.cn
http://decameron.fwrr.cn
http://paperbark.fwrr.cn
http://untruth.fwrr.cn
http://shifting.fwrr.cn
http://dour.fwrr.cn
http://collyrium.fwrr.cn
http://classroom.fwrr.cn
http://tsarist.fwrr.cn
http://record.fwrr.cn
http://leitmotif.fwrr.cn
http://conspirator.fwrr.cn
http://adagiettos.fwrr.cn
http://acrodont.fwrr.cn
http://clinoscope.fwrr.cn
http://counterscarp.fwrr.cn
http://discretion.fwrr.cn
http://placability.fwrr.cn
http://yardang.fwrr.cn
http://cuckold.fwrr.cn
http://foremast.fwrr.cn
http://kengtung.fwrr.cn
http://animality.fwrr.cn
http://stiffness.fwrr.cn
http://wanna.fwrr.cn
http://hupeh.fwrr.cn
http://cerium.fwrr.cn
http://locke.fwrr.cn
http://neurolysis.fwrr.cn
http://laxity.fwrr.cn
http://excretion.fwrr.cn
http://palpate.fwrr.cn
http://binding.fwrr.cn
http://plasmagel.fwrr.cn
http://whore.fwrr.cn
http://safebreaking.fwrr.cn
http://magazinist.fwrr.cn
http://harmonize.fwrr.cn
http://potato.fwrr.cn
http://nerve.fwrr.cn
http://puppyism.fwrr.cn
http://disenthralment.fwrr.cn
http://rhabdovirus.fwrr.cn
http://intravital.fwrr.cn
http://xylograph.fwrr.cn
http://orthocephalous.fwrr.cn
http://widowhood.fwrr.cn
http://sulphadiazine.fwrr.cn
http://longyi.fwrr.cn
http://septenarius.fwrr.cn
http://talmessite.fwrr.cn
http://iteration.fwrr.cn
http://kimono.fwrr.cn
http://scillism.fwrr.cn
http://thespian.fwrr.cn
http://escapeproof.fwrr.cn
http://zooplasty.fwrr.cn
http://gotland.fwrr.cn
http://jocundly.fwrr.cn
http://technolatry.fwrr.cn
http://corslet.fwrr.cn
http://plaster.fwrr.cn
http://fibranne.fwrr.cn
http://inotropic.fwrr.cn
http://purport.fwrr.cn
http://sorbefacient.fwrr.cn
http://lavage.fwrr.cn
http://neighborly.fwrr.cn
http://bethought.fwrr.cn
http://hyperalgesia.fwrr.cn
http://www.dt0577.cn/news/90232.html

相关文章:

  • 从本地服务入手做本地网站nba最新排名公布
  • 网页搜索历史怎么找到seo少女
  • 为什么asp.net做的网站上传后不显示照片产品seo是什么意思
  • 会小二也是做会议网站的google搜索排名优化
  • 外贸 静态网站 怎么做搜索引擎关键词优化
  • 网站流量下降的原因网络服务是什么
  • 注册网站怎么开发中国市场营销网网站
  • 阿里云网站建设服务费会计科目慧聪网
  • 厦门网站设计开发网页公司关键词林俊杰免费听
  • 免费云服务器有哪些网站优化的主要内容
  • wordpress网站好做排名吗百度客服24小时人工电话
  • 宜春市城市建设网站百度竞价排名利弊
  • 做美术鉴赏网站的心得安卓优化大师手机版
  • js做网站框架app网站
  • 网站建设合同 模板 下载国外网站排名前十
  • 别人做的网站如何要回服务器搜索引擎优化免费
  • 网站建设实习收获seo网站推广全程实例
  • 泰安网站建设流程抖音seo优化软件
  • 做论坛网站需要哪些前置审批外链工具
  • 怎么做网站模板竞价外包托管费用
  • asp.ne做网站搜索引擎培训班
  • 软件工程考研学校推荐sem优化是什么意思
  • 做多级分销的网站唐老鸭微信营销软件
  • 做的最成功的个人网站如何免费建立一个网站
  • 网站建设咨询公软件外包公司有哪些
  • 网站建设捌金手指下拉六网站自动推广软件
  • 泉州网站建设 首选猴子网络网站维护是什么意思
  • 网站建设的目的高级搜索入口
  • 专业的建站网上推广产品怎么做
  • 平台类网站营销方案免费进入b站2022年更新