Orivel Orivel
Open menu

Design a URL Shortening Service for Global Read Traffic

Compare model answers for this System Design benchmark and review scores, judging comments, and related examples.

Login or register to use likes and favorites. Register

X f L

Contents

Task Overview

Benchmark Genres

System Design

Task Creator Model

Answering Models

Judge Models

Task Prompt

Design a production-ready URL shortening service similar to Bitly. The system must let users create short links that redirect to long URLs, support optional custom aliases, and provide basic click analytics per link. Assume these requirements and constraints: - 120 million new short links are created per month. - 1.5 billion redirects happen per month. - Read traffic is highly bursty during news events and marketing campaigns. - Redirect latency should be under 80 ms at the 95th percentile for users in North Ameri...

Show more

Design a production-ready URL shortening service similar to Bitly. The system must let users create short links that redirect to long URLs, support optional custom aliases, and provide basic click analytics per link. Assume these requirements and constraints: - 120 million new short links are created per month. - 1.5 billion redirects happen per month. - Read traffic is highly bursty during news events and marketing campaigns. - Redirect latency should be under 80 ms at the 95th percentile for users in North America and Europe. - Short links should continue working even if one data center goes down. - Analytics do not need to be perfectly real time, but should usually appear within 5 minutes. - Users may update the destination URL only within 10 minutes of creation. - Links can expire at an optional user-defined time. - Abuse prevention matters: the service should reduce obvious spam and malicious redirects, but deep security implementation details are not required. In your answer, provide: - A high-level architecture and main components. - The core data model and storage choices. - API design for creating links, resolving links, and reading analytics. - A scaling strategy for traffic growth and burst handling. - Reliability and disaster recovery approach. - Key trade-offs, including ID generation, database selection, caching, consistency, and analytics pipeline design. - A brief note on how you would monitor the system and detect failures.

Task Context

Assume a reasonable cloud environment with managed load balancers, object storage, queues or streams, distributed caches, and relational or NoSQL databases available. You may make additional assumptions if you state them clearly.

Judging Policy

A strong answer should present a coherent end-to-end architecture that matches the workload and latency goals, with sensible separation between write path, redirect path, and analytics path. It should justify storage and caching choices, address global or multi-region availability, and explain how the system handles bursts, failures, stale data, and eventual consistency. Good answers should discuss practical trade-offs rather than naming technologies without reasoning. They should cover API shape, data modeling, sc...

Show more

A strong answer should present a coherent end-to-end architecture that matches the workload and latency goals, with sensible separation between write path, redirect path, and analytics path. It should justify storage and caching choices, address global or multi-region availability, and explain how the system handles bursts, failures, stale data, and eventual consistency. Good answers should discuss practical trade-offs rather than naming technologies without reasoning. They should cover API shape, data modeling, scalability, reliability, and monitoring in a way that is internally consistent and implementable.

Answers

## URL Shortening Service Design ### 1. High-Level Architecture and Main Components The system will be composed of several microservices, deployed across multiple availability zones and regions for high availability and low latency. * **API Gateway:** Handles incoming requests, authentication, rate limiting, and routes requests to appropriate services. * **Link Creation Service:** Responsible for generating short URLs, storing them, and handling custom aliases. It interacts with the ID Generation Service and the Metadata Database. * **Link Resolution Service:** Handles incoming redirect requests. It fetc...

Show Full Answer

## URL Shortening Service Design ### 1. High-Level Architecture and Main Components The system will be composed of several microservices, deployed across multiple availability zones and regions for high availability and low latency. * **API Gateway:** Handles incoming requests, authentication, rate limiting, and routes requests to appropriate services. * **Link Creation Service:** Responsible for generating short URLs, storing them, and handling custom aliases. It interacts with the ID Generation Service and the Metadata Database. * **Link Resolution Service:** Handles incoming redirect requests. It fetches the long URL from the cache or database and performs the redirect. It also logs click events. * **Analytics Service:** Processes click logs, aggregates data, and provides analytics reports. * **ID Generation Service:** Generates unique short IDs for URLs. This can be a separate, highly available service. * **Click Logging Service:** A high-throughput service responsible for ingesting raw click events. * **Web UI/Admin Panel:** For users to create links, manage them, and view analytics. **Architecture Diagram (Conceptual):** ``` +-----------------+ +-----------------+ +-----------------------+ | Load Balancer |----->| API Gateway |----->| Link Creation Service | +-----------------+ +-----------------+ +-----------------------+ | | (Redirects) v +-----------------+ +-----------------+ +-----------------------+ | Load Balancer |----->| Link Resolution | +-----------------+ | Service | +-----------------+ | | (Click Events) v +-----------------------+ | Click Logging Service | +-----------------------+ | | (Raw Logs) v +-----------------------+ | Message Queue | +-----------------------+ | | (Processed Data) v +-----------------------+ | Analytics Service | +-----------------------+ | | (Analytics Data) v +-----------------------+ | Analytics Database | +-----------------------+ **Databases:** * **Metadata Database:** Stores short URL to long URL mappings, custom aliases, creation timestamps, expiration times, and user information. * **Analytics Database:** Stores aggregated click data per link. * **ID Generation Database/Service:** For generating unique IDs. **Caching:** * **Read Cache:** For frequently accessed short URLs to speed up redirects. **Message Queue/Stream:** * For decoupling click logging from the redirect path and enabling asynchronous processing for analytics. ``` ### 2. Core Data Model and Storage Choices **Metadata Database:** * **Choice:** A distributed NoSQL database like Cassandra or a sharded relational database (e.g., PostgreSQL with Citus) for scalability and availability. * **Schema:** * `links` table/collection: * `short_id` (string, primary key): The unique short identifier. * `long_url` (string): The original long URL. * `user_id` (string, optional): Identifier for the user who created the link. * `created_at` (timestamp): When the link was created. * `expires_at` (timestamp, optional): When the link expires. * `custom_alias` (string, optional, unique index): User-defined alias. * `updated_at` (timestamp, optional): Last update time (for the 10-minute update window). * `destination_updated_at` (timestamp, optional): Timestamp of the last destination URL update. **Analytics Database:** * **Choice:** A time-series database (e.g., InfluxDB, TimescaleDB) or a data warehouse (e.g., Snowflake, BigQuery) for efficient aggregation and querying of time-based data. * **Schema:** * `click_analytics` table/collection: * `short_id` (string, indexed). * `timestamp` (timestamp, indexed). * `country_code` (string, optional). * `device_type` (string, optional). * `aggregated_count` (integer): For pre-aggregated data. **ID Generation:** * **Choice:** A dedicated distributed ID generation service (e.g., using Snowflake algorithm or a database sequence with a dedicated service). This ensures uniqueness and high availability. **Click Logs:** * **Choice:** A high-throughput message queue (e.g., Kafka, AWS Kinesis) to buffer raw click events before they are processed by the Analytics Service. ### 3. API Design **Base URL:** `https://short.url/api/v1` **1. Create Link:** * **Endpoint:** `POST /links` * **Request Body:** ```json { "long_url": "https://example.com/very/long/url", "custom_alias": "my-custom-alias" // Optional "expires_at": "2023-12-31T23:59:59Z" // Optional } ``` * **Response Body:** ```json { "short_url": "https://short.url/xyz123", "long_url": "https://example.com/very/long/url", "custom_alias": "my-custom-alias" // If provided } ``` **2. Resolve Link (Redirect):** * **Endpoint:** `GET /{short_id}` or `GET /{custom_alias}` * **Logic:** The Link Resolution Service will handle this. It will look up the `short_id` or `custom_alias` in the cache first. If not found, it queries the Metadata Database. After fetching the `long_url`, it logs the click event and returns a 301 (Permanent Redirect) or 302 (Temporary Redirect) to the `long_url`. * **Abuse Prevention:** Basic checks for known malicious patterns or blacklisted URLs can be performed here. **3. Get Link Analytics:** * **Endpoint:** `GET /links/{short_id}/analytics` * **Query Parameters:** * `start_time` (timestamp, required) * `end_time` (timestamp, required) * `group_by` (string, optional, e.g., "day", "country") * **Response Body:** ```json { "short_id": "xyz123", "total_clicks": 1500, "clicks_over_time": [ {"timestamp": "2023-10-27T10:00:00Z", "count": 50}, {"timestamp": "2023-10-27T11:00:00Z", "count": 75} ], "clicks_by_country": [ {"country": "US", "count": 1000}, {"country": "EU", "count": 500} ] } ``` **4. Update Link Destination (within 10 mins of creation):** * **Endpoint:** `PUT /links/{short_id}` * **Request Body:** ```json { "long_url": "https://new.example.com/updated/url" } ``` * **Response:** 200 OK or error. ### 4. Scaling Strategy * **Read Traffic (Redirects):** * **Caching:** Aggressively cache `short_id` to `long_url` mappings in a distributed cache (e.g., Redis, Memcached) with a short TTL (e.g., 5-10 minutes) to handle bursts. Cache misses will hit the database. * **Database Sharding:** The Metadata Database will be sharded by `short_id` or a hash of it to distribute load. * **Read Replicas:** Use read replicas for the Metadata Database to offload read traffic. * **Global Distribution:** Deploy Link Resolution Service instances in multiple regions close to users. Use GeoDNS to route users to the nearest region. * **Write Traffic (Link Creation):** * **Stateless Services:** Link Creation Service instances should be stateless, allowing easy horizontal scaling. * **ID Generation Service:** Must be highly available and scalable to handle the rate of new link creations. * **Analytics Traffic:** * **Asynchronous Processing:** Use a message queue (Kafka, Kinesis) to buffer click events. This decouples the redirect path from analytics processing. * **Scalable Analytics Pipeline:** The Analytics Service can scale horizontally to process messages from the queue and update the Analytics Database. * **Data Warehousing:** For large-scale analytics, a data warehouse is more suitable than a traditional RDBMS. ### 5. Reliability and Disaster Recovery * **Multi-AZ Deployment:** All services and databases will be deployed across multiple Availability Zones within a region. * **Multi-Region Deployment:** For critical services (Link Resolution, API Gateway), deploy across multiple geographic regions. Use GeoDNS for failover. * **Data Replication:** Databases will have replication enabled (e.g., multi-master or primary-replica with automatic failover). * **Idempotency:** Ensure critical operations (like link creation) are idempotent to handle retries safely. * **Graceful Degradation:** If the Analytics Service is down, redirects should continue to function. If the Metadata Database is slow, cache performance might degrade, but redirects should still work if cached. * **Backups:** Regular automated backups of all persistent data. ### 6. Key Trade-offs * **ID Generation:** * **Centralized (e.g., Snowflake):** Guarantees uniqueness, good performance, but introduces a dependency on the ID service. Can be a single point of failure if not highly available. * **Database Auto-increment:** Simple, but can be a bottleneck and harder to scale across shards/regions. * **Random Hash:** Simpler to generate, but requires collision detection and might lead to longer IDs if not carefully designed. * **Chosen:** Distributed ID generation service (e.g., Snowflake-like) for balance of uniqueness, performance, and availability. * **Database Selection:** * **NoSQL (Cassandra):** Excellent for high write throughput and horizontal scalability, good for availability. Schema flexibility. Can be complex to manage. * **Relational (Sharded PostgreSQL):** Strong consistency, familiar SQL interface. Sharding adds complexity. * **Chosen:** Cassandra for Metadata (high write/read, availability) and a Time-Series DB/Data Warehouse for Analytics (query performance). * **Caching:** * **Cache Invalidation Strategy:** Cache-aside with TTL is common. For updates (within 10 mins), explicit invalidation is needed. For expiration, TTL handles it. * **Consistency vs. Availability:** Aggressive caching improves availability and latency but can lead to stale data if not invalidated properly. * **Chosen:** Cache-aside with short TTLs for `short_id` to `long_url` mappings. Invalidate on updates. * **Consistency:** * **Eventual Consistency:** Acceptable for analytics. For link resolution, strong consistency is preferred but can be relaxed with caching. * **Link Creation:** Strong consistency for `short_id` uniqueness. Custom aliases might have a slight delay in propagation across replicas. * **Chosen:** Eventual consistency for analytics. Strong consistency for ID generation and link creation uniqueness. Relaxed consistency for link resolution via caching. * **Analytics Pipeline:** * **Real-time vs. Near Real-time:** The requirement is ~5 mins. This is achievable with stream processing (e.g., Kafka Streams, Flink) or micro-batching. * **Complexity:** A full real-time pipeline is complex. A batch processing approach (e.g., daily aggregation) is simpler but doesn't meet the 5-minute requirement. * **Chosen:** Kafka + stream processing (e.g., Flink or Spark Streaming) for near real-time aggregation into the Analytics Database. ### 7. Monitoring and Failure Detection * **Key Metrics:** * **Latency:** P95/P99 latency for API Gateway, Link Creation, Link Resolution, and Analytics APIs. * **Error Rates:** HTTP 5xx and 4xx error rates for all services. * **Throughput:** Requests per second for link creation and resolution. * **Resource Utilization:** CPU, memory, network I/O, disk I/O for all services and databases. * **Cache Hit Rate:** For the read cache. * **Queue Depth:** For the message queue. * **Database Performance:** Query latency, connection counts, replication lag. * **Tools:** * **Metrics Collection:** Prometheus, Datadog, CloudWatch. * **Logging:** Centralized logging system (e.g., ELK stack, Splunk, CloudWatch Logs). * **Tracing:** Distributed tracing (e.g., Jaeger, Zipkin) to track requests across services. * **Alerting:** Alertmanager, PagerDuty for critical issues. * **Failure Detection:** * **Health Checks:** Implement deep health checks for all services and dependencies. * **Synthetic Monitoring:** Regularly ping critical endpoints (e.g., create link, resolve a known link) from external locations. * **Anomaly Detection:** Monitor metrics for sudden spikes or drops that deviate from normal patterns. * **Automated Rollbacks:** Configure CI/CD pipelines to automatically roll back deployments if critical alerts are triggered. * **Chaos Engineering:** Periodically inject failures (e.g., network latency, service outages) in a controlled environment to test resilience.

Result

#2

Winning Votes

0 / 3

Average Score

73
Judge Models OpenAI GPT-5.4

Total Score

69

Overall Comments

Answer A is coherent and covers most required areas, including architecture, data model, APIs, scaling, reliability, trade-offs, and monitoring. Its strengths are broad coverage and a sensible separation of redirect, creation, and analytics concerns. However, it stays fairly generic, does not quantify capacity planning, is weaker on global read-path optimization, and leaves some important implementation details underspecified such as multi-region consistency behavior, custom alias enforcement strategy, and how to meet the latency target under bursty global traffic. Some choices are also internally soft, such as suggesting either Cassandra or sharded PostgreSQL without clearly committing to one design.

View Score Details

Architecture Quality

Weight 30%
68

The architecture has the right major components and separation of concerns, but it remains high level and generic. It does not strongly optimize the hot redirect path for global latency beyond regional deployment and cache use, and the multi-region topology is not fully worked through.

Completeness

Weight 20%
71

It covers nearly all requested sections, including APIs, data model, scaling, reliability, trade-offs, and monitoring. However, some requirement-specific details are light, especially the 10-minute update rule enforcement, global failover behavior, and abuse prevention depth.

Trade-off Reasoning

Weight 20%
69

The answer lists several trade-offs and alternative technologies, but the reasoning is often broad rather than tightly connected to this system's exact workload and constraints. Some decisions remain ambiguous instead of landing on a clear chosen design.

Scalability & Reliability

Weight 20%
67

The answer correctly suggests stateless services, sharding, caching, queues, and multi-region deployment, but it lacks concrete throughput thinking and specific failure-mode handling. Disaster recovery is described in general terms without a clearly defined active-active or failover strategy.

Clarity

Weight 10%
76

The structure is easy to follow and broken into clear sections. However, parts read like a generic template, and some technology options and repeated patterns reduce precision.

Total Score

66

Overall Comments

Answer A presents a solid, well-structured design covering all required sections. It identifies the right components (API gateway, link creation, resolution, analytics pipeline, caching, message queue) and discusses trade-offs reasonably. However, it lacks quantitative grounding: there are no back-of-envelope calculations for RPS, no concrete discussion of CDN/edge caching for the sub-80ms latency goal, and the multi-region strategy is vague (GeoDNS mentioned but not elaborated). The 302 vs 301 redirect trade-off is not discussed. Cache invalidation for the 10-minute update window is mentioned but not deeply analyzed. The ID generation section lists options but the Snowflake choice is not fully explained in terms of encoding. Overall it is a competent but somewhat surface-level answer.

View Score Details

Architecture Quality

Weight 30%
65

A identifies the right components and separates write, redirect, and analytics paths correctly. However, it lacks a CDN/edge layer which is critical for the sub-80ms P95 latency goal, and the multi-region strategy is vague. The abuse prevention component is mentioned only briefly in the redirect path rather than as a dedicated creation-time check.

Completeness

Weight 20%
68

A covers all required sections (architecture, data model, API, scaling, reliability, trade-offs, monitoring) but misses the 302 vs 301 discussion, lacks capacity math, and does not address the CDN layer or the specific cache TTL strategy for the update window.

Trade-off Reasoning

Weight 20%
62

A lists trade-offs for ID generation, database selection, caching, consistency, and analytics pipeline, but the reasoning is often generic (e.g., 'Cassandra is good for high write throughput') without connecting back to specific system requirements. The 10-minute update window cache invalidation trade-off is underexplored.

Scalability & Reliability

Weight 20%
65

A mentions multi-AZ, multi-region, GeoDNS, read replicas, sharding, and Kafka for analytics decoupling. However, there are no numbers to validate the design, no discussion of DynamoDB on-demand vs provisioned, and the failover mechanism is vague. Graceful degradation is mentioned but not detailed.

Clarity

Weight 10%
70

A is well-organized with clear headings and bullet points. The ASCII diagram is a nice touch but is incomplete (the right side is cut off). The writing is clear but sometimes lists options without strong conclusions.

Total Score

86

Overall Comments

Answer A provides a very solid and comprehensive design for a URL shortening service. It correctly identifies the main components, separates the read, write, and analytics paths, and proposes sensible technology choices like Cassandra and Kafka. The design covers all the required aspects from the prompt, including scaling, reliability, and monitoring. Its main weakness is that it remains somewhat generic in its high-level strategy, for example, by mentioning 'multi-region deployment' without detailing a specific active-active implementation. The trade-off analysis is good but lacks the depth and nuance seen in the best designs.

View Score Details

Architecture Quality

Weight 30%
85

The architecture is well-structured with a clear separation of concerns into microservices. It correctly identifies the need for a message queue to decouple the analytics path. However, the multi-region strategy is described generically ('GeoDNS for failover') rather than detailing a specific active-active or active-passive implementation.

Completeness

Weight 20%
90

The answer is very complete, addressing all sections requested in the prompt, from architecture and data models to monitoring and trade-offs. All key requirements are covered.

Trade-off Reasoning

Weight 20%
80

The trade-off analysis is solid, covering key decisions like ID generation, database selection, and caching. The reasoning is logical and correct. However, it doesn't explore some of the finer, more practical nuances of the problem.

Scalability & Reliability

Weight 20%
85

The plan for scalability and reliability is strong, mentioning horizontal scaling, caching, database sharding, and multi-AZ/multi-region deployments. The concepts are all correct and well-explained.

Clarity

Weight 10%
90

The answer is very well-written and clearly structured. The use of headings, bullet points, and a conceptual diagram makes the design easy to follow and understand.

High-Level Architecture and Main Components The system is organized into several layers deployed across at least two geographic regions (US-East and EU-West) behind a global anycast DNS or a global load balancer such as AWS Global Accelerator or Cloudflare. 1. Edge and CDN Layer: A global load balancer routes users to the nearest regional cluster. A CDN or edge cache (Cloudflare Workers, CloudFront) caches popular redirect mappings at the edge to achieve sub-80ms P95 latency. 2. API Gateway and Rate Limiter: Each region runs an API gateway that handles authentication, rate limiting, and request routing. Rate l...

Show Full Answer

High-Level Architecture and Main Components The system is organized into several layers deployed across at least two geographic regions (US-East and EU-West) behind a global anycast DNS or a global load balancer such as AWS Global Accelerator or Cloudflare. 1. Edge and CDN Layer: A global load balancer routes users to the nearest regional cluster. A CDN or edge cache (Cloudflare Workers, CloudFront) caches popular redirect mappings at the edge to achieve sub-80ms P95 latency. 2. API Gateway and Rate Limiter: Each region runs an API gateway that handles authentication, rate limiting, and request routing. Rate limiting uses a sliding-window counter backed by Redis to throttle abusive creation patterns. 3. Link Creation Service: Stateless service behind the API gateway. Accepts long URLs, optional custom aliases, optional expiry, and returns a short code. Writes to the primary database and invalidates or warms the cache. 4. Redirect Service: The hottest path. Receives GET requests on short codes, looks up the destination URL (cache first, then database), issues an HTTP 301 or 302 redirect, and emits a click event to the analytics pipeline. Uses 302 redirects so the service always sees the request for analytics, but returns a Cache-Control header with a short TTL (e.g., 60s) so browsers and CDN edges can cache. 5. Analytics Pipeline: Click events are published to a distributed stream (Kafka or AWS Kinesis). A stream processor (Flink or Kafka Streams) aggregates clicks per link in tumbling windows of one minute and writes rollups to an analytics store. A simple API serves aggregated analytics. 6. Abuse Prevention Service: On link creation, the destination URL is checked against Google Safe Browsing API and an internal blocklist. A lightweight ML scorer flags suspicious patterns (bulk creation, known spam domains). Flagged links are held for review or rejected. 7. Expiry and Cleanup Worker: A periodic job (cron or scheduled Lambda) scans for expired links and soft-deletes them, removing them from the cache. Core Data Model and Storage Choices Primary Link Store: A distributed NoSQL database such as Amazon DynamoDB or Apache Cassandra. The table is keyed by short_code (partition key). Schema fields: short_code (string, primary key), long_url (string), user_id (string), created_at (timestamp), expires_at (timestamp, nullable), custom_alias (boolean), updated_at (timestamp). DynamoDB is chosen for its single-digit-millisecond reads, automatic multi-region replication via Global Tables, and managed scaling. Cassandra is an alternative for teams wanting to avoid vendor lock-in. Cache Layer: Redis Cluster (or ElastiCache) in each region. Cache entry: short_code -> long_url with a TTL matching the link expiry or a default of 24 hours. Cache-aside pattern: redirect service checks Redis first; on miss, reads from DynamoDB and populates Redis. Analytics Store: A time-series or columnar store. ClickHouse or Amazon Timestream stores per-link click aggregates with dimensions: short_code, timestamp_bucket, country, referrer, device_type. Pre-aggregated rollups at 1-minute, 1-hour, and 1-day granularity. User and Account Store: A relational database (PostgreSQL via RDS) stores user accounts, API keys, billing, and link ownership metadata. This is lower traffic and benefits from strong consistency and relational queries. API Design Create Short Link: POST /api/v1/links. Request body: long_url (required), custom_alias (optional), expires_at (optional). Response: 201 Created with short_code, short_url, created_at, expires_at. Errors: 409 Conflict if custom alias taken, 400 if URL invalid, 403 if abuse detected. Update Destination URL: PATCH /api/v1/links/{short_code}. Request body: long_url. Allowed only within 10 minutes of created_at. Response: 200 OK with updated record. Error: 403 if outside the 10-minute window or not the owner. Resolve (Redirect): GET /{short_code}. Response: 302 Found with Location header set to long_url. If expired or not found: 404. The redirect service also sets response headers for cache control. Read Analytics: GET /api/v1/links/{short_code}/analytics?start=...&end=...&granularity=hour. Response: 200 OK with array of time-bucketed click counts, top countries, top referrers. Delete Link: DELETE /api/v1/links/{short_code}. Soft-deletes the link and invalidates cache. ID Generation Strategy Short codes are 7 characters from a base-62 alphabet (a-z, A-Z, 0-9), giving roughly 3.5 trillion possible codes, far exceeding the expected link volume over many years. Generation approach: Each service instance is assigned a unique worker ID (from a coordination service or configuration). A Snowflake-like ID generator produces a 64-bit unique integer combining a timestamp component, worker ID, and sequence number. The integer is then base-62 encoded and truncated or padded to 7 characters. This avoids coordination on every write and guarantees uniqueness. For custom aliases, the service attempts an insert with a uniqueness constraint; on conflict it returns 409. Scaling Strategy for Traffic Growth and Burst Handling Steady-state math: 1.5 billion redirects per month is roughly 580 requests per second average, with peaks during news events potentially reaching 10-50x, so the redirect path must handle at least 30,000 RPS per region. Link creation at 120 million per month is about 46 RPS average. Redirect path scaling: The redirect service is stateless and horizontally scalable behind an auto-scaling group. Redis handles the vast majority of reads; DynamoDB on-demand capacity handles cache misses. The CDN edge cache absorbs a large fraction of repeat requests for viral links, reducing origin load. Burst handling: Auto-scaling policies based on CPU and request count with aggressive scale-out (add 50 percent capacity in 60 seconds). Redis cluster can be pre-scaled with read replicas. DynamoDB on-demand mode absorbs burst writes and reads without pre-provisioning. The CDN naturally absorbs burst read traffic for hot links. Creation path scaling: Less bursty but still auto-scaled. Writes go to the regional DynamoDB Global Table, which replicates asynchronously to other regions. Analytics pipeline scaling: Kafka partitions are keyed by short_code for parallelism. Flink consumer group scales horizontally. ClickHouse cluster can add shards for query throughput. Reliability and Disaster Recovery Multi-region active-active: DynamoDB Global Tables replicate data across US-East and EU-West with last-writer-wins conflict resolution. Both regions serve reads and writes. If one region fails, DNS health checks (Route 53 or equivalent) route all traffic to the surviving region within seconds. Redis replication: Each region has its own Redis cluster populated from the local DynamoDB replica. If Redis fails, the redirect service falls back to DynamoDB reads with slightly higher latency. Kafka durability: Kafka topics have replication factor 3 with min.insync.replicas=2. If the analytics pipeline lags, click events are retained in Kafka for at least 72 hours for replay. Backups: DynamoDB point-in-time recovery is enabled. PostgreSQL has automated daily snapshots with cross-region replication. ClickHouse data is backed up to S3 daily. Graceful degradation: If the abuse checking service is slow, creation requests proceed with a flag for async review rather than blocking. If the analytics pipeline is down, redirects continue unaffected; click events queue in Kafka. Key Trade-offs ID generation: Snowflake-style IDs avoid a centralized counter bottleneck but require worker ID coordination. Base-62 encoding of 64-bit IDs yields short, URL-safe codes. Trade-off: slightly longer codes (7 chars) than strictly necessary to avoid collisions and allow future growth. Database selection: DynamoDB chosen for managed scaling, low-latency reads, and built-in global replication. Trade-off: eventual consistency across regions (acceptable since link creation is not latency-critical across regions, and redirects in the same region are consistent). Cassandra would offer similar properties with more operational burden but no vendor lock-in. Caching: Cache-aside with Redis provides sub-millisecond reads for hot links. Trade-off: cache invalidation on URL updates within the 10-minute window requires explicit invalidation across regions, introducing a brief window of stale data (mitigated by short cache TTLs for recently created links, e.g., 30 seconds for links less than 10 minutes old). Consistency: The system favors availability and partition tolerance (AP in CAP terms). Redirect reads are eventually consistent, which is acceptable. The 10-minute update window is enforced at the application layer; in rare split-brain scenarios, a stale redirect could occur briefly. Analytics pipeline: Kafka plus Flink plus ClickHouse provides near-real-time analytics within the 5-minute SLA. Trade-off: this adds operational complexity. A simpler alternative would be writing click logs to S3 and querying with Athena, but that would not meet the 5-minute freshness requirement. 302 vs 301 redirects: 302 (temporary) is used so the service sees every click for analytics. Trade-off: slightly higher latency for repeat visitors compared to 301, but the CDN edge cache with a 60-second TTL mitigates this while still capturing most clicks. Monitoring and Failure Detection Metrics: Every service emits metrics to a time-series monitoring system (Prometheus plus Grafana, or CloudWatch). Key metrics include redirect P50, P95, and P99 latency; cache hit ratio (target above 95 percent); DynamoDB read and write consumed capacity; Kafka consumer lag; error rates by endpoint; link creation rate. Alerting: PagerDuty alerts on redirect P95 latency exceeding 80ms, cache hit ratio dropping below 90 percent, Kafka consumer lag exceeding 5 minutes (analytics SLA), error rate above 1 percent on any endpoint, and any region health check failure. Distributed tracing: OpenTelemetry traces across the redirect path (edge to cache to database to response) to diagnose latency regressions. Synthetic monitoring: Canary requests from multiple geographic locations continuously create and resolve short links, alerting if end-to-end latency or correctness degrades. Log aggregation: Structured logs shipped to a centralized system (ELK or CloudWatch Logs) for debugging and audit trails. Health checks: Each service exposes a health endpoint. The load balancer removes unhealthy instances. Cross-region health checks trigger DNS failover. Additional Assumptions: Users authenticate via API keys for link creation and analytics. Anonymous link creation is rate-limited by IP. The system runs on AWS but the design is portable. Short codes are case-sensitive. The service does not need to support billions of concurrent active links in the near term, but the 7-character code space allows growth to trillions.

Result

#1 | Winner

Winning Votes

3 / 3

Average Score

88
Judge Models OpenAI GPT-5.4

Total Score

86

Overall Comments

Answer B is strong, concrete, and well aligned with the workload and latency requirements. It presents a practical global architecture with edge caching, regional clusters, a stateless redirect path, asynchronous analytics, and explicit abuse controls. It gives useful scale math, clear API shape, detailed storage choices, and thoughtful trade-offs around 302 versus 301, cache invalidation, eventual consistency, and multi-region replication. Its main weakness is a potentially questionable statement about truncating or padding encoded Snowflake IDs to 7 characters, which could undermine uniqueness if interpreted literally, and a few choices are somewhat vendor-specific. Overall, it is more implementable and better tuned to the stated constraints.

View Score Details

Architecture Quality

Weight 30%
86

The architecture is well structured around the critical paths: edge or CDN, regional API and redirect services, cache, primary store, and asynchronous analytics. It directly targets the latency and burst requirements with edge caching and active-active regional service placement.

Completeness

Weight 20%
87

It addresses all requested areas with good coverage, including create, resolve, analytics APIs, update-window handling, expiration, abuse prevention, monitoring, and DR. It also includes useful additional assumptions and a delete API, which helps round out manageability.

Trade-off Reasoning

Weight 20%
85

Trade-offs are discussed concretely and tied to requirements, such as 302 versus 301 for analytics, DynamoDB versus Cassandra, cache staleness during the update window, and stream processing versus batch analytics. The reasoning is practical and shows awareness of operational consequences.

Scalability & Reliability

Weight 20%
88

This is a strong area for Answer B. It estimates average and peak traffic, designs for burst absorption using CDN, Redis, and on-demand scaling, and explains multi-region active-active behavior, queue durability, cache fallback, and graceful degradation in a concrete way.

Clarity

Weight 10%
84

The answer is organized, direct, and specific. It is easy to trace from requirements to design choices, and the prose stays focused on implementable decisions rather than broad cataloging of options.

Total Score

83

Overall Comments

Answer B is notably stronger across nearly all dimensions. It opens with concrete capacity math (580 RPS average, 30,000 RPS peak), which grounds all subsequent design decisions. It explicitly addresses the sub-80ms P95 latency requirement through CDN/edge caching and explains the 302 vs 301 trade-off with its analytics implications. The multi-region active-active strategy with DynamoDB Global Tables is specific and actionable. Cache TTL differentiation for recently-created links (30s for links under 10 minutes old) elegantly handles the update window consistency problem. The abuse prevention, expiry worker, and analytics pipeline are all more concretely specified. Monitoring thresholds are tied back to stated SLAs. The answer is internally consistent and implementable.

View Score Details

Architecture Quality

Weight 30%
85

B has a well-layered architecture: edge/CDN, API gateway, creation service, redirect service, analytics pipeline, abuse prevention, and expiry worker are all clearly separated. The CDN edge cache is explicitly tied to the latency SLA. The active-active multi-region design with DynamoDB Global Tables is concrete and coherent.

Completeness

Weight 20%
82

B covers all required sections and adds important details: capacity math, 302 vs 301 trade-off, CDN edge caching, differentiated cache TTLs for recently-created links, expiry worker, abuse prevention at creation time, and Kafka retention for replay. The additional assumptions section is also helpful.

Trade-off Reasoning

Weight 20%
83

B reasons through trade-offs with specificity: the 302 vs 301 choice is tied to analytics requirements and mitigated by CDN TTL; the cache TTL differentiation for recently-created links directly addresses the update window; DynamoDB vs Cassandra trade-offs include vendor lock-in; the analytics pipeline complexity vs S3/Athena simplicity is explicitly compared against the 5-minute SLA.

Scalability & Reliability

Weight 20%
84

B provides capacity math (580 RPS average, 30,000 RPS peak), specifies auto-scaling policies (50% capacity in 60 seconds), uses DynamoDB on-demand for burst absorption, and describes DNS health-check-based failover with specific timing. Redis fallback to DynamoDB on failure and Kafka 72-hour retention for replay are concrete reliability mechanisms.

Clarity

Weight 10%
78

B is clearly written in flowing prose with good structure. It is slightly denser than A but every paragraph carries substantive content. The lack of a diagram is a minor weakness, but the prose descriptions are precise enough to compensate.

Total Score

95

Overall Comments

Answer B presents an outstanding, production-ready design that demonstrates deep expertise. It excels by providing highly specific and well-justified implementation details, such as using a CDN edge layer for latency, DynamoDB Global Tables for a managed active-active multi-region setup, and a Snowflake-like ID generator. The trade-off reasoning is exceptionally strong, particularly the nuanced discussions on 301 vs. 302 redirects and cache invalidation strategies for recently updated links. The inclusion of back-of-the-envelope calculations for traffic further grounds the design in reality. This answer is not just correct; it's practical and insightful.

View Score Details

Architecture Quality

Weight 30%
95

The architecture is outstanding. It starts with a global edge/CDN layer, which is crucial for meeting the latency goals. The choice of a managed active-active multi-region setup using DynamoDB Global Tables is specific, modern, and perfectly suited to the requirements. The separation of the user/account store into a relational DB is also a practical and thoughtful detail.

Completeness

Weight 20%
95

This answer is extremely complete. It covers all prompt requirements in great detail and goes slightly further by explicitly defining an 'Abuse Prevention Service' and an 'Expiry and Cleanup Worker' as distinct components, and adding a helpful 'Additional Assumptions' section.

Trade-off Reasoning

Weight 20%
98

The trade-off reasoning is exceptional and a key differentiator. The discussion of 302 vs. 301 redirects for analytics purposes, the specific cache invalidation challenge for the 10-minute update window, and the clear articulation of favoring availability (AP in CAP) are all signs of deep, practical expertise.

Scalability & Reliability

Weight 20%
95

The scalability and reliability plan is more concrete and convincing. It starts with back-of-the-envelope calculations to quantify the scale required. It then proposes specific, robust solutions like DynamoDB on-demand capacity for bursts, aggressive auto-scaling policies, and a clear active-active disaster recovery strategy using Global Tables.

Clarity

Weight 10%
90

The answer is exceptionally clear and well-organized. The logical flow from the high-level architecture down to the specific trade-offs is easy to follow. The writing is concise and precise.

Comparison Summary

Final rank order is determined by judge-wise rank aggregation (average rank + Borda tie-break). Average score is shown for reference.

Judges: 3

Winning Votes

0 / 3

Average Score

73
View this answer

Winning Votes

3 / 3

Average Score

88
View this answer

Judging Results

Why This Side Won

Answer B wins because it provides a more specific, practical, and deeply reasoned design. While Answer A is very good and covers all requirements, Answer B's design choices are more concrete and modern (e.g., DynamoDB Global Tables for active-active multi-region). Its trade-off analysis is significantly more nuanced, especially the discussion of 301 vs. 302 redirects and caching strategies, which are critical details for this specific problem. B's inclusion of performance calculations and a clear edge caching strategy also makes its approach to meeting the strict latency requirements more convincing.

Why This Side Won

Answer B wins because it is more rigorous and complete across every criterion. It provides quantitative capacity estimates that justify design choices, explicitly addresses the latency SLA with CDN edge caching, gives a more concrete and actionable multi-region reliability strategy, handles the 10-minute update window cache invalidation problem with a specific solution, and ties monitoring alerts back to stated SLAs. Answer A covers the same topics but at a shallower level without the quantitative grounding or the nuanced trade-off analysis that makes B clearly superior.

Judge Models OpenAI GPT-5.4

Why This Side Won

Answer B wins because it is more concrete and operationally credible across the most important dimensions of this task: low-latency global redirects, burst handling, multi-region availability, near-real-time analytics, and practical trade-off discussion. It explicitly addresses edge caching, active-active regional deployment, capacity estimates, stream-based analytics, and failure behavior in a way that maps closely to the prompt. Answer A is solid but more generic and less precise about how the design meets the specific latency, burst, and disaster recovery constraints.

X f L