Sefism early access is open for X and Instagram followers and university students.Get early access
Web

Low-Latency Read API Case Study

Everyone repeats the same advice for low latency: connection pooling, indexes, caching, compression, a CDN. Very few people have measured what each one actually does. Build a read-heavy API with a deliberately slow baseline, apply one optimisation at a time, and measure p50, p95 and p99 latency after each step under the same load. The deliverable is an honest, reproducible case study, including the optimisations that did not help.

Difficulty

Intermediate

A small team, or one strong student willing to learn something new.
Effort

1 semester · 2 students

Deliverables

7 to ship

4 optional extras

Suggested stack

Node.jsPostgreSQLRedisNginxk6CloudflareDocker
A suggestion, not a requirement. Swap anything for what you already know.

What you should ship

  • A dataset generator producing a few million related rows, committed with a fixed random seed
  • A baseline API with documented, deliberate inefficiencies
  • Six optimisation steps, each a tagged commit that changes one thing
  • A benchmark harness using k6 at a constant arrival rate that records p50, p95, p99, throughput and errors per step
  • Measurements from a nearby and a distant client for the CDN step
  • An ablation run showing what each optimisation contributes to the final version
  • A written case study with query plans, charts and an explanation of every result

If you have time left

  • A read replica, with a measurement of replication lag and its effect on stale reads
  • Hedged requests for the slowest endpoint, and their effect on p99 latency
  • Protobuf responses compared with compressed JSON
  • A cost comparison: latency gained per extra rupee of monthly infrastructure spend

Problem

Performance advice is usually passed on as a checklist. Students repeat it without knowing which items matter for their workload, how much each one helps, or what it costs in complexity. A measured case study answers those questions with numbers you produced yourself.

What you build

  • A read-heavy API over a realistic dataset, for example a course catalogue or a product catalogue with a few million rows and related tables such as sections, reviews and prices.
  • A baseline that is slow in common, realistic ways: a new database connection per request, no indexes beyond primary keys, N+1 queries, offset pagination, large uncompressed JSON responses and no HTTP caching headers.
  • A series of steps, each a tagged commit, applied one at a time:
    1. connection pooling;
    2. indexes chosen from EXPLAIN ANALYZE output;
    3. removing N+1 queries and switching to keyset pagination;
    4. an in-memory cache in Redis, cache-aside, with a stated invalidation rule;
    5. gzip or brotli compression and smaller response payloads;
    6. HTTP caching headers and a CDN in front of cacheable endpoints.
  • A benchmark harness that runs the same k6 scenario against every step and stores the results.

Suggested architecture

  • Node.js or Go for the API, PostgreSQL, Redis, Nginx as a reverse proxy, and a free CDN tier such as Cloudflare. Any backend language works; keep the same one across every step.
  • Run the database and API on fixed, documented hardware. A small cloud VM is better than a laptop that is also running a browser.
  • Use k6 with a constant arrival rate executor, so a slow server cannot quietly reduce the load it is tested with.
  • Measure from at least two places: a machine in the same region, and a distant client (for example Lahore against a European region), because the CDN step only shows up for distant users.

Milestones by month

  1. Month 1: dataset generator, baseline API, benchmark harness, first baseline numbers.
  2. Month 2: steps 1 to 3, each measured and written up.
  3. Month 3: steps 4 to 6, including cache invalidation tests and CDN measurements from two locations.
  4. Month 4: combined results, an ablation that removes each step from the final version to see what it contributes, report and demo.

How it will be assessed

  • A results table and charts: p50, p95, p99, throughput and error rate for every step, with the hardware and load described.
  • Reproducibility: an examiner can check out any step's tag and rerun the benchmark with one command.
  • The quality of the explanations. "Latency fell by 60% because the query moved from a sequential scan to an index scan, shown in this plan" is the standard to aim for.
  • Honest reporting of steps that made no difference or made things worse.

Pitfalls

  • Changing two things in one step.
  • Measuring with a cold cache in one run and a warm cache in the next without saying so.
  • Reporting averages instead of percentiles.
  • Benchmarking a dataset so small that it fits in memory, which makes indexes look useless.
  • Caching data that must be fresh without a clear invalidation rule. Write down how stale each endpoint is allowed to be.

Ideas and guidance, not finished projects

These are project ideas and scoping guidance, published free for students to use as a starting point. I do not build, write, or sell final-year projects, and I do not complete coursework for anyone. Take an idea, make it yours, and build it.

Not sure this one fits you?

I help students pick an idea that matches their skills and their deadline, then scope it down until it is finishable. Guidance only, never done for you.

Discuss this idea
Work with me

Stuck on something specific?

Writing only gets you so far. If you want an answer to your situation rather than the general case, book a session and we will work through it together. Sessions are free for approved Sefism members, and a few slots open each week.

Follow along

New writing, resources and project ideas land here first.