Skip to content
❱ πŸ‡ URL shortener service is written in Scala using Akka-Http and Redis ❰
Scala Dockerfile
Branch: master
Clone or download
ziyasal Merge pull request #29 from scala-steward/update/specs2-core-4.6.0
Update specs2-core, specs2-mock to 4.6.0
Latest commit 5e752de Jul 15, 2019
Type Name Latest commit message Commit time
Failed to load latest commit information.
project Merge pull request #31 from scala-steward/update/sbt-native-packager-… Jul 15, 2019
src Update StatsServiceSpec.scala Nov 23, 2018
.gitignore init Nov 28, 2017
.travis.yml init Nov 28, 2017
Dockerfile Update Dockerfile Nov 29, 2017 Update Sep 24, 2018
UNLICENSE Update and rename LICENSE to UNLICENSE Jul 13, 2018
build.sbt Update specs2-core, specs2-mock to 4.6.0 Jun 30, 2019
docker-compose.yml docker-compose Nov 29, 2017

❱ ❰

URL shortener service

Build Status Coverage Status

Tech stack

Alternative solutions

We could use following short code gen also:

substr(base62(md5(url)), 6) = 62 ^ 6 //unique short urls



Run docker-compose, it will start api, redis and will expose api port to host.

docker-compose up

Sample usage

# Shorten
curl -i http://localhost:9001 -F "url="

# Call shortened url
for ((i=1;i<=100;i++)); do curl -i "http://localhost:9001/SEwuXHhBQw"; done

# Get Stats
curl -i "http://localhost:9001/stats/?url="

# returns: {"callCount":100}

Create executable

sbt packageBin


sbt test

Gatling Simulation

Simulation users count can be set in application.conf in test resources.

# terminal 1
sbt run

# Run simulation in terminal 2
sbt gatling:test gatling:latestReport

Coverage with Report

sbt clean coverage test coverageReport


  • Seperate read and write API's
  • Move statistics to different data store and API
  • Add DB support by having write master/replicas and have read replicas
  • Move hit counts to MapReduce job and generate them from the Web Server logs
  • Implement Authentication using JWT authentication protocol with OAuth2 authentication framework
  • API Documentation using swagger or similar
  • Add Host blackListing
  • Add Retry policies for Redis calls using Retry or similar one
  • Add Throttling using akka-http-contrib
  • Add Metrics support using akka-http-metrics

z i Ξ» a s a l.

You can’t perform that action at this time.