This is the 25th day of my participation in Gwen Challenge

What is a sentinel

Sentinel has been the core scene of Alibaba’s singles’ Day traffic drive for nearly 10 years

  • Service traffic limiting: When the system resources are insufficient to handle a large number of requests, the system limits the traffic or functions based on preset rules
  • Service meltdown: When a large number of requests and invocations of the target service time out or fail, the service caller directly executes the default local method for subsequent invocations of the service interface to avoid long-time blocking and affecting other services
  • Service degradation: To ensure the normal operation of core services in the face of a large number of requests, the priority of some services is reduced according to the actual service situation and traffic, and some services are not processed strategically or handled in a simple way

Sentinel is divided into two parts:

  • The core library (Java client) is independent of any framework/library, can run in all Java runtime environments, and has good support for frameworks such as Dubbo/Spring Cloud.
  • The Console (Dashboard) is based on Spring Boot and can be packaged to run directly without the need for additional application containers such as Tomcat.

Comparison with Hystrix:

Sentinel can be used in two ways:

  • Intrusive coupling to business code (not recommended)
// Resource names can use any string with business semantics, such as method names, interface names, or other uniquely identifiable strings.
try (Entry entry = SphU.entry("resourceName")) {
  // Protected business logic
  // do something here...
} catch (BlockException ex) {
  // Resource access blocked, traffic restricted or degraded
  // Do the corresponding processing here
}
Copy the code
  • Adaptive decoupling from the mainstream framework
Support Servlet <dependency> <groupId>com.alibaba.csp</groupId> <artifactId> Sentinel-web-servlet </artifactId> <version> X.Y.Z </version> </dependency> Support dubbo <dependency> <groupId>com.alibaba.csp</groupId> <artifactId> Sentinel-Dubo-Adapter </artifactId> <version> X.Y.Z </version> </dependency> Support for SpringCloud <dependency> <groupId>org.springframework.cloud</groupId> <artifactId>spring-cloud-starter-alibaba-sentinel</artifactId> </dependency>Copy the code

Sentinel Performance Report

Test environment CPU: Intel(R) Xeon(R) CPU E5-2650 V2 @ 2.60GHz (32 cores) OS: Linux 2.6.32-220.23.2.ali927.el5.x86_64 Java version:

java version "1.8.0 comes with _77"
Java(TM) SE Runtime Environment (build 1.8. 0 _77-b03)
Java HotSpot(TM) 64-Bit Server VM (build 25.77-b03, mixed mode)
Copy the code

JVM parameters: -xmn256m -XMx1024M -xx :+UseConcMarkSweepGC tests the comparison of Sentinel throughput with and without Sentinel access in single-threaded mode. We simulated the situation under different QPS by performing some CPU intensive operations, such as sorting small arrays.

It can be seen that when the stand-alone QPS is very large (20W+), the performance loss caused by Sentinel will be relatively large. In this case, the business logic itself is very time consuming, while Sentinel series of statistics, inspection operations will consume a certain amount of time. A common scenario is cache read operations.

Open Source vs. Paid

Function comparison:

Commercial AHAS fees