|
@@ -3,41 +3,42 @@ |
|
|
# Sentinel: Sentinel of Your Application |
|
|
# Sentinel: Sentinel of Your Application |
|
|
|
|
|
|
|
|
[![Travis Build Status](https://travis-ci.org/alibaba/Sentinel.svg?branch=master)](https://travis-ci.org/alibaba/Sentinel) |
|
|
[![Travis Build Status](https://travis-ci.org/alibaba/Sentinel.svg?branch=master)](https://travis-ci.org/alibaba/Sentinel) |
|
|
[![codecov](https://codecov.io/gh/alibaba/Sentinel/branch/master/graph/badge.svg)](https://codecov.io/gh/alibaba/Sentinel) |
|
|
|
|
|
|
|
|
[![Codecov](https://codecov.io/gh/alibaba/Sentinel/branch/master/graph/badge.svg)](https://codecov.io/gh/alibaba/Sentinel) |
|
|
[![Maven Central](https://img.shields.io/maven-central/v/com.alibaba.csp/sentinel-core.svg?label=Maven%20Central)](https://search.maven.org/search?q=g:com.alibaba.csp%20AND%20a:sentinel-core) |
|
|
[![Maven Central](https://img.shields.io/maven-central/v/com.alibaba.csp/sentinel-core.svg?label=Maven%20Central)](https://search.maven.org/search?q=g:com.alibaba.csp%20AND%20a:sentinel-core) |
|
|
[![License](https://img.shields.io/badge/license-Apache%202-4EB1BA.svg)](https://www.apache.org/licenses/LICENSE-2.0.html) |
|
|
[![License](https://img.shields.io/badge/license-Apache%202-4EB1BA.svg)](https://www.apache.org/licenses/LICENSE-2.0.html) |
|
|
[![Gitter](https://badges.gitter.im/alibaba/Sentinel.svg)](https://gitter.im/alibaba/Sentinel) |
|
|
[![Gitter](https://badges.gitter.im/alibaba/Sentinel.svg)](https://gitter.im/alibaba/Sentinel) |
|
|
|
|
|
|
|
|
## What Does It Do? |
|
|
## What Does It Do? |
|
|
|
|
|
|
|
|
As distributed systems become increasingly popular, the stability between services is becoming more important than ever before. Sentinel takes "flow" as breakthrough point, and works on multiple fields including **flow control**, **concurrency**, **circuit breaking** and **load protection**, to protect service stability. |
|
|
|
|
|
|
|
|
As distributed systems become increasingly popular, the reliability and stability between services is becoming more important than ever before. Sentinel takes "flow" as breakthrough point, and works on multiple fields including **flow control**, **concurrency**, **circuit breaking** and **load protection**, to protect service reliability. |
|
|
|
|
|
|
|
|
Sentinel has the following features: |
|
|
Sentinel has the following features: |
|
|
|
|
|
|
|
|
* **Rich applicable scenarios**: |
|
|
|
|
|
Sentinel has been wildly used in Alibaba, and has covered almost all the core-scenarios in Double-11 Shopping Festivals in the past 10 years, such as “Second Kill” which needs to limit burst flow traffic to meet the system capacity, message peak clipping and valley fills, degrading unreliable downstream applications, etc. |
|
|
|
|
|
|
|
|
- **Rich applicable scenarios**: |
|
|
|
|
|
Sentinel has been wildly used in Alibaba, and has covered almost all the core-scenarios in Double-11 (11.11) Shopping Festivals in the past 10 years, such as “Second Kill” which needs to limit burst flow traffic to meet the system capacity, message peak clipping and valley fills, degrading unreliable downstream applications, etc. |
|
|
|
|
|
|
|
|
* **Integrated monitor module**: |
|
|
|
|
|
Sentinel also provides real-time monitoring function. You can see the runtime information of a single machine in real-time, and the summary runtime info of a cluster with less than 500 nodes. |
|
|
|
|
|
|
|
|
- **Real-time monitoring**: |
|
|
|
|
|
Sentinel also provides real-time monitoring ability. You can see the runtime information of a single machine in real-time, and the aggregated runtime info of a cluster with less than 500 nodes. |
|
|
|
|
|
|
|
|
* **Easy extension point**: |
|
|
|
|
|
Sentinel provides easy-to-use extension points that allow you to quickly customize your logic, for example, custom rule management, adapting data sources, and so on. |
|
|
|
|
|
|
|
|
- **Widespread open-source ecosystem**: |
|
|
|
|
|
Sentinel provides out-of-box integrations with commonly-used frameworks and libraries such as Spring Cloud, Dubbo and gRPC. You can easily use Sentinel by simply add the adapter dependency to your services. |
|
|
|
|
|
|
|
|
|
|
|
- **Various SPI extensions**: |
|
|
|
|
|
Sentinel provides easy-to-use SPI extension interfaces that allow you to quickly customize your logic, for example, custom rule management, adapting data sources, and so on. |
|
|
|
|
|
|
|
|
## Documentation |
|
|
## Documentation |
|
|
|
|
|
|
|
|
See the [中文文档](https://github.com/alibaba/Sentinel/wiki/%E4%BB%8B%E7%BB%8D) for Chinese readme. |
|
|
See the [中文文档](https://github.com/alibaba/Sentinel/wiki/%E4%BB%8B%E7%BB%8D) for Chinese readme. |
|
|
|
|
|
|
|
|
See the [Wiki](https://github.com/alibaba/Sentinel/wiki) for full documentation, examples, operational details and other information. |
|
|
|
|
|
|
|
|
|
|
|
See the [Javadoc](https://github.com/alibaba/Sentinel/tree/master/doc) for the API. |
|
|
|
|
|
|
|
|
See the [Wiki](https://github.com/alibaba/Sentinel/wiki) for full documentation, examples, blog posts, operational details and other information. |
|
|
|
|
|
|
|
|
**If you are using Sentinel, please [leave a comment here](https://github.com/alibaba/Sentinel/issues/18) to tell us your use scenario to make Sentinel better :-)** |
|
|
|
|
|
|
|
|
**If you are using Sentinel, please [leave a comment here](https://github.com/alibaba/Sentinel/issues/18) to tell us your scenario to make Sentinel better :-)** |
|
|
|
|
|
|
|
|
## Quick Start |
|
|
## Quick Start |
|
|
|
|
|
|
|
|
Below is a simple demo that guides new users to use Sentinel in just 3 steps. It also shows how to monitor this demo using the dashboard. |
|
|
Below is a simple demo that guides new users to use Sentinel in just 3 steps. It also shows how to monitor this demo using the dashboard. |
|
|
|
|
|
|
|
|
### 1.Download Library |
|
|
|
|
|
|
|
|
### 1. Add Dependency |
|
|
|
|
|
|
|
|
**Note:** Sentinel requires Java 6 or later. |
|
|
**Note:** Sentinel requires Java 6 or later. |
|
|
|
|
|
|
|
@@ -53,10 +54,9 @@ If your application is build in maven, just add the following code in pom.xml. |
|
|
|
|
|
|
|
|
If not, you can download JAR in [Maven Center Repository](https://mvnrepository.com/artifact/com.alibaba.csp/sentinel-core). |
|
|
If not, you can download JAR in [Maven Center Repository](https://mvnrepository.com/artifact/com.alibaba.csp/sentinel-core). |
|
|
|
|
|
|
|
|
|
|
|
### 2. Define Resource |
|
|
|
|
|
|
|
|
### 2.Define Resource |
|
|
|
|
|
|
|
|
|
|
|
Wrap code snippet via Sentinel API: `SphU.entry("RESOURCENAME")` and `entry.exit()`. In below example, it is `System.out.println("hello world");`: |
|
|
|
|
|
|
|
|
Wrap code snippet via Sentinel API: `SphU.entry("resourceName")` and `entry.exit()`. In below example, it is `System.out.println("hello world");`: |
|
|
|
|
|
|
|
|
```java |
|
|
```java |
|
|
Entry entry = null; |
|
|
Entry entry = null; |
|
@@ -78,7 +78,7 @@ try { |
|
|
|
|
|
|
|
|
So far the code modification is done. |
|
|
So far the code modification is done. |
|
|
|
|
|
|
|
|
### 3.Define Rules |
|
|
|
|
|
|
|
|
### 3. Define Rules |
|
|
|
|
|
|
|
|
If we want to limit the access times of the resource, we can define rules. The following code defines a rule that limits access to the reource to 20 times per second at the maximum. |
|
|
If we want to limit the access times of the resource, we can define rules. The following code defines a rule that limits access to the reource to 20 times per second at the maximum. |
|
|
|
|
|
|
|
@@ -95,7 +95,7 @@ FlowRuleManager.loadRules(rules); |
|
|
|
|
|
|
|
|
### 4. Check the Result |
|
|
### 4. Check the Result |
|
|
|
|
|
|
|
|
After running the demo for a while, you can see the following records in `~/logs/csp/${appName}-metrics.log.xxx`. |
|
|
|
|
|
|
|
|
After running the demo for a while, you can see the following records in `~/logs/csp/${appName}-metrics.log`. |
|
|
|
|
|
|
|
|
``` |
|
|
``` |
|
|
|--timestamp-|------date time----|--resource-|p |block|s |e|rt |
|
|
|--timestamp-|------date time----|--resource-|p |block|s |e|rt |
|
@@ -106,7 +106,7 @@ After running the demo for a while, you can see the following records in `~/logs |
|
|
1529998908000|2018-06-26 15:41:48|hello world|20|19502|20|0|0 |
|
|
1529998908000|2018-06-26 15:41:48|hello world|20|19502|20|0|0 |
|
|
1529998909000|2018-06-26 15:41:49|hello world|20|18386|20|0|0 |
|
|
1529998909000|2018-06-26 15:41:49|hello world|20|18386|20|0|0 |
|
|
|
|
|
|
|
|
p stands for incoming request, block for intercepted by rules, success for success handled, e for exception, rt for average response time (ms) |
|
|
|
|
|
|
|
|
p stands for incoming request, block for blocked by rules, success for success handled by Sentinel, e for exception count, rt for average response time (ms) |
|
|
``` |
|
|
``` |
|
|
This shows that the demo can print "hello world" 20 times per second. |
|
|
This shows that the demo can print "hello world" 20 times per second. |
|
|
|
|
|
|
|
@@ -116,7 +116,7 @@ The working principles of Sentinel can be found in [How it works](https://github |
|
|
|
|
|
|
|
|
Samples can be found in the [sentinel-demo](https://github.com/alibaba/Sentinel/tree/master/sentinel-demo) module. |
|
|
Samples can be found in the [sentinel-demo](https://github.com/alibaba/Sentinel/tree/master/sentinel-demo) module. |
|
|
|
|
|
|
|
|
### 5.Start Dashboard |
|
|
|
|
|
|
|
|
### 5. Start Dashboard |
|
|
|
|
|
|
|
|
Sentinel also provides a simple dashboard application, on which you can monitor the clients and configure the rules in real time. |
|
|
Sentinel also provides a simple dashboard application, on which you can monitor the clients and configure the rules in real time. |
|
|
|
|
|
|
|
@@ -134,5 +134,4 @@ Contact us: sentinel@linux.alibaba.com |
|
|
|
|
|
|
|
|
## Contributing |
|
|
## Contributing |
|
|
|
|
|
|
|
|
Contributions are always welcomed! Please see [CONTRIBUTING](./CONTRIBUTING.md) for detailed guidelines. |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Contributions are always welcomed! Please see [CONTRIBUTING](./CONTRIBUTING.md) for detailed guidelines. |