A serverless URL shortener implementation built with Quarkus and deployed on AWS using a cloud-native architecture. The application demonstrates the use of serverless technologies for building scalable web applications.
This URL shortener is implemented using AWS serverless technologies. The application is built with Quarkus for performance and deployed using Infrastructure as Code (Terraform) on AWS.
Key Characteristics:
- Serverless architecture with no server management required
- Automatic scaling based on demand
- Cost-effective with pay-per-use pricing model
- Built with Quarkus framework for optimal performance
- Infrastructure as Code with Terraform for reproducible deployments
- Comprehensive monitoring and logging capabilities
The application follows a serverless, cloud-native approach using AWS services:
The application logic is implemented as a serverless function that scales automatically with demand. Configuration includes:
- Java 21 runtime (or native runtime for optimized performance)
- 1024MB memory allocation
- 30-second timeout for request processing
- Environment variables for configuration management
Handles HTTP routing and exposes the application endpoints with:
- Routes for URL shortening (
POST /shorten) and redirection (GET /{id}) - Integration with the Lambda function
- Deployment and staging management
- Custom domain support
Serverless NoSQL database for storing URL entries and click events:
url-entriestable: Stores shortened URLs and their original destinationsclick-eventstable: Tracks click analytics for each shortened URL- Provisioned capacity for predictable performance
When enabled, CloudFront provides:
- Global content delivery with low latency
- HTTPS enforcement for security
- Caching of API responses for improved performance
- Custom domain support with SSL certificates
- IAM roles and policies for secure resource access
- CloudWatch for comprehensive logging and monitoring
- URL Shortening: Convert long URLs to short, shareable links
- Click Analytics: Track how many times each shortened URL is accessed
- Custom Domains: Support for custom domains via CloudFront
- High Availability: Built on AWS serverless services for maximum uptime
- Auto-scaling: Automatically scales to handle traffic spikes
- Cost Efficient: Pay only for what you use with serverless pricing
The serverless architecture was selected for this implementation based on the following considerations:
- Operational Efficiency: No server management required, reducing operational overhead
- Scalability: Automatic scaling to handle varying traffic patterns
- Cost Optimization: Pay-per-use pricing model aligns with usage patterns
- Performance: Quarkus framework provides fast startup times and low memory usage
- Deployment Automation: Terraform enables reproducible, version-controlled deployments
- Java 21+
- Maven
- AWS CLI configured
- Terraform 1.0+
You can run your application in dev mode that enables live coding using:
mvn quarkus:devThe application can be packaged using:
mvn packageYou can create a native executable using:
mvn package -DnativeOr, if you don't have GraalVM installed, you can run the native executable build in a container using:
mvn package -Dnative -Dquarkus.native.container-build=trueThe application is deployed using Terraform with the following AWS resources:
- Lambda function for the application
- API Gateway for HTTP routing
- DynamoDB tables for data storage
- IAM roles and policies for permissions
- CloudFront distribution (optional) for CDN
- CloudWatch log groups for monitoring
To deploy the application, use the Terraform configuration in the terraform/ directory.