← Amazon Interview Insights

Amazon·Software Engineer·Onsite - Coding / Algorithms·Intermediate

Intermediate
May 2026

Summary

Amazon SWE live coding round where they had me build a web crawler from scratch in my own IDE with screen sharing. Open-book but no AI tools allowed, which honestly felt fair. The problem sounded straightforward until I started actually writing it.

Questions Asked (2)

Q1

Implement a BFS-based web crawler starting from a seed URL, with URL normalization, deduplication, and an option to restrict crawling to the same domain.

Algorithms & Data StructuresSystem DesignTechnical Trade-offs
Author's notes

I started with the BFS queue and dedup set, which went fine.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Start by clarifying requirements (scale, politeness, depth limits) and then outline a BFS crawler using a queue, a visited set for deduplication, and URL normalization. Discuss domain restriction, concurrency, and trade-offs like politeness vs. throughput, and finish with edge cases and testing.

Pro tip: Mention robots.txt and crawl-delay early to show respect for web etiquette and avoid legal issues, and propose a distributed architecture with a URL frontier and worker pool to demonstrate scalability thinking.

1. Clarify Requirements and Constraints

Ask about scale (pages, depth), politeness (robots.txt, rate limiting), and whether to restrict to same domain. Confirm expected output and error handling.

2. Design Core Data Structures and BFS

Use a queue for BFS, a set for visited URLs, and a function to normalize URLs (lowercase host, remove fragments, sort query params). Explain how to extract links from HTML.

3. Implement Domain Restriction and Deduplication

Check if a URL belongs to the same domain (or subdomain) before enqueueing. Normalize URLs before deduplication to avoid duplicates with different representations.

4. Address Scalability and Politeness

Discuss concurrency (thread pool, async I/O), rate limiting per domain, and distributed crawling with a URL frontier. Mention robots.txt parsing and crawl-delay.

5. Handle Edge Cases and Testing

Cover malformed URLs, redirects, non-HTML content, and cycles. Suggest unit tests for normalization and integration tests with a mock server.

Key Points to Mention

  • URL normalization techniques: lowercasing scheme/host, removing default ports, resolving dot-segments, sorting query parameters, removing fragments.
  • Deduplication using a visited set (e.g., hash set) and potential memory concerns at scale (Bloom filters).
  • Domain restriction: compare hostnames, consider subdomains, and handle www vs non-www.
  • Politeness: robots.txt, crawl-delay, rate limiting per domain, and user-agent identification.
  • Concurrency and scalability: thread pool, async I/O, distributed crawling with a URL frontier and worker nodes.
  • Trade-offs: BFS vs DFS, memory vs speed, politeness vs throughput, and handling dynamic content.

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

Q2

How would you handle HTTP errors, malformed URLs, and timeouts in your crawler, and what retry logic would you implement for transient failures?

System DesignTechnical Trade-offsAPI & Integrations
Author's notes

I knew the general shape of the answer: catch exceptions, distinguish retryable vs non-retryable status codes, exponential backoff with a cap.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Structure your answer by categorizing failures into client errors (4xx), server errors (5xx), and network-level issues (timeouts, malformed URLs), then describe a layered handling strategy for each. Emphasize idempotency, exponential backoff with jitter, and circuit breakers to prevent cascading failures, aligning with Amazon's operational excellence and customer obsession principles.

Pro tip: Tie your retry logic to Amazon's leadership principles by highlighting how you balance customer impact (avoiding duplicate actions) with system resilience (retrying transient failures), and mention using AWS services like SQS or Step Functions for managed retries when appropriate.

1. Categorize Errors

Distinguish between client errors (4xx), server errors (5xx), and network issues (timeouts, DNS failures, malformed URLs). Explain that 4xx errors are generally non-retryable, while 5xx and network errors are candidates for retries.

2. Handle Malformed URLs and Timeouts

For malformed URLs, validate and sanitize inputs before crawling, and log them for analysis without retrying. For timeouts, set reasonable timeouts per request and treat them as transient, but avoid retrying indefinitely.

3. Implement Retry Logic with Backoff

Use exponential backoff with jitter to avoid thundering herd problems. Limit retries (e.g., 3-5 attempts) and consider idempotency to prevent duplicate side effects. Optionally, use a dead-letter queue for persistent failures.

4. Add Circuit Breakers and Monitoring

Implement circuit breakers to stop retrying when a service is consistently failing, preventing resource exhaustion. Monitor error rates and retry counts to detect systemic issues and alert accordingly.

5. Discuss Trade-offs and AWS Integration

Explain trade-offs between retry aggressiveness and latency/cost. Mention how AWS services like SQS, Lambda, or Step Functions can offload retry logic and provide built-in resilience.

Key Points to Mention

  • Exponential backoff with jitter to avoid synchronized retries
  • Idempotency of requests to safely retry without side effects
  • Circuit breaker pattern to prevent cascading failures
  • Distinguishing between retryable (5xx, timeouts) and non-retryable (4xx) errors
  • Dead-letter queues for handling persistent failures
  • Monitoring and alerting on error rates and retry metrics

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