Stop 15 · Portfolio & Interview PrepTopics · 8/10

System Design Basics

Part of the Java Roadmap

In short

Freshers aren't expected to design all of YouTube, but backend interviews often ask simple versions: how would you build a URL shortener or scale a Spring Boot app? Knowing the building blocks is enough to give a calm, sensible answer.

For backend roles, learn the basics of designing systems: client-server architecture, REST, databases, caching, load balancing and when to scale. Freshers are usually asked simple versions.

The jaadu in a station master's cap stands in a busy railway concourse, waving travellers towards several open ticket counters under a large display board.

Think of it like this

Running a railway station

When a station like New Delhi gets more passengers, it adds more ticket counters (more servers) with a guide sending people to the shortest queue (load balancer). Popular information like platform numbers goes on a big display board so nobody queues to ask (cache). The main records office (database) stays the single source of truth.

Watch it happen

A request in a simple scaled design

Client
Load balancer
App servers
Cache (Redis)
Database

1/5A user opens a short link like sho.rt/aB3x.

The big ideas

What you need to know

Scale out

Vertical scaling buys a bigger machine. Horizontal scaling adds more machines behind a load balancer, which needs stateless servers.

Cache hot reads

Redis or an in-memory cache in front of the database. Think about TTLs and what happens when data changes.

Pick storage on purpose

Relational for transactions and relationships, NoSQL for huge simple key lookups. Add read replicas and indexes before anything fancy.

Queues for slow work

Emails, PDFs and notifications go to a queue like Kafka or RabbitMQ and are processed in the background.

How it works

How to structure a 30-minute answer

  1. 1

    Requirements

    Functional (shorten, redirect) and non-functional (fast reads, many users, high availability).

  2. 2

    Rough numbers

    Reads vs writes, data per record. Keep it simple and state your assumptions.

  3. 3

    APIs

    POST /urls and GET /{code}, with request and response shapes.

  4. 4

    High-level design

    Client, load balancer, app servers, cache, database. Draw the boxes.

  5. 5

    Deep dive

    Short code generation, caching, scaling, and failure cases. Mention trade-offs.

See it in code

Walk through the code

java
1import org.springframework.cache.annotation.Cacheable;2import org.springframework.stereotype.Service;3 4@Service5public class ShortUrlService {6    private final UrlRepository repo;7 8    public ShortUrlService(UrlRepository repo) { this.repo = repo; }9 10    @Cacheable(value = "urls", key = "#code")11    public String resolve(String code) {12        return repo.findByCode(code)13                   .map(UrlMapping::getLongUrl)14                   .orElseThrow(() -> new UrlNotFoundException(code));15    }16}17 18// application.properties19// spring.cache.type=redis20// spring.data.redis.host=localhost21// spring.cache.redis.time-to-live=10m

1/3Cache the result under the short code. Later calls skip the method body.

Add @EnableCaching to a configuration class and spring-boot-starter-data-redis. The first call hits the database; repeats come from Redis.

Save yourself the pain

Common mistakes

Oops

Drawing Kafka, Kubernetes and ten microservices for a simple app.

Do this instead

Start simple and add pieces only when a requirement needs them. Explain why each box exists.

Oops

Jumping to the design without asking requirements.

Do this instead

Spend the first few minutes on scope and scale. It changes the right answer.

Oops

Ignoring what happens when something fails.

Do this instead

Mention timeouts, retries, database backups and what users see if the cache is down.

Your mission

Design a URL shortener

~60 min

Quick check

Why should app servers be stateless when scaling horizontally?

Go deeper

  1. 1Learn what load balancers, caches and database indexes do.
  2. 2Sketch the design of a URL shortener on paper.
  3. 3Explain the architecture of your own Spring Boot project clearly.

More topics at this stop

Stuck on this topic? Ask an Insider

Get 1:1 guidance from people who've walked this exact path — on the InsideEdge app.

Download
InsideEdge