Код: Выделить всё
resilience4j:
circuitbreaker:
instances:
studentService:
slidingWindowSize: 10
failureRateThreshold: 50
waitDurationInOpenState: 5000
permittedNumberOfCallsInHalfOpenState: 3
automaticTransitionFromOpenToHalfOpenEnabled: true
ratelimiter:
instances:
studentRateLimiter:
limitForPeriod: 10000
limitRefreshPeriod: 1s
timeoutDuration: 500ms
bulkhead:
threadpool:
instances:
studentService:
maxThreadPoolSize: 100
coreThreadPoolSize: 20
queueCapacity: 1000
server:
tomcat:
accept-count: 20000
max-threads: 400
min-spare-threads: 20
< /code>
Мои основные вопросы: < /p>
[list]
[*] Учитывая цель обработки не менее 150 000 запросов в секунду, каковы рекомендуемые значения для: < /li>
< /ol>
[list]
rateLimiter.limitForPeriodКод: Выделить всё
bulkhead.threadpool.maxThreadPoolSize[*]tomcat.max-threads
[*]tomcat.accept-count
2.How do these settings interact? For example, if RateLimiter allows 10,000 requests per second but Bulkhead only has 100 threads, will requests get rejected or queued? How to balance these limits to avoid losing requests?
[/list]
[*]How does the Tomcat thread pool relate to the Bulkhead thread pool? Should Tomcat threads be set higher or lower than Bulkhead threads?
[*]Will having a large number of Tomcat threads (e.g., 400 or more) cause high CPU or memory usage? How to tune this optimally for an 8-core server?
[*]What is the best way to queue or buffer requests if Bulkhead threads are busy, without dropping calls?
[*]Is using both RateLimiter and Bulkhead together beneficial, or will RateLimiter just add overhead?
[*]How can I effectively monitor and track the real-time usage of RateLimiter, Bulkhead, and Tomcat threads to tune the system accordingly?
[/list]
Код: Выделить всё
@GetMapping("/{id}")
@CircuitBreaker(name = "studentService", fallbackMethod = "getStudentFallback")
@RateLimiter(name = "studentRateLimiter")
public ResponseEntity getStudent(@PathVariable Integer id) {
return studentService.getStudentById(id)
.map(ResponseEntity::ok)
.orElse(ResponseEntity.notFound().build());
}
Подробнее здесь: https://stackoverflow.com/questions/796 ... threads-to