<?xml version="1.0" encoding="UTF-8"?>
<response><data><post><id>195</id><slug>retry-and-backoff-patterns-part-10-195</slug><title>Retry and backoff patterns, part 10</title><excerpt>In part 10 we take the ideas from earlier instalments and apply them to a larger, messier site. Networks fail, servers restart and rate limits kick in. A scraper that gives up at the first error is…</excerpt><seriesName>Retry and backoff patterns</seriesName><seriesPart>10</seriesPart><sections><item><heading>Introduction</heading><paragraphs><item>In part 10 we take the ideas from earlier instalments and apply them to a larger, messier site. Networks fail, servers restart and rate limits kick in. A scraper that gives up at the first error is fragile; one that retries instantly and forever is a nuisance.</item></paragraphs></item><item><heading>Step by step</heading><paragraphs><item>Time zones matter more than they seem. Store timestamps in UTC and convert only when displaying them.</item><item>Before writing a single line of code, look at how the page actually loads its data. Open the network panel, reload, and note which requests return the content you care about. Very often the data you want arrives as JSON from an endpoint you can call directly.</item></paragraphs></item><item><heading>What to watch for</heading><paragraphs><item>Always identify your client honestly with a descriptive User-Agent, and keep your request rate modest. A crawler that behaves like a considerate visitor is far less likely to cause problems for the site operator.</item><item>Pagination comes in several shapes: numbered pages, next links, offsets and opaque cursors. Each has trade-offs, and a robust scraper should detect the end of the result set rather than assuming a fixed number of pages.</item></paragraphs></item><item><heading>Key takeaway</heading><paragraphs><item>Retry only on errors that can succeed later (timeouts, 429, 5xx), use exponential backoff with jitter, and cap the number of attempts.</item></paragraphs></item></sections><authorId>9</authorId><authorName>Mateo Hughes</authorName><authorSlug>mateo-hughes</authorSlug><category>Data Engineering</category><tags><item>ethics</item><item>json</item></tags><publishedAt>2024-07-17T00:00:00.000Z</publishedAt><wordCount>203</wordCount><readingTimeMinutes>2</readingTimeMinutes></post></data></response>
