all4you / sentinel-tutorial Goto Github PK
View Code? Open in Web Editor NEWSentinel 教程,包括原理分析,源码阅读,实战分享
License: Apache License 2.0
Sentinel 教程,包括原理分析,源码阅读,实战分享
License: Apache License 2.0
没有认为设置contextName时,使用呢默认的:Constants.CONTEXT_DEFAULT_NAME(sentinel_default_context)
if (context == null) { // Using default context. context = InternalContextUtil.internalEnter(Constants.CONTEXT_DEFAULT_NAME); }
如下图在NodeSelectorSlot中,通过context.getName()获取DefaultNode
` DefaultNode node = map.get(context.getName());
if (node == null) {
synchronized (this) {
node = map.get(context.getName());
if (node == null) {
node = new DefaultNode(resourceWrapper, null);
HashMap<String, DefaultNode> cacheMap = new HashMap<String, DefaultNode>(map.size());
cacheMap.putAll(map);
cacheMap.put(context.getName(), node);
map = cacheMap;
// Build invocation tree
((DefaultNode) context.getLastNode()).addChild(node);
}
}
}
context.setCurNode(node);
fireEntry(context, resourceWrapper, node, count, prioritized, args);`
很多关键的流程和逻辑介绍详情图片看不到,希望整理下,这样理解起来更快,谢谢
谢谢作者写的难得的精彩的分析Sentinel源码的文章,获益匪浅,非常感谢!!!
关于这段话
原因是,我们这里测试的代码使用了多线程,注意看 threadCount 的值,一共有32个线程来模拟,而在RunTask的run方法中执行资源保护时,即在 SphU.entry 的内部是没有加锁的,所以就会导致在高并发下,pass的数量会高于20。
这里说没有锁导致了高并发的限流和期望值不一样
问
这算是sentinel的bug
还是说 SphU.entry 这个api并不是为多线程场景准备的
属于错误用法 而正确的用法就是在单线程下使用 SphU.entry
看acquireClusterToken的实现,是从ClusterMetricStatistics类维护的ConcurrentHashMap结构中获取,这么做能否实现集群流控(限制总QPS)呢?还是说client在获取tokenserver时,其路由规则可以保证请求一定被路由到某个server呢?
sentinel-tutorial/sentinel-practice/sentinel-cluster-flow-control/sentinel-cluster-flow-environment-build.md中
http://<ip>:<port>?getRules?type=flow应该改为:http://<ip>:<port>/getRules?type=flow
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.