This was basically a whole system design interview packed into one question.
Start by clarifying requirements and constraints, then design the API contracts and versioning strategy before diving into the internals. Structure your answer around the key areas: API design, entropy/PRNG choices, multi-tenancy, security, observability, scaling, and SLAs. Emphasize trade-offs and justify decisions based on the use case (e.g., cryptographic vs. standard PRNG).
Pro tip: Demonstrate awareness of SoFi's regulated fintech environment by prioritizing security, compliance, and auditability in your design. Mention that you would separate the control plane (API management, quotas) from the data plane (number generation) for scalability and isolation.
Ask questions to understand expected throughput, latency, security needs, and whether numbers must be cryptographically secure. Identify if reproducibility is required for testing or auditing.
Define REST endpoints (e.g., GET /v1/random?min=1&max=100&count=10) and streaming endpoints (e.g., WebSocket or SSE). Use URL versioning (e.g., /v1/) and include version in streaming handshake. Specify response formats, error codes, and idempotency.
For cryptographic security, use a CSPRNG seeded from a hardware entropy source (e.g., /dev/urandom, AWS KMS). For non-security use, a standard PRNG like Mersenne Twister with a seed for reproducibility. Explain when to use each.
Implement API keys or OAuth for authentication, per-tenant rate limiting and quotas using a token bucket or sliding window. Isolate tenants via separate namespaces or resource pools. Add DDoS protection, input validation, and audit logging.
Instrument with metrics (latency, error rates, throughput), logging, and tracing. Deploy stateless services behind a load balancer, auto-scale based on load, and use a CDN for static content. Define SLAs: e.g., 99.99% availability, p99 latency < 100ms for REST, < 200ms for streaming.
AI-generated suggestions, not part of the candidate's original notes. May be inaccurate — verify before relying on them.