The following contents are my own understanding, not guarantee correct, may be right, may also take you to the ditch, their screening.

For more details, see liveDemystify it – build your own service governance framework based on zero

segmentfault.com/l/15…

A long time ago, when I heard people share their architecture, I would always say, because of xyz, we do servitization, our company developed a service governance framework.

At that time, tiger body was one of the shocks, feeling on the phone to write down key words: “servitization”, “service governance”, “service governance framework”. Search immediately after return, feel very lofty on, do not understand, why should service change, what is service management after all? A lot of articles on the first of direct about their service governance NB, but for the new people there is always a feeling of a mirror, so I hope to set out from the evolution of the framework, step by step, I hope to let everyone suddenly enlightened.

General idea: the decoupling of services leads to the emergence of servitization, and the emergence of multiple sets of servitization leads to the emergence of code redundancy and inconvenient management, which ultimately leads to the emergence of service governance.

The emergence of servitization

Imagine a jingdong development path (all made up by me).

  1. Initially, it was A simple shopping website similar to EcShop, developed iteratively by A team. Suddenly one day the operation realized that we needed a community to increase the stickiness of users.
  2. At this time, JINGdong was already large enough and the code was very complex. The new team (Cname B) developed a community, but it was not appropriate to patch the development on the original basis, so we finally decided to develop a new system. Since it is the same company, there is no reason for users to re-register in the community, right? The user should be logged in at www.jd.com/login, and then the basic information of the user should be available at bbs.jd.com.
  3. How to get the basic information of users in the forum? In order to better understand the newcomers, I made up a scheme:

    • After the user logs in at www.jd.com/login, the server saves a symmetric encrypted cookie to the client*.jd.comUnder.
    • Then the bbs.jd.com server takes the cookie from the client and decrypts it to get a JSON string.{uid:xxxx,username:'xxx',token:'xxxx'}
    • Finally, the bbs.jd.com server side takes uid + token to an API provided by www.jd.com for verification. After verification, the user is considered to have logged in.
  4. Thus, team A and team B worked together happily for some time.
  5. With the development of business, accounts are becoming more and more complex. For example, we have more and more social accounts bound, many email addresses, mobile phone login, enterprise accounts, sub-accounts, membership levels and other services.
  6. We all know the development principle of high cohesion, low coupling. Finally, the old driver of A team deployed the code related to the original account independently. Assign the domain nameaccount.jd.com. In this way, users are unifiedaccount.jd.comLog in, called by both team A and team Baccount.jd.comThrough the Intranet IP address :port.

The occurrence of a disaster

One day, the account center cluster was attacked by ddos, and the IP address was directly blocked by the machine room. However, both team A and team B did not know that many requests were blocked in the authentication interface of users. As a result, there are more and more requests, and the timeout time is set to be long, so that websites are getting more and more jammed.

Both team A and Team B learned their lesson and made the following solutions:

  1. Perform periodic health checks on account center services, such as once a minute.
  2. If the service is not available, the state of the service is cached for 10 minutes, during which the health check continues. If the service is available, the state is changed to available.
  3. If a service is found to be unavailable, an exception is thrown instead of blocking and waiting.
  4. Three parties have added an alarm, if the service is not available, will receive an alarm.

As more services are extracted, more teams emerge

  1. Business continued to develop, the emergence of jingdong pharmacy, specializing in selling drugs, the need to call jingdong’s current financial system. Loop the logic above, the financial system is independent.
  2. Large pharmacies also call account center services and financial services.
  3. Also deploy the same fault-tolerant code that you used to have on the A and B teams.

Changes in service providers

  1. IP: the change of the port
  2. The code for all service consumers has been modified to use the new IP :port

Meeting meeting put forward service governance

  1. Now the code of the system is being used by each team of A/B/C/D, and the address update needs to be manually updated. Can we do that? The address of the service provider is updated, and it can be pushed to all service consumers.
  2. The service management done by A and B for the service of the account center is actually A set of general plan. Can we come up with A platform or service (the embryonic form of service governance)? A/B/C/D all rely on my service (the embryonic form of service governance) and manage each service through this service.
  3. That is, the current service governance is to manage each service, there are two functions, service registration, service subscription, service push.
  4. A service provider said, we will do a pressure test in a few days, you can not request us192.168.0.10You all ask192.168.0.11. Oh! So that’s the weight, so let’s set the weight of the former to zero, ok, all the service providers might want that. So service management also contracted.
  5. B the service provider says, you call us when you write the order192.168.0.12Call us when you check the order192.168.0.13or192.168.0.14. Oh! Isn’t that what we do with read-write separation? Ok, we add a routing function to service governance, the service provider just has to configure it dynamically, and we push it dynamically to the consumer.

Improvement of service governance

Organize the essence of the meeting:

  1. We service governance center, need a registry, statistics are who provide what services, and then consumers, when starting the service, like the registry to send requests, we need what services, registry push provider service information.
  2. Our service governance center needs a monitoring center to count The Times provided by each service, the time of service response and the health status of the service.
  3. Instead of using HTTP for communication between the service provider and the service consumer, we can use a custom protocol and encapsulate a set of RPC protocols. This way, we can call remote methods just like using local methods. Java is a hurdle every old driver can’t get around), it is better to use long connections between service providers and service consumers to reduce the time consumption and network I/O per connection request. This RPC protocol is also specified by our service governance.

That’s it!

Not enough, Tee. for more on this live streamDemystify it – build your own service governance framework based on zero

segmentfault.com/l/15…