aicodinginterview Waitlist

Log insights: AI coding interview practice

You’re on call for the API gateway. This library parses access-log lines and feeds the dashboard: busiest endpoints and latency percentiles, refreshed every few seconds while new lines keep arriving. Three tickets are waiting for you.

Download the project (zip, 8 KB)

Java 17, Maven, JUnit 5. Covers parsing, percentiles, time windows, caching with invalidation.

What's inside

pom.xml
README.md
src/main/java/practice/logs/LogLine.java
src/main/java/practice/logs/LogParser.java
src/main/java/practice/logs/LogStats.java
src/main/java/practice/logs/MalformedLineException.java
src/main/java/practice/logs/PathCount.java
src/test/java/practice/logs/BaselineTest.java
src/test/java/practice/logs/Lines.java
src/test/java/practice/logs/Phase1Test.java
src/test/java/practice/logs/Phase2Test.java
src/test/java/practice/logs/Phase3Test.java

Run it

mvn -q test                      # phase tests fail until you solve them
mvn -q test -Dtest=BaselineTest  # what already works; keep it green

How to practise

The three tickets

Phase 1: Fix the bug

On-call says the busiest-endpoints panel is useless: /api/orders is the hottest endpoint and it never shows up. Find the cause and fix it.

Check with mvn -q test -Dtest=Phase1Test

Hint

Look at what the parser stores as the path for a real log line, then at how topPaths groups them.

Phase 2: Add the feature

The dashboard needs an error-rate panel. Implement LogStats.errorRate(from, to): the share of requests in [from, to) that returned a 5xx status, 0 for an empty window, and an error for a backwards window.

Check with mvn -q test -Dtest=Phase2Test

Hint

Pin down the edges first: is a 404 an error here? Is a line exactly at ‘to’ inside the window?

Phase 3: Make it fast

With a day of traffic loaded, the dashboard takes seconds to refresh. Make percentile() and topPaths() fast while lines keep arriving, without changing their answers.

Check with mvn -q test -Dtest=Phase3Test

Hint

The dashboard reads far more often than lines arrive between reads. What work is repeated on every read?

More practice projects

Want to know what real rounds look like first? Read the candidate reports by company.