← baseten Interview Insights

baseten·Software Engineer·Onsite - System Design / Architecture·Senior

Senior
Apr 2026

Summary

Follow-up system design round at Baseten focused on the integrity verification side of a parallel S3 chunk downloader. Pretty deep dive, more about correctness guarantees and testability than the happy path.

Questions Asked (3)

Q1

After building a parallel chunk downloader for S3, how do you verify that every chunk arrived correctly and the reassembled file actually matches what the server has?

System DesignTechnical Trade-offsAPI & Integrations
Author's notes

This is where I spent most of the time.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Start by explaining per-chunk integrity verification using checksums (e.g., MD5 or SHA-256) provided by S3's ETag or custom metadata, then describe how to verify the reassembled file's overall integrity against the server's version. Emphasize handling edge cases like multipart ETags and the importance of end-to-end validation to catch reassembly errors.

Pro tip: Mention that S3's ETag for multipart uploads is not a simple MD5 of the whole file, so you must either compute checksums per part or use additional checksums (like SHA-256) for reliable verification. This shows deep understanding of S3 internals.

1. Verify each chunk during download

As each chunk is downloaded, compute its checksum (e.g., MD5 or SHA-256) and compare it to the expected checksum from S3's ETag or custom metadata. If mismatch, retry the chunk.

2. Validate chunk order and completeness

Ensure all chunks are received and in the correct order by tracking part numbers and sizes. Use a manifest or list of expected parts to detect missing or duplicate chunks.

3. Reassemble the file

Concatenate the verified chunks in the correct order to reconstruct the file. Optionally, compute a running checksum during reassembly to avoid a second pass.

4. Verify the reassembled file

Compute the overall checksum of the reassembled file and compare it to the server's checksum. For S3, if the object was uploaded as a single part, the ETag is the MD5; for multipart, use the multipart ETag algorithm or a separate checksum.

5. Handle failures and retries

Implement retry logic for failed chunks and consider fallback to re-download the entire file if reassembly verification fails. Log discrepancies for debugging.

Key Points to Mention

  • Use of checksums (MD5, SHA-256) for per-chunk and whole-file verification
  • S3 ETag behavior: single-part vs multipart uploads
  • Handling of chunk order and completeness via part numbers
  • Retry mechanisms for failed chunks and exponential backoff
  • End-to-end integrity check to catch reassembly errors
  • Performance considerations: avoid re-reading the entire file if possible

AI-generated suggestions, not part of the candidate's original notes. May be inaccurate — verify before relying on them.

Q2

If a chunk checksum or the final file hash doesn't match the expected value, do you retry that chunk, abort the whole download, or something else? What's your decision logic?

System DesignTechnical Trade-offs
Author's notes

I said retry the specific chunk up to N times before failing the whole job.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Start by clarifying the context: is this a user-facing download, a background data pipeline, or a model artifact fetch? Then outline a tiered retry strategy with bounded attempts, exponential backoff, and fallback to full-file verification. Emphasize that the decision depends on cost of retry vs. cost of corruption, and that you'd instrument and log all failures for observability.

Pro tip: Mention that you'd treat checksum mismatches as potential security or data integrity incidents, not just transient errors—so you'd log the chunk hash, expected hash, and source, and consider quarantining the source if mismatches are frequent. This shows you think beyond just retrying.

1. Clarify the context and constraints

Ask about the type of download (user-facing vs. internal), size, network reliability, and whether the source is trusted. This determines acceptable latency and risk tolerance.

2. Define retry policy for chunks

For chunk checksum failures, retry the chunk a limited number of times (e.g., 3) with exponential backoff and jitter. If it still fails, consider fetching from an alternate source or mirror if available.

3. Handle final file hash mismatch

If the final file hash fails after all chunks pass, re-download the entire file or the suspicious chunks. If it persists, abort and alert, as this may indicate corruption or tampering.

4. Implement fallback and escalation

After bounded retries, fall back to a full re-download or abort with a clear error. Escalate to logging/monitoring and possibly disable the source if failures are systemic.

5. Instrument and learn

Log all checksum failures with metadata (chunk ID, source, timestamp) to detect patterns. Use metrics to tune retry counts and timeouts over time.

Key Points to Mention

  • Bounded retries with exponential backoff and jitter to avoid thundering herd
  • Distinguish between transient network errors and persistent corruption/tampering
  • Use of alternate sources or mirrors for resilience
  • Final file hash as a last line of defense; if it fails, consider full re-download
  • Observability: logging, metrics, and alerting on checksum failures
  • Security implications: checksum mismatches could indicate MITM or malicious source

AI-generated suggestions, not part of the candidate's original notes. May be inaccurate — verify before relying on them.

Q3

How would you unit and integration test this downloader, including fault injection on individual chunks?

System DesignTechnical Trade-offs
Author's notes

Went with deterministic fakes for the S3 client so tests don't hit the network.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Start by clarifying the downloader's architecture and interfaces to identify testable units. Then outline a layered testing strategy: unit tests for chunk logic, integration tests for end-to-end downloads, and fault injection to simulate failures. Emphasize how you'd use dependency injection and test doubles to isolate components and inject faults.

Pro tip: Use a fault injection framework like Toxiproxy or a custom wrapper to simulate network failures, and always verify that the downloader retries with exponential backoff and resumes from the correct offset.

1. Clarify the downloader's design

Ask about the downloader's components (e.g., chunk manager, HTTP client, storage writer) and how they interact. This ensures your testing strategy targets the right boundaries.

2. Unit test individual components

Test each unit in isolation: chunk size calculation, retry logic, checksum verification, and error handling. Use mocks for external dependencies like network calls.

3. Integration test the full download flow

Test the downloader end-to-end with a real or simulated server, verifying that chunks are downloaded, assembled, and saved correctly. Include tests for partial failures and resumption.

4. Inject faults at the chunk level

Simulate failures such as network timeouts, corrupted data, or server errors on specific chunks. Verify that the downloader retries, falls back, or reports errors appropriately.

5. Automate and monitor tests

Integrate tests into CI/CD, use code coverage to ensure critical paths are tested, and add logging/metrics to detect flakiness or gaps in fault coverage.

Key Points to Mention

  • Dependency injection to swap real network/storage with test doubles
  • Mocking HTTP responses for unit tests (e.g., using WireMock or responses library)
  • Fault injection techniques: network latency, packet loss, corrupted chunks, server errors
  • Verifying retry logic with exponential backoff and idempotency
  • Testing resumption from partial downloads using range requests
  • Using property-based testing for chunk boundary conditions

AI-generated suggestions, not part of the candidate's original notes. May be inaccurate — verify before relying on them.