The background,

Microservice circuit breaker: If Hystrix is used and HystrixException is found in logs, you know that either the called service has hung up or the service has timed out. Few people write the default return method after the service is not available, because the vast majority of calls between services is to rely on the data returned by the called party, without this data can not go on, can only throw exceptions unified processing.

The micro-service traffic limiting scheme, which has used Guava RateLimiter or Redis, can only think of which business is not important and write into which business. Similar to the semaphore scheme, it limits QPS and returns error information quickly when the quantity exceeds the limit, reducing the impact on the system and storage.

When learning that Soul gateway supports access to four traffic limiting schemes, it is found that Sentinel is the most popular one. Sentinel, as its name implies, actually overlaps some functions of gateway, that is, gateway component and flow control component are both for service governance and access to business services, and both also provide console management. I feel that foreign open source software open source the core part, similar to the console and other peripheral functions are reserved or not (such as Kafka), give users more imagination and expansion space, and can even produce many companies by packaging open source software to provide better integrated enterprise solutions. The open source products of domestic companies are full of functions and perfect solutions as far as possible, so that more enterprises can quickly apply them.

Second, the Sentinel

Website sentinelguard. IO /

Open source software is now focused on community building, and there are many participants, so the community building is perfect, forming a good cycle. In fact, this blog is more like a diary, which is recorded for myself. Sentinel learning does not need to look for information everywhere, but you can basically get started by reading the official website, running examples and codes. After learning one of the open source components of microservices (gateway, registry, configuration center, service invocation, etc.), you will be familiar with the basic pattern of open source systems and microservices.

Let’s start with two images on Github

The first is a functional architecture diagram with four blocks:

  • The vertical blue on the far right is a microservice ecosystem that can be accessed.
  • The yellow at the top is the console, real-time monitoring, machine discovery (service discovery, also functions as a registry, in fact the components either depend on the registry or want to be a registry themselves, because they have to deal with business services, how can they be governed without monitoring them), rule configuration. Soul Gateway. Gateway is the gateway to traffic. It’s best to see the traffic.
  • Green in the middle: Sentinel functionality embedded in the business service. Looking at so many features, Sentinel is not just Hystrix. You can see it from the definition on the official website.

With the popularity of microservices, stability between services becomes increasingly important. Sentinel takes flow as the entry point to protect the stability of service from multiple dimensions such as flow control, fusing downgrading and system load protection.

Sentinel: The Sentinel of Your Microservices

  • Purple at the bottom: configuration storage, you can see that traffic management rules can be stored in the registry, configuration center. This is also different from Soul, which uses MySQL. In fact, I also feel that Soul can use a registry or configuration center instead of storing the configuration in a database.

The second one is the integration of the surrounding ecosystem:

Discover gateways, cloud native, microservices, configuration centers, registries, and even RocketMQ to control consumption rates?

Here’s another comparison with Hystrix:

Sentinel uses semaphore isolation. In fact, thread pool isolation is not widely used in Sentinel. Too many thread pools will increase the overhead of thread switching.

Token bucket: Control access rate QPS, say 1000 tokens generated in 1s, then around 1000QPS

Semaphore: Controls concurrency, which is the maximum concurrency allowed to be accessed simultaneously by a race resource. This resource can be a method or block of code in Java code (the Sentinel resource concept also refers to this). It is more like controlling TPS, but it cannot control the flow accurately. It is related to the interface processing time.