Title: Thread pool tuning best practice suggestions? · graphql-java/java-dataloader · Discussion #129 · GitHub
Open Graph Title: Thread pool tuning best practice suggestions? · graphql-java/java-dataloader · Discussion #129
X Title: Thread pool tuning best practice suggestions? · graphql-java/java-dataloader · Discussion #129
Description: Thread pool tuning best practice suggestions?
Open Graph Description: Are there suggestions for general best practices when configuring/choosing a thread pool(s) to be used by batch loaders? I understand that thread pool selection and tuning is very much project spec...
X Description: Are there suggestions for general best practices when configuring/choosing a thread pool(s) to be used by batch loaders? I understand that thread pool selection and tuning is very much project spec...
Opengraph URL: https://github.com/graphql-java/java-dataloader/discussions/129
X: @github
Domain: patch-diff.githubusercontent.com
{"@context":"https://schema.org","@type":"QAPage","mainEntity":{"@type":"Question","name":"Thread pool tuning best practice suggestions?","text":"Are there suggestions for general best practices when configuring/choosing a thread pool(s) to be used by batch loaders?
\nI understand that thread pool selection and tuning is very much project specific, but knowing of any common gotchas or tips for common situations or common use cases would be very welcomed. In particular for scenarios where several batches (eg 100+ or 1000+) are expected to be run for a double data loader while running just as many for other data loaders that are running simultaneously.
","upvoteCount":1,"answerCount":1,"acceptedAnswer":{"@type":"Answer","text":"I don't think thread pooling policies are batch loader specific really. It always depends on your load profile as you say.
\nI think the style of your application architecture matters however. Will the calls during the batch load be reactive or imperative? eg will they block during batch loader call and hence use up the thread while it completes?
\nIf you are reactive then you should not have to worry about thread pools much as all. Use the \"Schedulers\" of you reactive framework (Spring Project Reactor / Quarkus Mutiny) and the event loop thread pools are set for you. Typically they end up with thread pools of cpu count * 2
\nIf you are using an imperative architecture and the thread blocks to get data then your need more threads. The number will be driven by the amount of work that needs to get done. You haven't outlined how many concurrent loads will be going on.
\nEach threads in the JVM costs something like 1MB of memory - so as you add more threads to the pool to get more concurrency you incur a fixed memory cost. If you add 1000s of threads it will hurt you in memory terms even if you get better concurrency.
\nSo unfortunately this typically means a testing mechanism to discover the right balance... eg adding more threads increase your concurrency but it also increases the memory usage and switching overhead costs. You have to discover via testing the point that gives the best return for the least resources
\nJDK 21 just came out and nominally this allows you to use virtual threads which are significantly cheaper to create and hence nominally each batch load could be a virtual thread. You would NOT use thread pooling in JDK 21 - you would use the new https://docs.oracle.com/en/java/javase/21/docs/api/java.base/java/util/concurrent/Executors.html#newVirtualThreadPerTaskExecutor()
","upvoteCount":1,"url":"https://github.com/graphql-java/java-dataloader/discussions/129#discussioncomment-7091668"}}}
| route-pattern | /_view_fragments/Voltron::DiscussionsFragmentsController/show/:user_id/:repository/:discussion_number/discussion_layout(.:format) |
| route-controller | voltron_discussions_fragments |
| route-action | discussion_layout |
| fetch-nonce | v2:da0fbf32-a4a6-a5a2-093e-9794c4de09d9 |
| current-catalog-service-hash | 9f0abe34da433c9b6db74bffa2466494a717b579a96b30a5d252e5090baea7be |
| request-id | 9848:30A82E:481801:66709F:696FA7F4 |
| html-safe-nonce | 242e6327a49de8c8a3d1b7813528efff99b6107d683fa255420fbe18341045b0 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI5ODQ4OjMwQTgyRTo0ODE4MDE6NjY3MDlGOjY5NkZBN0Y0IiwidmlzaXRvcl9pZCI6IjIyMTYyMDk4NjEwMTM2NDUzMDAiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | 252128f50dec1f05ab1a71bb1f0898677679d2175e421c6e361abaeb8d6ca124 |
| hovercard-subject-tag | discussion:5661120 |
| github-keyboard-shortcuts | repository,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/Voltron::DiscussionsFragmentsController/show/graphql-java/java-dataloader/129/discussion_layout |
| twitter:image | https://opengraph.githubassets.com/f0ea25848cd1bd6e4cfcb136be0e81203ed80aed94a55c961166aa6f45f30b9d/graphql-java/java-dataloader/discussions/129 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/f0ea25848cd1bd6e4cfcb136be0e81203ed80aed94a55c961166aa6f45f30b9d/graphql-java/java-dataloader/discussions/129 |
| og:image:alt | Are there suggestions for general best practices when configuring/choosing a thread pool(s) to be used by batch loaders? I understand that thread pool selection and tuning is very much project spec... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| hostname | github.com |
| expected-hostname | github.com |
| None | 0ca8d8c65612640b9a1a588b3eed68222ca723ed2d028b18fe81b28936d535eb |
| turbo-cache-control | no-preview |
| go-import | github.com/graphql-java/java-dataloader git https://github.com/graphql-java/java-dataloader.git |
| octolytics-dimension-user_id | 14289921 |
| octolytics-dimension-user_login | graphql-java |
| octolytics-dimension-repository_id | 97364654 |
| octolytics-dimension-repository_nwo | graphql-java/java-dataloader |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 97364654 |
| octolytics-dimension-repository_network_root_nwo | graphql-java/java-dataloader |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 95f60616ce2765d1114fe6da4af405a58c6d26d2 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width