Skip to content

CloudHSM performance issue

0

HI,

I'm using CloudHSM (single instance of hsm1) with a Java application using the JCE provider (SDKv5). I created an instance of CloudHsmProvider in order to sign token generated by JOSE (https://connect2id.com/products/nimbus-jose-jwt)

Here is a pseudo code I have:

// create the Config object
var jceCfg = CloudHsmProviderConfig.builder()
// create the JCE provider
var cloudHsmProvider = new CloudHsmProvider(jceCfg);
// create the authenticator & signin
var authenticator = new JceAuthenticator(cloudHsmProvider, configuration.getCryptoUser(), configuration.getPassword(), caCert);
authenticator.login();
// Create a keyStore
CloudHsmKeyStore keyStore = new CloudHsmKeyStore(authenticator.getAuthProvider());

// Get PrivateKey reference
var key = (PrivateKey) keyStore.engineGetKey(new KeyAttributesMapBuilder()
                .put(KeyAttribute.LABEL, privateKeyLabel)
                .build());

// create the JOSE signer & sign the token
var signer = new RSASSASigner((PrivateKey) key, true);
signer.sign();

The sign method is using the java.security.Signature which is calling the com.amazonaws.cloudhsm.jce.provider.CloudHsmSignatureBase.engineInitSign com.amazonaws.cloudhsm.jce.provider.CloudHsmSignatureBase.engineSign methods under the hood.

With a single instance of my application using a single instance of the keyStore, I'm able to sign around 100 tokens per second using RS256. (multi thread context) but the documentation highlight a capacity of 1000 tps (https://docs.aws.amazon.com/cloudhsm/latest/userguide/performance.html).

I tried to create multiple instance of the CloudHsmKeyStore in my application but even with 10 keyStores, I can not do more than 100 signature per second.

If I create a second instance of my application, I can reach 200 signatures per second.

Is there any limitation with the JCE provider which prevent me to reach the 1000 tps mentioned in the online documentation ?

Thanks in advance for your feedback

2 Answers
5

Below what we can try to locate and fix the issue:

  • Use multiple crypto users: Create and log in with multiple CU accounts, each owning a copy of the key. This can help distribute load across sessions.
  • Parallelize across HSMs: The 1000 TPS figure assumes multiple HSMs in a cluster. With just one HSM, you're unlikely to hit that number. Consider scaling horizontally.
  • Use CaviumKey directly: If you're using standard JCE PrivateKey objects, you might be missing out on performance optimizations available with CaviumKey objects.
  • Profile with native SDK: If performance is critical, consider bypassing the JCE layer and using the native SDK or PKCS#11 interface directly. It’s more complex but gives you finer control.

https://aws.amazon.com/blogs/security/cloudhsm-best-practices-to-maximize-performance-and-avoid-common-configuration-pitfalls/

EXPERT

answered a year ago

0

Hey,

Hope you're keeping well.

With CloudHSM, the TPS numbers in the documentation are for a fully utilized cluster with multiple HSMs and parallel client sessions. A single hsm1.medium instance will cap throughput based on its own CPU and crypto engine limits, so you won’t see 1000 TPS from one HSM or one client session. To increase signing throughput, you need multiple HSMs in the cluster and ensure your client is opening multiple authenticated sessions to them in parallel. Also, avoid reusing a single CloudHsmKeyStore object across threads — create independent CloudHsmProvider or PKCS#11 sessions per thread to remove contention.

Thanks and regards,
Taz

answered a year ago

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.