Skip to main content
This lab walks you through running the provided URL-shortener service locally, creating a real short link, and generating traffic against it to observe how each redirect is recorded in Postgres. Follow the steps below — hints and full solutions are available in the lab if you need them.

What you’ll do

  • Start the application and its dependencies with Docker Compose.
  • Mint a short link via the /shorten endpoint.
  • Use the provided hammer script to send 200 requests to that short link.
  • Inspect the application logs (and Postgres) to confirm every request was recorded.

Prerequisites

  • Docker and Docker Compose installed
  • curl (or any HTTP client)
  • Access to the lab environment where the repository and hammer.sh script exist

Quick lab steps

  1. Start services:
  1. Mint a short link:
  1. Hammer the short link:
  1. Inspect logs to confirm every request hit Postgres.

Detailed example session

Start the services:
Mint a short link (example using curl):
Example response:
The service responds with a JSON payload containing the short code (for example, 2Bi). Use that returned code when running the hammer script. For example, if the service returned 2Bi, run:
That script will send 200 requests against the short link. Then inspect the application logs (or Postgres) to verify each request was recorded.
If your environment uses a different short code (for example some exercises may reference cat42), substitute that code when invoking ./hammer.sh. The important part is to target the actual short code returned by the /shorten endpoint.

Inspecting logs and Postgres

  • Watch the application logs printed to the terminal from docker compose up — you should see log lines for each redirect request.
  • Alternatively, connect to the Postgres container and query the table that stores hits (table name may vary by lab). Example:

Endpoints reference

Troubleshooting tips

  • If you get an unexpected short code, always use the returned code when running ./hammer.sh.
  • Ensure the app, redis, and pg services are healthy in docker compose ps before sending traffic.
  • If logs show errors connecting to Postgres, confirm network/service names in docker-compose.yml and that the DB has initialized.
Happy testing — this lab helps you observe real-world behavior where every redirect generates a database write, which is important when considering scalability and caching strategies.

Watch Video

Practice Lab