Full-Stack Development Case Studies & Practical Application 2 — Questions and Answers
Question 1: A social media app experiences slow feed loading because each post requires a separate database call to fetch author details. Which pattern best resolves this N+1 query problem?
- Add an index on the author_id column
- Use eager loading with a JOIN to fetch posts and authors in one query (Correct answer)
- Cache each author record in localStorage
- Switch from SQL to a document database
Correct answer: Use eager loading with a JOIN to fetch posts and authors in one query
Eager loading with a JOIN retrieves all required data in a single query, eliminating the N+1 problem.
Question 2: An e-commerce checkout page must never show a stale cart total, but product listing pages can tolerate slightly outdated prices. Which caching strategy fits this requirement?
- Cache everything with a 1-hour TTL
- No caching on any page
- Cache product listings with a short TTL; never cache the checkout total (Correct answer)
- Use service-worker cache for all pages
Correct answer: Cache product listings with a short TTL; never cache the checkout total
Applying different caching policies per page type balances performance with data accuracy where it matters most.
Question 3: A startup's monolithic Node.js app is bottlenecked at its image-resize feature during peak hours. What is the most targeted fix without a full rewrite?
- Increase the Node.js event loop tick rate
- Extract image resizing into a separate microservice or worker queue (Correct answer)
- Add more CPU cores to the monolith server
- Rewrite the entire app in Go
Correct answer: Extract image resizing into a separate microservice or worker queue
Extracting the bottleneck into an independent worker allows it to scale independently without disrupting the rest of the monolith.
Question 4: A React SPA communicates with a REST API. After a deploy, some users still see the old UI because the browser cached stale JS bundles. What build-time strategy prevents this?
- Set Cache-Control: no-store on the server
- Include a content hash in each bundle filename so new files bypass old cache entries (Correct answer)
- Delete cookies on every deploy
- Use HTTP/2 push to force new assets
Correct answer: Include a content hash in each bundle filename so new files bypass old cache entries
Content-hashed filenames ensure browsers treat new bundles as distinct resources and never serve stale files.
Question 5: A PostgreSQL-backed API endpoint is timing out under load. EXPLAIN ANALYZE shows a sequential scan on a 10M-row table. What is the immediate corrective action?
- Partition the table by date
- Add an index on the column used in the WHERE clause (Correct answer)
- Increase max_connections in postgresql.conf
- Switch to an in-memory store like Redis
Correct answer: Add an index on the column used in the WHERE clause
Adding an index on the filtered column allows the query planner to perform an index scan instead of a sequential scan.
Question 6: A fintech app must ensure a bank transfer debit and credit happen together or not at all. Which database concept enforces this?
- Foreign key constraint
- Database transaction with ACID guarantees (Correct answer)
- Optimistic locking
- Read replica failover
Correct answer: Database transaction with ACID guarantees
An ACID transaction groups both operations so a failure in either rolls back the entire transfer atomically.
Question 7: A team is migrating a legacy jQuery app to React. Users must not experience downtime during the migration. Which strategy enables incremental migration?
- Freeze new feature development until the full React rewrite is complete
- Use the strangler fig pattern — replace one page or component at a time while running both systems (Correct answer)
- Redirect all traffic to a staging React app immediately
- Convert all jQuery to vanilla JS first, then to React
Correct answer: Use the strangler fig pattern — replace one page or component at a time while running both systems
The strangler fig pattern lets you incrementally replace the old system while both coexist, avoiding a risky big-bang cutover.
A social media app experiences slow feed loading because each post requires a separate database call to fetch author details.
Which pattern best resolves this N+1 query problem?