When creating and validating JSON Web Tokens, choosing the appropriate cryptographic signing algorithm is critical. The two industry standards are HS256 (HMAC with SHA-256) and RS256 (RSA Signature with SHA-256).

HS256 is symmetric and blindingly fast, but requires sharing a secret key across every service. RS256 is asymmetric, enabling public verification at scale without exposing signing authority. Let's compare their mechanics, performance benchmarks, and architectural tradeoffs.

1. Symmetric vs. Asymmetric Cryptography

The core distinction comes down to the number of keys involved:

🔑 Key Architecture: Symmetric (HS256) vs Asymmetric (RS256)

Cryptographic Architecture
HS256 (SYMMETRIC) 1 Shared Secret for Both Signing & Verification Auth Server signs with: secret_key_123 All Microservices verify with: secret_key_123 ⚠️ Blast Radius: If 1 microservice leaks the secret, attackers forge tokens! RS256 (ASYMMETRIC) Private Key (Sign) + Public Key (Verify) Auth Server signs with: Private Key (Kept secret) Microservices verify with: Public Key / JWKS ✓ Zero Leak Risk: Public key cannot forge signatures!
Figure 1: RS256 isolates the signing private key strictly inside the identity provider, enabling safe, distributed verification across thousands of client microservices.
Key Distribution Architecture
HS256 (Symmetric):
Auth Server [Shared Secret: "k8#9!xP"] -----> Microservice A [Shared Secret: "k8#9!xP"]
                                        -----> Microservice B [Shared Secret: "k8#9!xP"]
                                        -----> Third-Party API [Shared Secret: "k8#9!xP"] (DANGEROUS!)

RS256 (Asymmetric):
Auth Server [Private Key: PEM]  -----> Signs token
Public Key Endpoint (JWKS)       -----> Microservice A [Public Key: PEM]
                                 -----> Microservice B [Public Key: PEM]
                                 -----> Third-Party API [Public Key: PEM] (SAFE!)

2. Technical Comparison Matrix

Criterion HS256 (HMAC-SHA256) RS256 (RSA-SHA256)
Key Architecture 1 shared secret key (symmetric) Keypair: Private key + Public key (asymmetric)
Minimum Recommended Key Size 256 bits (32 random bytes) 2048 bits (RSA modulus)
Signing Speed Extremely fast (~1,000,000 ops/sec per core) Moderate (~2,000 to 5,000 ops/sec per core)
Verification Speed Extremely fast (~1,000,000 ops/sec per core) Fast (~25,000 ops/sec per core)
Signature Size in Token 32 bytes (43 Base64URL characters) 256 bytes (342 Base64URL characters)
Total Token Size Compact (~250 to 450 bytes) Larger (~600 to 950 bytes)
Microservices Suitability Risky: any verifier can forge valid tokens Ideal: verifiers only have the read-only public key
JWKS Key Distribution Unsupported (cannot expose secret via HTTP) Standard via /.well-known/jwks.json

3. Why RS256 Is the Standard for Microservices

Consider a modern company with 20 microservices (Order Service, Billing Service, Notification Service, Analytics, etc.).

If you use HS256, all 20 microservices must possess the shared secret key to verify incoming tokens. If a vulnerability is found in the low-priority Analytics service and an attacker dumps its environment variables, the attacker now possesses the signing secret. They can forge administrative tokens with arbitrary permissions for the Billing and Database services!

With RS256, the private signing key resides exclusively in the Auth Server. The remaining 19 microservices download the public key from the standard JSON Web Key Set (JWKS) URL (e.g. https://auth.company.com/.well-known/jwks.json). Even if an attacker completely compromises 10 microservices, they only obtain the public key—they cannot forge a single new token.

4. The Performance Benchmark Reality

Developers often worry about the performance cost of asymmetric cryptography:

Unless your application processes over 100,000 requests per second per node, RS256 computational overhead will never be your bottleneck.

5. What About ES256 and EdDSA?

If you want the security of asymmetric keypairs with the compact footprint of HMAC, modern identity systems are adopting Elliptic Curve algorithms:

6. Which Algorithm Should You Choose?