服务网关组件的使用

什么是服务网关

说明

网关统一服务入口,可方便实现对平台众多服务接口进行管控,对访问服务的身份认证、防报文重放与防数据篡改、功能调用的业务鉴权、响应数据的脱敏、流量与并发控制,甚至基于API调用的计量或者计费等等。

网关 = 路由转发 + 过滤器

路由转发:接收一切外界请求,转发到后端的微服务上去;

过滤器:在服务网关中可以完成一系列的横切功能,例如权限校验、限流以及监控等,这些都可以通过过滤器完成。

阅读更多

Hystrix组件使用

In a distributed environment, inevitably some of the many service dependencies will fail. Hystrix is a library that helps you control the interactions between these distributed services by adding latency tolerance and fault tolerance logic. Hystrix does this by isolating points of access between the services, stopping cascading failures across them, and providing fallback options, all of which improve your system’s overall resiliency. –[摘自官方]

阅读更多

OpenFeign组件的使用

简介

官方:https://cloud.spring.io/spring-cloud-openfeign/reference/html/

Feign是一个声明式的伪Http客户端,它使得写Http客户端变得更简单。使用Feign,只需要创建一个接口并注解。它具有可插拔的注解特性(可以使用springmvc的注解),可使用Feign 注解和JAX-RS注解。Feign支持可插拔的编码器和解码器。Feign默认集成了Ribbon,默认实现了负载均衡的效果并且springcloud为feign添加了springmvc注解的支持。

阅读更多

服务间通信方式及Ribbon使用

在整个微服务架构中,我们比较关心的就是服务间的服务改如何调用,有哪些调用方式?

在springcloud中服务间调用方式主要是使用 http restful方式进行服务间调用

阅读更多

Consul基本使用

简介

官网:https://www.consul.io

consul是一个可以提供服务发现,健康检查,多数据中心,Key/Value存储等功能的分布式服务框架,用于实现分布式系统的服务发现与配置。与其他分布式服务注册与发现的方案,使用起来也较为简单。Consul用Golang实现,因此具有天然可移植性(支持Linux、Windows和Mac OS X);安装包仅包含一个可执行文件,方便部署。

阅读更多

Eureka基本使用

简介

官网:https://github.com/Netflix/eureka/wiki

Eureka是Netflix开发的服务发现框架,本身是一个基于REST的服务。SpringCloud将它集成在其子项目spring-cloud-netflix中,以实现SpringCloud的服务注册和发现功能。
Eureka包含两个组件:Eureka Server和Eureka Client。

阅读更多

服务注册中心介绍

服务注册中心

什么是服务注册中心

所谓服务注册中心就是在整个的微服务架构中单独提出一个服务,这个服务不完成系统的任何的业务功能,仅仅用来完成对整个微服务系统的服务注册和服务发现,以及对服务健康状态的监控和管理功能。

阅读更多

SpringCloud介绍及环境搭建

什么是SpringCloud

官方定义

Spring Cloud provides tools for developers to quickly build some of the common patterns in distributed systems (e.g. configuration management, service discovery, circuit breakers, intelligent routing, micro-proxy, control bus). Coordination of distributed systems leads to boiler plate patterns, and using Spring Cloud developers can quickly stand up services and applications that implement those patterns. ——-[摘自官网]

阅读更多

微服务介绍

  • 版本:Hoxton SR9

In short, the microservice architectural style is an approach to developing a single application as a suite of small services(一系列微小服务), each running in its own process(运行在自己的进程里) and communicating with lightweight mechanisms, often an HTTP resource API. These services are built around business capabilities(围绕自己的业务开发) and independently deployable(独立部署) by fully automated deployment machinery. There is a bare minimum of centralized management of these services(基于分布式管理), which may be written in different programming languages and use different data storage technologies. —–[摘自官网]

阅读更多

Swagger简介

引言

相信无论是前端还是后端开发,都或多或少地被接口文档折磨过。前端经常抱怨后端给的接口文档与实际情况不一致。后端又觉得编写及维护接口文档会耗费不少精力,经常来不及更新。其实无论是前端调用后端,还是后端调用后端,都期望有一个好的接口文档。但是这个接口文档对于程序员来说,就跟注释一样,经常会抱怨别人写的代码没有写注释,然而自己写起代码起来,最讨厌的,也是写注释。所以仅仅只通过强制来规范大家是不够的,随着时间推移,版本迭代,接口文档往往很容易就跟不上代码了。

阅读更多