Which threadpool should be used to execute expensive cpu operations inside a Spring Cloud Gateway Filter?

Viewed 334

In general, it is best to avoid any blocking computation in Spring Cloud Gateway.

However, there might be some [blocking non IO] expensive operations like encryption/decryption of certain payloads, etc.

Based on my investigation so far, I've found 2 thread pools from a live Spring Cloud Gateway App.

  • reactor-http-epoll-* : seems like the event loop thread pool
  • boundedElastic-* : seems like a background thread pool

Q) What is the cost of executing expensive cpu computations in a boundedElastic thread pool vs event loop thread pool. Based on my understanding, we should absolutely avoid any blocking code on event loop thread pool.

Looks like by default all the filters run on event loop thread pool. So offloading to boundedElastic actually incurs the cost of thread switch.

0 Answers
Related