Skip to content

A scalable, serverless URL shortening API using Go on Cloud Run for the backend, Firestore as the NoSQL database for storing URL mappings (original URL to short code), and Memorystore (Redis) for caching redirects to achieve sub-millisecond response times. It demonstrates serverless deployment, NoSQL integration, and caching for performance.

Notifications You must be signed in to change notification settings

sermachage/urlshort

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 

Repository files navigation

High-Performance URL Shortener

A scalable, serverless API for shortening URLs, built with Go on Cloud Run, Firestore for storage, and Redis (Memorystore) for caching. Handles 10K+ RPS with <100ms latency.

Architecture

sequenceDiagram
    participant C as Client
    participant CR as Cloud Run (Go App)
    participant R as Redis (Cache)
    participant F as Firestore (DB)

    Note over C, F: Shorten Flow
    C->>+CR: POST /shorten { "url": "https://example.com" }
    CR->>+F: Store {short_code, original_url, created_at}
    F-->>-CR: Ack
    CR-->>-C: { "short_url": "https://app.run.app/abc123" }

    Note over C, F: Redirect Flow (with Cache)
    C->>+CR: GET /abc123
    CR->>+R: GET abc123 (cache check)
    alt Cache Hit
        R-->>-CR: "https://example.com"
        CR-->>-C: 302 Redirect
    else Cache Miss
        R-->>-CR: Miss
        CR->>+F: Get doc by short_code
        F-->>-CR: {original_url}
        CR->>+R: SET abc123 "https://example.com" (TTL 1h)
        CR-->>-C: 302 Redirect
    end
Loading

About

A scalable, serverless URL shortening API using Go on Cloud Run for the backend, Firestore as the NoSQL database for storing URL mappings (original URL to short code), and Memorystore (Redis) for caching redirects to achieve sub-millisecond response times. It demonstrates serverless deployment, NoSQL integration, and caching for performance.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 2

  •  
  •  

Languages