Developing a URL Shortening Service (TinyURL)

Developing a URL Shortening Service (TinyURL)
Developing a URL Shortening Service (TinyURL)

CLOUD LABS



Developing a URL Shortening Service (TinyURL)

In this Cloud Lab, you’ll learn how to build a URL shortening service on AWS and how multiple fully managed AWS services help meet our application’s nonfunctional requirements.

10 Tasks

intermediate

2hr

Certificate of Completion

Desktop OnlyDevice is not compatible.
No Setup Required
Amazon Web Services

Learning Objectives

Hands-on experience deploying a URL shortener on Amazon Web Services (AWS)
Expertise in application load balancer traffic management
Ability to use Auto Scaling groups to automatically provision resources
Hands-on experience with AWS WAF and Shield for rate limiting

Technologies
DAX
EC2 logoEC2
DynamoDB logoDynamoDB
ALB logoALB
WAF
Cloud Lab Overview

A URL shortening service takes long URLs, making them shorter and easier to handle. When clicked, these shortened URLs forward users to their longer counterparts.

This Cloud Lab focuses on developing a highly available, scalable, and resilient URL shortening service using AWS. The initial step involves setting up a DynamoDB table and DAX cluster for caching and storing key pairs of long URLs and their short URL equivalents. You’ll then create a Flask application within your EC2 instance. Next, you’ll configure an Auto Scaling group to manage your EC2 instances. Lastly, you’ll use an Application Load Balancer to manage incoming traffic and implement rate limiting with WAF. 

After completing this Cloud Lab, you can deploy a fully functional, end-to-end URL shortening service, leveraging the power and scalability of AWS cloud services. The provisioned infrastructure is provided in the architecture diagram below for reference.

URL shortening system using AWS services
URL shortening system using AWS services

Why URL shorteners are a classic system design problem

URL shortening services look simple on the surface: take a long URL and return a short one. However, behind that simplicity lie numerous real-world backend challenges, including high read traffic, low latency, data durability, and reliability.

That’s why URL shorteners are a common teaching example. They condense several key system design ideas into a problem that’s easy to understand and extend.

The core components of a URL shortening system

Most URL shorteners include the same fundamental pieces:

  • API layer: An API receives requests to create short URLs and handles redirects when users access them.

  • ID generation: The system requires a reliable method to generate short, unique identifiers that won’t collide as usage increases.

  • Storage: Short URLs must be mapped to long URLs in a durable data store capable of handling high read traffic.

  • Redirection logic: When a user accesses a short URL, the system must resolve it quickly and redirect with minimal latency.

  • Scalability and availability: Because read traffic is typically much higher than write traffic, caching and horizontal scaling are critical.

Common design decisions and trade-offs

Building a URL shortener forces you to think about trade-offs:

  • ID strategy: Random strings vs. sequential IDs vs. hash-based approaches.

  • Storage choice: Key-value stores vs. relational databases.

  • Caching: Reducing database reads for popular links.

  • Expiration policies: Temporary vs. permanent links.

  • Analytics: Tracking clicks without slowing redirects.

There’s no single “right” design; the best choice depends on scale, traffic patterns, and reliability requirements.

How cloud platforms simplify the design

Cloud services reduce operational overhead by providing managed building blocks:

  • Managed databases for durable storage.

  • Serverless compute or containers for API logic.

  • Load balancers and routing for traffic management.

  • Monitoring and logging for visibility into usage and failures.

The important lesson isn’t which service you choose, it’s how the pieces fit together.

Why this pattern generalizes beyond URL shortening

Once you understand how a URL shortener works, the same ideas apply to:

  • Session management systems

  • Feature flag services

  • Referral and tracking links

  • Key-based lookup APIs

  • High-read, low-write backend services

It’s a small system with outsized learning value.

Cloud Lab Tasks
1.Introduction
Getting Started
2.Set Up the Network
Create a VPC
3.Set Up the Database and Cache
Create a DynamoDB Table
Create a DAX Cluster
4.Set Up the Server
Launch the EC2 Instance
5.Set Up Load Balancers
Create an Application Load Balancer
Create an Auto Scaling Group (ASG)
6.Add Rate Limiting
Create the Web ACL
7.Conclusion
Clean Up
Wrap Up
Labs Rules Apply
Stay within resource usage requirements.
Do not engage in cryptocurrency mining.
Do not engage in or encourage activity that is illegal.

Relevant Courses

Use the following content to review prerequisites or explore specific concepts in detail.

Hear what others have to say
Join 1.4 million developers working at companies like