You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Encryption performance improvement on Java client #23121
I searched in the issues and found nothing similar.
Motivation
We found that using encryption will add significant performance overhead and could be the bottleneck especially in high-throughput production/consumption.
The micro benchmark shows that MessageCryptoBc#encrypt throughput is only around 2k ops/s in below setting:
MessageCryptoBc uses AES-GCM for the data encryption.
Hotspot JVM has intrinsics to use hardware AES instruction from JDK8 and upwards for SunJCE security provider.
By switching AES-GCM cipher to use SunJCE provider instead of BouncyCastle provider, the throughput is improved by x23.
@hpvd decryption performance on consumer-side will be also improved
@ocadaruma This PR contains some improvements to consumer-side decryption performance: #25400. This impacts the case when there are multiple producers and multiple public keys used in the producers. Currently the decryption is very poor in this type of real-world scenario. If the decryption fails, it will retry with the next key that succeeds. CPU will be unnecessarily spent in these attempts. In the Java client implementation, the producer will use the same key for 4 hours before rotating the key. That's why it's useful to cache the decrypted key by producer name.
Activity
hpvd commentedon Aug 4, 2024
awsome finding. Do you also have a direct comparison of "no encryption" vs "encryption using SunJCE provider"?
ocadaruma commentedon Aug 4, 2024
@hpvd below is the pulsar-perf result on standalone pulsar.
hpvd commentedon Aug 4, 2024
@ocadaruma many thanks - this looks great! Are there other places in pulsar where this could be relevant?
ocadaruma commentedon Aug 4, 2024
@hpvd decryption performance on consumer-side will be also improved
lhotari commentedon Mar 26, 2026
@ocadaruma This PR contains some improvements to consumer-side decryption performance: #25400. This impacts the case when there are multiple producers and multiple public keys used in the producers. Currently the decryption is very poor in this type of real-world scenario. If the decryption fails, it will retry with the next key that succeeds. CPU will be unnecessarily spent in these attempts. In the Java client implementation, the producer will use the same key for 4 hours before rotating the key. That's why it's useful to cache the decrypted key by producer name.