Title: SecureRandom causes high lock contention in heavy-volume environments · Issue #368 · dnsjava/dnsjava · GitHub
Open Graph Title: SecureRandom causes high lock contention in heavy-volume environments · Issue #368 · dnsjava/dnsjava
X Title: SecureRandom causes high lock contention in heavy-volume environments · Issue #368 · dnsjava/dnsjava
Description: We're using dnsjava in a high-volume environment. We've observed high lock contention related to the secure random number generation. Ultimately, the issue is that the JDK's NativePRNG has a synchronized block on the hot path in implNext...
Open Graph Description: We're using dnsjava in a high-volume environment. We've observed high lock contention related to the secure random number generation. Ultimately, the issue is that the JDK's NativePRNG has a synchr...
X Description: We're using dnsjava in a high-volume environment. We've observed high lock contention related to the secure random number generation. Ultimately, the issue is that the JDK's NativePRNG ...
Opengraph URL: https://github.com/dnsjava/dnsjava/issues/368
X: @github
Domain: Github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"SecureRandom causes high lock contention in heavy-volume environments","articleBody":"We're using dnsjava in a high-volume environment. We've observed high lock contention related to the secure random number generation. Ultimately, the issue is that the JDK's `NativePRNG` has a synchronized block on the hot path in `implNextBytes`.\r\n\r\nIn dnsjava, `SecureRandom` is used for header IDs and in `NioUdpClient`. The latter can be disabled [when it's safe] with `dnsjava.udp.ephemeral.use_ephemeral_port`.\r\n\r\nI wanted to document this problem but, because it probably doesn't affect a lot of people, I am not sure what should be done, if anything. We're using a fork that works around this and a couple of other problems.\r\n\r\nSome thoughts:\r\n- In the ideal world, Java would perhaps provide `ThreadLocalSecureRandom` that caches randomness at thread level to reduce pressure on `NativePRNG`. This would resolve the contention except in a highly-inefficient and unlikely scenario with short-lived threads.\r\n- If dnsjava makes secure random generation pluggable, heavy users could provide their own implementation that perform better under high concurrency.\r\n- Another property can be added to disable the use of `SecureRandom`, which might be safe when dnsjava is used with a local recursive resolver.\r\n\r\n","author":{"url":"https://github.com/ivanr-rs","@type":"Person","name":"ivanr-rs"},"datePublished":"2025-01-08T12:31:16.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":3},"url":"https://github.com/368/dnsjava/issues/368"}
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:c96778bc-da5a-617e-26bf-3f8cd237ae3b |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | BAF8:D68F0:95BEC0:CAD30D:6A62E9CF |
| html-safe-nonce | eeee4248f9b5f3a3f2b8c898a0e0ea7ddcae01bc6140f7ed4ec9973934175189 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJCQUY4OkQ2OEYwOjk1QkVDMDpDQUQzMEQ6NkE2MkU5Q0YiLCJ2aXNpdG9yX2lkIjoiNzk4OTc5MTU1OTMxNTAyNDMzNSIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | 589081b7c334254a3c01402a6636227e7e44ceb42ba8d11daa3d6295f8697a00 |
| hovercard-subject-tag | issue:2775281044 |
| github-keyboard-shortcuts | repository,issues,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/issues/show/dnsjava/dnsjava/368/issue_layout |
| twitter:image | https://opengraph.githubassets.com/96b3688b2ef7bcaff7f572c176a3080afc62092b40b587b273a6d30af3242a67/dnsjava/dnsjava/issues/368 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/96b3688b2ef7bcaff7f572c176a3080afc62092b40b587b273a6d30af3242a67/dnsjava/dnsjava/issues/368 |
| og:image:alt | We're using dnsjava in a high-volume environment. We've observed high lock contention related to the secure random number generation. Ultimately, the issue is that the JDK's NativePRNG has a synchr... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | ivanr-rs |
| hostname | github.com |
| expected-hostname | github.com |
| None | df33b1b61ee7b9a0af988199bfc3503c9c1acafb1f1d40e1f140ea7c84f890dd |
| turbo-cache-control | no-preview |
| go-import | github.com/dnsjava/dnsjava git https://github.com/dnsjava/dnsjava.git |
| octolytics-dimension-user_id | 6755615 |
| octolytics-dimension-user_login | dnsjava |
| octolytics-dimension-repository_id | 17084567 |
| octolytics-dimension-repository_nwo | dnsjava/dnsjava |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 17084567 |
| octolytics-dimension-repository_network_root_nwo | dnsjava/dnsjava |
| 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 | d41cd1bdb290013455c0ac430fa755621733f5eb |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width