Shorten My Link is an API to shortern URLs.
Make a POST
request to https://shorten-my-link.herokuapp.com/shorten_url
with the request body:
{
"url": "https://really-really-really-long-unwieldy-url.com"
}
The response will be:
{
"shortened_url": "https://shorten-my-link.herokuapp.com/<short_id>"
}
where <short_id>
is a random alphanumeric string. Navigate to https://shorten-my-link.herokuapp.com/<short_id>
in your browser and you will be re-directed to https://really-really-really-long-unwieldy-url.com
.
This API is currently written as a Python Django application, hosted on Heroku's free plan. Data is stored in PostgreSQL running on a separate server (also hosted on Heroku). There are multiple ways of scaling the API to production scale. These are, in increasing levels of scalability:
- Increase the server size and utilise ulti-threading.
- Deploy the application to multiple servers behind a load balancer (e.g. Amazon EC2 + Elastic Load Balancer).
- Elastically scale the number of servers to meet increasing demand.
- Add additional database replications on additional servers and balance load between them. For PostgreSQL, Slony and pgpool are useful tools for replication and connection pooling, respectively.
- Deploy multiple servers behind multiple load balancers.
- Use Memcached for caching recently created short urls.
An entirely different approach to scaling is to write the API as a set of functions to run as part of a serverless architecture, for example using AWS Lambda.
- Add more throrough logging and monitoring.
- Add more comprehensive error handling - the API is not handling some edge cases correctly at the moment.
- Add separate deployment configurations for production and developement environments.