General view of a micro architecture services:
Use dubbo + zookeeper simplified micro Services Architecture
dubbo is a distributed service framework is core framework Alibaba SOA service governance programs. zookeeper is an open source distributed coordination service, created by Yahoo, based on google chubby.
What do zookeeper
1. Data released / subscribe (Configuration Center: disconf)
2. Naming Service
3.master election (kafka, hadoop, hbase)
4. Distributed Queue
5. Distributed Lock
zookeeper properties
1. Sequential Consistency
Transaction requests initiated from the same client will eventually be applied in strict accordance with the order to the zookeeper
2. atomicity
All transaction requests processing results of the application on all machines across the cluster is consistent, that is, either all the machines across the cluster are successfully applied to a transaction,
All-or-none application
3. Reliability
Once the server has successfully applied a certain transaction data, and the client did respond, then the data across the cluster must be synchronized and preserved
4. The real-time
Once a transaction is successfully applied, the client will be able to immediately read data from the server to the latest state of affairs changed; (zookeeper only guarantee a certain time, near-real-time)
zookeeper as registry dubbo services, the two together can achieve the micro-service registration service, we found that health checks and load balancing, fault tolerance, dynamic configuration management functions.
zk configuration instructions
zoo.cfg profile analysis
tickTime = 2000 zookeeper smallest unit of time length (ms)
initLimit = 10 follower and leader node starts after the completion node data synchronization time
syncLimit = 5 leader and follower node node heartbeat maximum delay time
dataDir = / tmp / zookeeper zookeeper represents the directory server that stores the snapshot file
dataLogDir represents a storage path configuration zookeeper transaction log, the default directory specified in the dataDir
clientPort that the client and server to establish the connection port number: 2181
Code Description
1. Download ZK, open zk
Local window system downloaded: zookeeper-3.4.14, open zkServer.cmd in the bin directory files
2. Establish dubbo project
dubbo-api defined interfaces
dubbo-consumer1 consumer end
dubbo-provider provider 0
dubbo-provider1 Provider 1
After two open over the offer, you can check to verify the nodes of zk
20880 is a provider port, another port provider 20881
Consumer calls are defaults FailoverClusterInvoker, debug can see there are two nodes 20880,20881 callable
The final caller data obtained through load balancing strategy, call
Invoker invoker = this.select (loadbalance, invocation , copyinvokers, invoked);