-
Notifications
You must be signed in to change notification settings - Fork 1.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[New Feature] Add new configuration options which allows broker to use a bounded Jersey ThreadPool #10614
[New Feature] Add new configuration options which allows broker to use a bounded Jersey ThreadPool #10614
Conversation
Codecov Report
@@ Coverage Diff @@
## master #10614 +/- ##
============================================
+ Coverage 69.03% 70.40% +1.36%
+ Complexity 6499 5629 -870
============================================
Files 2106 2106
Lines 113010 113674 +664
Branches 17027 17216 +189
============================================
+ Hits 78015 80029 +2014
+ Misses 29515 28050 -1465
- Partials 5480 5595 +115
Flags with carried forward coverage won't be shown. Click here to find out more.
... and 183 files with indirect coverage changes 📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more |
pinot-spi/src/main/java/org/apache/pinot/spi/utils/CommonConstants.java
Outdated
Show resolved
Hide resolved
pinot-broker/src/main/java/org/apache/pinot/broker/api/resources/PinotClientRequest.java
Outdated
Show resolved
Hide resolved
2729796
to
cc7b404
Compare
...-broker/src/main/java/org/apache/pinot/broker/broker/BrokerManagedAsyncExecutorProvider.java
Outdated
Show resolved
Hide resolved
pinot-broker/src/main/java/org/apache/pinot/broker/broker/BrokerAdminApiApplication.java
Outdated
Show resolved
Hide resolved
...ker/src/test/java/org/apache/pinot/broker/broker/BrokerManagedAsyncExecutorProviderTest.java
Outdated
Show resolved
Hide resolved
...ker/src/test/java/org/apache/pinot/broker/broker/BrokerManagedAsyncExecutorProviderTest.java
Outdated
Show resolved
Hide resolved
pinot-spi/src/main/java/org/apache/pinot/spi/utils/CommonConstants.java
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks Christina for addressing all the feedback!
79e7221
to
04a4a2b
Compare
Runtime.getRuntime().availableProcessors() * 2; | ||
public static final String CONFIG_OF_HTTP_ASYNC_EXECUTOR_QUEUE_SIZE = | ||
"pinot.broker.http.async.executor.queue.size"; | ||
public static final int DEFAULT_HTTP_ASYNC_EXECUTOR_QUEUE_SIZE = |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
queue size actually is bounded by memory. but I think availableProcessors() * 2 is OK.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would the default queue size of availableProcessors() * 2 be too small? During spiky request we may drop requests prematurely?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi Jasper, I didn't test the default values so they might be small. Can you share what might be a better number here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@jasperjiaguo I set the default value to Integer.MAX_VALUE, let me know if this looks good to you. The change is in the last commit.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes that looks good to me. Thanks!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM otherwise
...-broker/src/main/java/org/apache/pinot/broker/broker/BrokerManagedAsyncExecutorProvider.java
Show resolved
Hide resolved
pinot-spi/src/main/java/org/apache/pinot/spi/utils/CommonConstants.java
Outdated
Show resolved
Hide resolved
pinot-common/src/main/java/org/apache/pinot/common/metrics/BrokerMeter.java
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM otherwize
Runtime.getRuntime().availableProcessors() * 2; | ||
public static final String CONFIG_OF_HTTP_ASYNC_EXECUTOR_QUEUE_SIZE = | ||
"pinot.broker.http.async.executor.queue.size"; | ||
public static final int DEFAULT_HTTP_ASYNC_EXECUTOR_QUEUE_SIZE = |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would the default queue size of availableProcessors() * 2 be too small? During spiky request we may drop requests prematurely?
04a4a2b
to
a0622ad
Compare
a0622ad
to
0175c27
Compare
Thanks @Jackie-Jiang , comments are all addressed. Can you help take another look. Thanks |
@MeihanLi Can you help update the pinot documentation to include this new feature? |
Thanks Jackie for merging it, documentation is updated here: pinot-contrib/pinot-docs#164 |
@MeihanLi By reading the pinot doc, I just realized that we already have a set of configs ( cc @apucher who has more context on how to config the rest server |
@Jackie-Jiang : Yeah I had added those. Those configs control the thread-pool for the sync APIs afaiu. We mainly use them for tuning the thread-pool size for the pinot-controllers. I think we don't really need to support that config for brokers. We could consider removing support for it to reduce confusion. |
[New Feature] Add new configuration options which allows broker to use a bounded Jersey ThreadPool
Currently Broker uses Jersey default unbounded thread pool to process async requests and it uses No-Op RejectedExecutionHandler.
When a broker is serving very high QPS, a significant amount of threads will be accumulated on the broker. We have seen ~25k threads accumulated in a short time because of this and brokers were taken down very quickly. This is also the root cause of #9019.
This PR
(1) Implements a custom provider
BrokerManagedAsyncExecutorProvider
by extendingThreadPoolExecutorProvider
, which will be automatically picked by Jersey. When async requests can not be accommodated, they will get rejected and customers will receive ERROR code 503 (Service Unavailable).(2) Add new configuration options below which allow us to use the bounded thread pool and allocate capacities for it. By default, it is disabled.
pinot.broker.enable.bounded.http.async.executor
pinot.broker.http.async.executor.max.pool.size
pinot.broker.http.async.executor.core.pool.size
pinot.broker.http.async.executor.queue.size
By enabling the new configs, endpoints POST /query/sql and GET /query/sql will be impacted.
Test
Tested locally, one example response for a rejected request is
The error log emitted by BrokerManagedAsyncExecutorProvider is:
2023/04/14 16:47:26.146 ERROR [BrokerManagedAsyncExecutorProvider] [grizzly-http-server-15] Task java.util.concurrent.FutureTask@dafa6aa[Not completed, task = java.util.concurrent.Executors$RunnableAdapter@74af7b05[Wrapped task = org.glassfish.jersey.server.ServerRuntime$AsyncResponder$2@58e4de25]] rejected from java.util.concurrent.ThreadPoolExecutor@1bebdf0b[Running, pool size = 1, active threads = 1, queued tasks = 1, completed tasks = 6]