Repair deterministic experiment assignment across replicas and traffic ramps

Quick Overview

Repair experiment assignment across C++14 replicas and offline recomputation. Define exact ASCII bytes and hashing, separate enrollment from variant assignment, and preserve existing groups when traffic expands from 10% to 20%.

Repair deterministic experiment assignment across replicas and traffic ramps

Company: Microsoft

Role: Software Engineer

Category: Software Engineering Fundamentals

Difficulty: hard

Interview Round: Technical Screen

Repair a C++14 experiment-assignment service. After it expands from one replica to three, some users see both Control and Treatment, and offline recomputation disagrees with online assignment. Increasing experiment traffic from 10% to 20% also moves some previously enrolled Treatment users to Control. The identifier contract requires ASCII byte normalization only. Convert bytes A through Z to lowercase and preserve every other byte. Explain why a locale-sensitive case conversion is inappropriate for this contract. ### Clarifying Questions - Which experiment identifier, salt, byte concatenation format, hash parameters, and fixed bucket count are shared with offline computation? - Does the traffic ramp change only enrollment, while the Control/Treatment ratio remains fixed? - How are assignment-version changes distinguished from a normal traffic increase? ### Part 1: Diagnose and repair replica disagreement Compare normalized bytes, hash values, and slot numbers for the same identifier across replicas and offline code. Implement deterministic ASCII normalization and hashing with an explicit input format. ```hint Find the first differing stage If the normalized bytes already disagree, changing the bucket comparison cannot restore agreement downstream. ``` #### What This Part Should Cover - Exact byte normalization and deterministic encoding - Fixed hashing parameters and bucket configuration - Cross-replica and offline verification vectors ### Part 2: Preserve assignments during expansion Separate enrollment from variant assignment using stable rules. With 100 enrollment slots, a 10% rollout admits slots 0 through 9 and a 20% rollout admits slots 0 through 19. Existing enrolled users must retain their variant when only the enrollment threshold grows. ```hint Isolate the changing input Identify which expression is allowed to use the rollout percentage and which must remain unchanged to preserve old assignments. ``` #### What This Part Should Cover - Monotone enrollment and stable Control/Treatment assignment - Domain-separated assignment inputs and versioning - Tests for unchanged users, newly enrolled users, and excluded users ### Part 3: Explain the ASCII conversion Explain why manually converting ASCII uppercase bytes can be preferable to `std::tolower` here, including locale behavior and byte-type concerns. ```hint Treat the identifier as bytes Bytes outside the ASCII uppercase range must survive unchanged, including bytes whose plain `char` representation is negative. ``` #### What This Part Should Cover - Locale-independent ASCII conversion - Safe unsigned-byte handling - Agreement with the offline normalization contract ### What a Strong Answer Covers - Compatible C++14 implementation and an exact byte protocol - Separation of enrollment changes from assignment-version changes - Written checks covering case, non-ASCII bytes, and ramp stability ### Follow-up Questions - What should happen if the salt or bucket count must change after launch? - How would you detect assignment drift before users see conflicting variants?

Overview: Repair experiment assignment across C++14 replicas and offline recomputation. Define exact ASCII bytes and hashing, separate enrollment from variant assignment, and preserve existing groups when traffic expands from 10% to 20%.

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

Microsoft logo
Microsoft
Dec 1, 2026
hardSoftware EngineerTechnical ScreenSoftware Engineering Fundamentals
0
0

Repair a C++14 experiment-assignment service. After it expands from one replica to three, some users see both Control and Treatment, and offline recomputation disagrees with online assignment. Increasing experiment traffic from 10% to 20% also moves some previously enrolled Treatment users to Control.

The identifier contract requires ASCII byte normalization only. Convert bytes A through Z to lowercase and preserve every other byte. Explain why a locale-sensitive case conversion is inappropriate for this contract.

Clarifying Questions Guidance

  • Which experiment identifier, salt, byte concatenation format, hash parameters, and fixed bucket count are shared with offline computation?
  • Does the traffic ramp change only enrollment, while the Control/Treatment ratio remains fixed?
  • How are assignment-version changes distinguished from a normal traffic increase?

Part 1: Diagnose and repair replica disagreement

Compare normalized bytes, hash values, and slot numbers for the same identifier across replicas and offline code. Implement deterministic ASCII normalization and hashing with an explicit input format.

What This Part Should Cover Guidance

  • Exact byte normalization and deterministic encoding
  • Fixed hashing parameters and bucket configuration
  • Cross-replica and offline verification vectors

Part 2: Preserve assignments during expansion

Separate enrollment from variant assignment using stable rules. With 100 enrollment slots, a 10% rollout admits slots 0 through 9 and a 20% rollout admits slots 0 through 19. Existing enrolled users must retain their variant when only the enrollment threshold grows.

What This Part Should Cover Guidance

  • Monotone enrollment and stable Control/Treatment assignment
  • Domain-separated assignment inputs and versioning
  • Tests for unchanged users, newly enrolled users, and excluded users

Part 3: Explain the ASCII conversion

Explain why manually converting ASCII uppercase bytes can be preferable to std::tolower here, including locale behavior and byte-type concerns.

What This Part Should Cover Guidance

  • Locale-independent ASCII conversion
  • Safe unsigned-byte handling
  • Agreement with the offline normalization contract

What a Strong Answer Covers Guidance

  • Compatible C++14 implementation and an exact byte protocol
  • Separation of enrollment changes from assignment-version changes
  • Written checks covering case, non-ASCII bytes, and ramp stability

Follow-up Questions Guidance

  • What should happen if the salt or bucket count must change after launch?
  • How would you detect assignment drift before users see conflicting variants?