Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Java Keystore is giving performance issue? [duplicate]

We have developed an application to encrypt/decrypt a request/response from/to server. We were doing performance testing of encryption/decryption application where we have observed that encryption/decryption process is taking time, while many threads are doing it at the same time. To identify an issue, we have logged every methods that are part of encryption/decryption process. From logger we have found that Key Fetching process is taking 70-80% of time from overall time of process.

  1. We have used AES algorithm for encryption/decryption
  2. AES key is stored in key store with unique id.
  3. Before encryption/decryption process, we fetch AES key stored against unique id from key store & perform encryption/decryption.
  4. Performance is getting worse when key store size is getting increased.

On further analysis, we have found that Key store is internally using HashTable. Is this giving performance issue?

When Key store size is 2002 --- TPS is 85 Key store size is 14007 -- TPS is 38

Please help.

like image 933
Nirav Shah Avatar asked Feb 21 '26 23:02

Nirav Shah


1 Answers

I was facing this issue... and I have answered this on bellow post.

Issue related to execution speed varies with different operation system platform.

Jvm loads key store in memory. And its having hashtable collection as internal storage.

Hashtable is synchronized.

Whenever you perform get operation from key store, than it will return it from in-memory key store not from physical keystore. You can confirm it by using ("top" - %wa section) command in linux base OS.

Key store is using hashtable and it is the root cause behind performance decriment.

I have solved this issue by loading all keys from keystore into ConcurrentHashMap while initializing the project. and later on, All the read operation will be performed from MAP instead of keystore. And make sure that all write operation will be perform on both keystore and MAP.

Java Keystore.getKey() slow while Key store size Increase

Hope this will help..

like image 171
Nirav Chhatrola Avatar answered Feb 23 '26 13:02

Nirav Chhatrola