This is a URL shortener proof-of-concept.
To try the "production" version deployed on Heroku, run make prodpost
. This will post a URL (with curl
) to the app and it should return a short URL. Visiting the short URL should redirect to the original one:
NOTE: the Heroku dyno might be in a sleeping state, so the first request might take a few seconds.
make prodpost
Posting https://xkcd.com/1313?long-long-long-url to the shortener service..
The resulting short URL:
https://urlshrtr.herokuapp.com/2
curl https://urlshrtr.herokuapp.com/2
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
<title>Redirecting...</title>
<h1>Redirecting...</h1>
<p>You should be redirected automatically to target URL: <a href="b'https://xkcd.com/1313?long-long-long-url'">b'https://xkcd.com/1313'</a>. If not click the link.
Python3 is required for the code to run.
To install the dependencies:
make install
make run
make post
Posting https://xkcd.com/814 to the shortener service..
The resulting short URL:
http://127.0.0.1:5000/1
- Language: Python
- Web framework: Flask
- Data store: Redis
- Cloud platform: Heroku
Things related to the code that would be essential in a production setting:
- Testing is only for the happy path - edge cases should be tested
- Logging is minimal. More verbose logging would be beneficial.
- Exception handling is not very thorough.
Things related to the deployment of the service:
- load balancing - such a service must have multiple replicas behind a load balancer in production.
- monitoring - request rate, error rate, request latency, Redis memory usage would be some aspects which would have to be monitored
- rate limiting would be nice (based on user agent, IP, or other fingerprints)