This property sets the maximum number of requests allowed to a HystrixCommand.run() method when you are using ExecutionIsolationStrategy.SEMAPHORE. If this maximum concurrent limit is hit then subsequent requests will be rejected. The logic that you use when you size a semaphore is basically the same as when you choose how many threads to add to a thread-pool, but the overhead for a semaphore is far smaller and typically the executions are far faster (sub-millisecond), otherwise you would be using threads. For example, 5000rps on a single instance for in-memory lookups with metrics being gathered has been seen to work with a semaphore of only 2. The isolation principle is still the same so the semaphore should still be a small percentage of the overall container (i.e. Tomcat) thread pool, not all of or most of it, otherwise it provides no protection.
时间: 2024-04-28 22:19:57 浏览: 61
这段话是关于HystrixCommand执行隔离策略为SEMAPHORE时设置的maxConcurrentRequests属性的说明。当达到此最大并发限制时,后续请求将被拒绝。调整信号量大小的逻辑与选择添加到线程池中的线程数的逻辑基本相同,但信号量的开销要小得多,通常执行速度也更快(亚毫秒级别),否则您将使用线程。例如,在内存查找时收集指标的单个实例上,5000rps已被看作使用仅为2的信号量可以工作。隔离原则仍然相同,因此信号量应该是整个容器(例如Tomcat)线程池的一小部分,而不是全部或大部分,否则它将不提供保护。
阅读全文