0
0
Microservicessystem_design~20 mins

API key management in Microservices - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
API Key Mastery
Get all challenges correct to earn this badge!
Test your skills under time pressure!
Architecture
intermediate
2:00remaining
Designing a scalable API key storage system

You need to design a system to store and validate API keys for millions of users in a microservices environment. Which architectural choice best supports fast validation and scalability?

ASend API keys to an external third-party service for validation on every request.
BStore API keys in a centralized relational database and query it synchronously for every request.
CUse a distributed in-memory cache (like Redis) to store API keys with TTL and validate keys from cache.
DStore API keys in local files on each microservice instance and read from disk on every request.
Attempts:
2 left
💡 Hint

Think about latency and load on the database when validating keys for every request.

🧠 Conceptual
intermediate
2:00remaining
API key rotation strategy

What is the best practice for rotating API keys to maintain security without disrupting service?

ARotate keys only when a security breach is detected.
BAllow old keys to remain valid for a grace period while new keys are issued and accepted.
CNever revoke old keys to avoid any service disruption.
DImmediately revoke old keys and force all clients to update simultaneously.
Attempts:
2 left
💡 Hint

Consider how to avoid downtime during key rotation.

scaling
advanced
2:00remaining
Handling API key validation under high load

Your API gateway validates API keys for millions of requests per second. Which approach best reduces latency and avoids bottlenecks?

AUse a local cache on each gateway instance with periodic synchronization from a central store.
BSend all validation requests to a single dedicated validation microservice.
CValidate API keys synchronously by querying the database for each request.
DDisable API key validation during peak load to improve throughput.
Attempts:
2 left
💡 Hint

Think about reducing network calls and avoiding single points of failure.

tradeoff
advanced
2:00remaining
Choosing between API key length and usability

Longer API keys increase security but reduce usability. What is the best tradeoff approach?

AUse short keys (e.g., 8 characters) to maximize usability even if security is weaker.
BUse no API keys and rely only on IP whitelisting.
CUse very long keys (e.g., 256 characters) to maximize security regardless of usability.
DUse moderately long keys (e.g., 32 characters) combined with HTTPS and rate limiting.
Attempts:
2 left
💡 Hint

Consider balancing security and user experience.

estimation
expert
2:00remaining
Estimating storage requirements for API keys

You expect 10 million active API keys, each 40 characters long. Each key record stores the key, user ID (8 bytes), creation timestamp (8 bytes), and status (1 byte). Estimate the approximate storage needed in gigabytes (GB) for all keys, assuming UTF-8 encoding (1 byte per character) and ignoring database overhead.

AApproximately 0.5 GB
BApproximately 2.0 GB
CApproximately 1.0 GB
DApproximately 4.0 GB
Attempts:
2 left
💡 Hint

Calculate total bytes per record and multiply by number of keys, then convert to GB (1 GB = 1,073,741,824 bytes).