Design auth, session security, and top-N users

Read the full interview experience this question came from →

Quick Overview

This question evaluates a candidate's competency in web authentication and session security, secure API design, and scalable analytics for computing top-N active users.

Design auth, session security, and top-N users

Company: Bloomberg

Role: Software Engineer

Category: System Design

Difficulty: hard

Interview Round: Onsite

Design a web application where a user signs in and the page displays "Hello, <username>". 1) Define the client–server APIs for sign-up, sign-in, sign-out, and fetching the greeting (request/response shapes, status codes, and error handling). 2) Choose an authentication approach (stateful sessions vs. stateless tokens like JWT) and detail password storage, MFA (optional), TLS, CSRF protection, and XSS mitigations. 3) After sign-in, explain how to prevent others from impersonating a user by reusing/guessing a user ID; cover session identifiers or tokens, entropy, rotation/expiration, storage (cookie flags, SameSite), token binding, refresh flows, and defenses against fixation, replay, and theft. 4) Design an endpoint/service that returns the top N active users over a recent time window; define what "active" means, the signals you will count (e.g., requests, actions), the data model, and an efficient computation approach (e.g., sliding-window counters, stream processing, precomputed aggregations). Include scalability, consistency, rate limiting, and back-of-the-envelope capacity planning.

Overview: This question evaluates a candidate's competency in web authentication and session security, secure API design, and scalable analytics for computing top-N active users.

Read the full Bloomberg Software Engineer interview experience this question came from

|Home/System Design/Bloomberg
Bloomberg logo
Bloomberg
Sep 6, 2025
hardSoftware EngineerOnsiteSystem Design
27
0

Web App Design: Authentication, Security, and Top-N Active Users

Context: Build a browser-based web application where a user signs in and the page displays "Hello, <username>". Assume JSON over HTTPS, a single-page web client, and a backend service. Design the APIs, authentication, and a service that returns the top N active users over a recent time window.

Tasks

  1. Client–Server APIs
  • Define REST endpoints for sign-up, sign-in, sign-out, and fetching the greeting.
  • Include request/response JSON shapes, HTTP status codes, and error handling.
  1. Authentication Approach
  • Choose between stateful server-side sessions and stateless tokens (e.g., JWT).
  • Detail password storage, optional MFA, TLS requirements, CSRF protection, and XSS mitigations.
  1. Post Sign-In Impersonation Risks
  • Explain how to prevent impersonation via reusing/guessing a user ID.
  • Cover session identifiers or tokens, entropy, rotation/expiration, storage (cookie flags, SameSite), token binding, refresh flows, and defenses against fixation, replay, and theft.
  1. Top N Active Users Service
  • Design an endpoint/service that returns the top N active users over a recent window.
  • Define "active" and the signals counted (e.g., requests, actions).
  • Propose a data model and an efficient computation approach (e.g., sliding-window counters, stream processing, precomputed aggregations).
  • Include scalability, consistency tradeoffs, rate limiting, and back-of-the-envelope capacity planning.

Submit Your Answer to Earn 20XP

Sign in to leave a comment

Loading comments...