为什么SphU类的entry方法要默认EntryType.OUT而不是EntryType.IN呢?

更多的情况 不是使用EntryType.IN 吗?默认EntryType.OUT 每次都需要显示指定EntryType.IN。这样设计是出于怎样的考虑?

提问2.png

原提问者GitHub用户liwen2555376

展开
收起
学习娃 2023-05-19 14:21:55 266 分享 版权
1 条回答
写回答
取消 提交回答
  • EntryType用于区分流量类型,即入口流量与出口流量,默认流量类型为出口流量的目的是为了保障这部分资源不会因为SystemRule系统自适应限流所影响,系统自适应限流只对入口流量做流控。比如Dubbo的调用链路,Consumer与Provider两个节点的系统指标冲高时,Consumer无需对出口流量做流控,因为系统的消耗并不是因为出口流量导致的,而Provider需要对入口流量做流控,防止更多流量流入进一步冲高系统指标。 见方法签名注释中对trafficType的解释。 /** * Record statistics and perform rule checking for the given resource. * * @param name the unique name for the protected resource * @param trafficType the traffic type (inbound, outbound or internal). This is used * to mark whether it can be blocked when the system is unstable, * only inbound traffic could be blocked by {@link SystemRule} * @param batchCount the amount of calls within the invocation (e.g. batchCount=2 means request for 2 tokens) * @return the {@link Entry} of this invocation (used for mark the invocation complete and get context data). * @throws BlockException if the block criteria is met */ Entry entry(String name, EntryType trafficType, int batchCount) throws BlockException;

    原回答者GitHub用户luffy0223

    2023-05-19 19:56:57
    赞同 展开评论
问答地址:

阿里云拥有国内全面的云原生产品技术以及大规模的云原生应用实践,通过全面容器化、核心技术互联网化、应用 Serverless 化三大范式,助力制造业企业高效上云,实现系统稳定、应用敏捷智能。拥抱云原生,让创新无处不在。

还有其他疑问?
咨询AI助理