PracHub
QuestionsPremiumCoachesLearningGuidesInterview Prep
|Home/System Design/StubHub

Review getEvents endpoint for readability, performance, scalability, security

Last updated: Jun 15, 2026

Quick Overview

A StubHub software-engineer technical-screen system-design exercise: review and fix a GET /events HTTP handler that loads related data (venue, performers, tickets, transactions) per event. Candidates must find and fix the N+1 query, then harden the endpoint across readability/architecture, performance (pagination, indexing, caching), scalability (timeouts, retries, rate limiting), and security (authN/authZ, injection, PII), with trade-offs, SLOs, and a test plan.

  • hard
  • StubHub
  • System Design
  • Software Engineer

Review getEvents endpoint for readability, performance, scalability, security

Company: StubHub

Role: Software Engineer

Category: System Design

Difficulty: hard

Interview Round: Technical Screen

##### Question You are given a code snippet that implements an HTTP `GET /events` handler (`getEvents`). The handler queries events from a database and, for each event, lazily loads related data (for example venue, performers, tickets, and the transactions needed for downstream processing). Perform a thorough code review and propose concrete fixes across the following areas: 1. **Readability and architecture**: Identify duplicate code, poor naming/structure, unclear responsibilities (controller mixing transport, business logic, and SQL), leaky error handling, and the absence of explicit DTOs/response shapes. Propose a layered design (controller / service / repository), centralized validation and error handling, response DTOs with field whitelisting, and structured logging with correlation IDs. 2. **Performance**: Look for N+1 queries (loading related data per event in a loop), missing pagination/limits, inefficient sorting/filtering on non-indexed columns, post-fetch in-memory filtering, missing indexes, excessive serialization/over-fetching, uncompressed payloads, and missing caching or ETags. Propose batching/joins to eliminate N+1, enforced pagination (prefer keyset/cursor), composite indexes aligned to filter+sort patterns, projections/sparse fieldsets, compression, and conditional caching (ETag/Last-Modified, Cache-Control). 3. **Scalability**: Evaluate statelessness, connection pooling, dependency fan-out and batching, timeouts/retries with jitter, circuit breakers, backpressure/load shedding, rate limiting, and asynchronous precomputation/denormalization for hot listings. Propose concrete settings and trade-offs. 4. **Security**: Verify authentication and fine-grained authorization (scope/row-level access), input validation and SQL/NoSQL injection prevention (parameterized queries, sort/include allowlists), output encoding and PII minimization, TLS requirements, CSRF/IDOR risk, least-privilege DB roles, logging redaction, and resource quotas to prevent abuse. For each area, propose concrete fixes, explain the trade-offs, and outline correct HTTP status-code semantics. Finally, define the monitoring/alerting metrics and SLOs you would track, and a targeted test plan covering unit, integration, security (injection, authN/authZ), and performance/load tests (including a query-count budget that fails on N+1 regressions).

Quick Answer: A StubHub software-engineer technical-screen system-design exercise: review and fix a GET /events HTTP handler that loads related data (venue, performers, tickets, transactions) per event. Candidates must find and fix the N+1 query, then harden the endpoint across readability/architecture, performance (pagination, indexing, caching), scalability (timeouts, retries, rate limiting), and security (authN/authZ, injection, PII), with trade-offs, SLOs, and a test plan.

Related Interview Questions

  • Design a Marketing Email System - StubHub (medium)
  • Design Internal Chat and Re-engagement Emails - StubHub (medium)
  • Design Event Email System - StubHub (medium)
StubHub logo
StubHub
Sep 6, 2025, 12:00 AM
Software Engineer
Technical Screen
System Design
7
0
Question

You are given a code snippet that implements an HTTP GET /events handler (getEvents). The handler queries events from a database and, for each event, lazily loads related data (for example venue, performers, tickets, and the transactions needed for downstream processing). Perform a thorough code review and propose concrete fixes across the following areas:

  1. Readability and architecture : Identify duplicate code, poor naming/structure, unclear responsibilities (controller mixing transport, business logic, and SQL), leaky error handling, and the absence of explicit DTOs/response shapes. Propose a layered design (controller / service / repository), centralized validation and error handling, response DTOs with field whitelisting, and structured logging with correlation IDs.
  2. Performance : Look for N+1 queries (loading related data per event in a loop), missing pagination/limits, inefficient sorting/filtering on non-indexed columns, post-fetch in-memory filtering, missing indexes, excessive serialization/over-fetching, uncompressed payloads, and missing caching or ETags. Propose batching/joins to eliminate N+1, enforced pagination (prefer keyset/cursor), composite indexes aligned to filter+sort patterns, projections/sparse fieldsets, compression, and conditional caching (ETag/Last-Modified, Cache-Control).
  3. Scalability : Evaluate statelessness, connection pooling, dependency fan-out and batching, timeouts/retries with jitter, circuit breakers, backpressure/load shedding, rate limiting, and asynchronous precomputation/denormalization for hot listings. Propose concrete settings and trade-offs.
  4. Security : Verify authentication and fine-grained authorization (scope/row-level access), input validation and SQL/NoSQL injection prevention (parameterized queries, sort/include allowlists), output encoding and PII minimization, TLS requirements, CSRF/IDOR risk, least-privilege DB roles, logging redaction, and resource quotas to prevent abuse.

For each area, propose concrete fixes, explain the trade-offs, and outline correct HTTP status-code semantics. Finally, define the monitoring/alerting metrics and SLOs you would track, and a targeted test plan covering unit, integration, security (injection, authN/authZ), and performance/load tests (including a query-count budget that fails on N+1 regressions).

Solution

Show

Submit Your Answer to Earn 20XP

Sign in to leave a comment

Loading comments...

Browse More Questions

More System Design•More StubHub•More Software Engineer•StubHub Software Engineer•StubHub System Design•Software Engineer System Design
PracHub

Master your tech interviews with 8,000+ real questions from top companies.

Product

  • Questions
  • Learning Tracks
  • Interview Guides
  • Resources
  • Premium
  • For Universities
  • Student Access

Browse

  • By Company
  • By Role
  • By Category
  • Topic Hubs
  • SQL Questions
  • Compare Platforms
  • Discord Community

Support

  • support@prachub.com
  • (916) 541-4762

Legal

  • Privacy Policy
  • Terms of Service
  • About Us

© 2026 PracHub. All rights reserved.