Giter Club home page Giter Club logo

shortener's Introduction

URL shortener POC

This is a URL shortener proof-of-concept.

Details

Usage

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.

Running it locally

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

Implementation

  • Language: Python
  • Web framework: Flask
  • Data store: Redis
  • Cloud platform: Heroku

Shortcomings

code-related

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.

infra-related

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)

shortener's People

Contributors

samuelbalogh avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.