In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-17 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)06/02 Report--
This article mainly explains the "use of Sentinel current restrictions", the content of the explanation is simple and clear, easy to learn and understand, the following please follow the editor's ideas slowly in depth, together to study and learn "the use of Sentinel current restrictions"!
Sentinel series tutorials-using Sentinel to limit current
Sentinel is produced by alibaba, aiming at the components of system load protection, it is widely used because of its rich means of traffic protection and a variety of traffic integer strategies. The following is an official introduction from Sentinel: with the popularity of microservices, stability between services is becoming more and more important. Sentinel is a lightweight flow control component oriented to distributed service architecture. It mainly takes traffic as the starting point, and helps you ensure the stability of micro-services from many dimensions, such as current limit, traffic shaping, circuit breaker degradation, system load protection and so on. Sentinel-wiki Sentinel GitHub wiki is interested in children's shoes can go to learn.
This paper takes Sentinel 1.6.3 as an example.
Introduction of sentinel-core
Com.alibaba.csp sentinel-core 1.6.3
Load rule information
Private static final String RESOURCE_NAME = "hello"; / * load current limit rules * / public static void loadRules () {List rules = new ArrayList (); FlowRule flowRule = new FlowRule (); flowRule.setResource (RESOURCE_NAME); / / Resource name flowRule.setLimitApp ("default"); / / default represents flowRule.setGrade (RuleConstant.FLOW_GRADE_QPS) for all applications; / / current limit threshold type flowRule.setCount (10) / / threshold rules.add (flowRule); FlowRuleManager.loadRules (rules);}
Add resource entry to handle current limit exception
/ * execution method * @ param hello * / public static void hello (String hello) {Entry entry = null; try {entry = SphU.entry (RESOURCE_NAME); log.info ("args hello value is {}", hello);} catch (Exception e) {if (FlowException.isBlockException (e)) {log.error ("block resourceName: {}", RESOURCE_NAME) }} finally {if (entry! = null) {entry.exit ();}
Simulation invocation test
Public static void main (String [] args) {loadRules (); for (int iTuno)
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.