← Openai Interview Insights

Openai·Software Engineer·Onsite - System Design / Architecture·Senior

Senior
Jun 2026

Summary

System design round at OpenAI for a SWE role. One question, URL shortener, which sounds straightforward until you actually have to talk through key generation, caching, and global read scaling in a coherent way.

Questions Asked (1)

Q1

Design a URL shortening service similar to Bit.ly or TinyURL, covering key generation, redirect handling, storage, caching, and scaling.

System DesignTechnical Trade-offsData Modeling
Author's notes

I started with the redirect path because that felt most concrete, then worked backwards to key generation.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Start by clarifying requirements (scale, read/write ratio, latency, custom aliases, expiration) and then walk through the high-level design: API endpoints, key generation, storage, caching, and redirection. Dive into trade-offs for each component, such as key generation strategies, database choices, and caching policies, and finally discuss scaling and reliability.

Pro tip: Emphasize the read-heavy nature of the system and how caching and CDN can drastically reduce latency and load on the database. Also, mention that you would use a 301 redirect for permanent links to enable browser caching, but a 302 for analytics tracking, showing awareness of trade-offs.

1. Clarify Requirements and Constraints

Ask about expected traffic (e.g., 100M new URLs per day, 10B redirects per day), read/write ratio, latency requirements, custom aliases, expiration, and analytics. This sets the scope and guides design decisions.

2. Design API and Key Generation

Define endpoints like POST /shorten and GET /{key}. Discuss key generation strategies: base62 encoding of a globally unique ID (e.g., from a distributed counter like Snowflake or a database auto-increment), or hashing with collision resolution. Consider custom aliases.

3. Choose Storage and Data Model

Select a database (e.g., NoSQL like DynamoDB for scalability, or SQL for strong consistency). Model the mapping: short key -> long URL, with metadata like creation time, expiration, and user ID. Discuss indexing and partitioning.

4. Implement Caching and Redirection

Use a cache (e.g., Redis or Memcached) to store hot URLs, reducing database load. For redirection, use HTTP 301 (permanent) or 302 (temporary) based on analytics needs. Consider CDN for edge caching.

5. Address Scaling and Reliability

Scale horizontally with load balancers, shard the database, and use read replicas. Ensure high availability with replication and failover. Discuss rate limiting, analytics, and cleanup of expired URLs.

Key Points to Mention

  • Key generation: base62 encoding of a distributed unique ID (e.g., Snowflake) vs. hash-based with collision handling.
  • Storage: choice between SQL and NoSQL, data model with short key as primary key, and partitioning strategy.
  • Caching: use Redis/Memcached for hot URLs, cache eviction policies (LRU), and CDN for global low-latency redirects.
  • Redirection: HTTP 301 vs 302 trade-offs (browser caching vs. analytics), and handling 404 for invalid keys.
  • Scaling: horizontal scaling of app servers, database sharding, read replicas, and rate limiting to prevent abuse.
  • Additional features: custom aliases, expiration, analytics, and security (e.g., preventing malicious URLs).

AI-generated suggestions, not part of the candidate's original notes. May be inaccurate — verify before relying on them.