Consul服务注册与服务发现
Consul
https://www.consul.io/docs/internals/architecture.html
Consul is a service mesh solution providing a full featured control plane with service discovery, configuration, and segmentation functionality. Each of these features can be used individually as needed, or they can be used together to build a full service mesh.
Service Discovery: Clients of Consul can register a service, such as
apiormysql, and other clients can use Consul to discover providers of a given service. Using either DNS or HTTP, applications can easily find the services they depend upon.Health Checking: Consul clients can provide any number of health checks, either associated with a given service ("is the webserver returning 200 OK"), or with the local node ("is memory utilization below 90%"). This information can be used by an operator to monitor cluster health, and it is used by the service discovery components to route traffic away from unhealthy hosts.
KV Store: Applications can make use of Consul's hierarchical key/value store for any number of purposes, including dynamic configuration, feature flagging, coordination, leader election, and more. The simple HTTP API makes it easy to use.
Secure Service Communication: Consul can generate and distribute TLS certificates for services to establish mutual TLS connections. Intentions can be used to define which services are allowed to communicate. Service segmentation can be easily managed with intentions that can be changed in real time instead of using complex network topologies and static firewall rules.
Multi Datacenter: Consul supports multiple datacenters out of the box. This means users of Consul do not have to worry about building additional layers of abstraction to grow to multiple regions.
服务注册与发现
https://mp.weixin.qq.com/s/0OexlvVkr7Nxjl51p-L-Jg
Hi,大家好,我叫consul,翻译成中文叫做“领事”,其实我更喜欢叫自己为中介,因为我觉得自己做的事情和房产中介非常像。比如说想要卖房的房东到我这边登记,我将房屋信息登录到我的表格中(服务注册),有买家来咨询时,我再查询表格将符合条件的房子返回给买家(服务发现),平时我也要做点房源的维护工作,比如每隔一天就打电话问下房东:“你的房子还卖么?(服务健康检查)”。
我的作用主要是管理这些集群服务的配置,整体流程是这样子的:服务(进程)启动的时候把服务名和自己的IP、端口通过HTTP告诉我,我将这些信息记到自己的内存表格中,客户端调用时带上要查询的服务名通过HTTP发送给我,我再自己的内存表中找到叫这服务名的所有配置发送给客户端。
平时我还要做一些服务健康检查的事儿,在上面服务启动的时候,服务还要给我配置一个检查接口和检查频率等一些参数,我会按这些参数每隔一段时间,比如10秒钟去请求一下这个接口,如果不通,我就隔5秒再重试下,如果重试3次还不通,我就认定这个服务挂掉了,就从内存表格中删掉这个服务配置,不然客户端要请求到这个不通服务,我就罪过了。
consol优势
https://mp.weixin.qq.com/s/r9B15bdIzJnRJhj1OJhfLw
Consul 的优势:
使用 Raft 算法来保证一致性, 比复杂的 Paxos 算法更直接. 相比较而言, zookeeper 采用的是 Paxos, 而 etcd 使用的则是 Raft。
支持多数据中心,内外网的服务采用不同的端口进行监听。 多数据中心集群可以避免单数据中心的单点故障,而其部署则需要考虑网络延迟, 分片等情况等。 zookeeper 和 etcd 均不提供多数据中心功能的支持。
支持健康检查。 etcd 不提供此功能。
支持 http 和 dns 协议接口。 zookeeper 的集成较为复杂, etcd 只支持 http 协议。
官方提供 web 管理界面, etcd 无此功能。
综合比较, Consul 作为服务注册和配置管理的新星, 比较值得关注和研究。
https://www.imooc.com/article/284030
                    
                
                
            
        
浙公网安备 33010602011771号