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:926ee46a-5d2b-8fa8-18ab-288d687c832b |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | E7BA:FA21D:FFFF07:16E0E80:6A6354A5 |
| html-safe-nonce | b91ad8ab037aa575b21e17c97213069c9dc3af054f6aa37789741d93886acf6c |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJFN0JBOkZBMjFEOkZGRkYwNzoxNkUwRTgwOjZBNjM1NEE1IiwidmlzaXRvcl9pZCI6Ijc4Mjk2OTM1MzA5MTU0Mjc0OTMiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | 81826dc8e9e6f90c6e38acae0877335316c390266d0c1d1ea1148150a384dbd8 |
| 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 | 59e55daad7174ca59d63c6974d58276ccb5477442e550bebb3c035e1bef11c94 |
| 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 | 990295d92a4cc7b63fbbd83a046217cd7d77d49c |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width