<?xml version="1.0" encoding="UTF-8"?>
<response><data><post><id>135</id><slug>retry-and-backoff-patterns-part-7-135</slug><title>Retry and backoff patterns, part 7</title><excerpt>Part 7 looks at what changes when the same technique has to run every day in production. Networks fail, servers restart and rate limits kick in. A scraper that gives up at the first error is fragile;…</excerpt><seriesName>Retry and backoff patterns</seriesName><seriesPart>7</seriesPart><sections><item><heading>Introduction</heading><paragraphs><item>Part 7 looks at what changes when the same technique has to run every day in production. 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>A practical approach</heading><paragraphs><item>Deduplicate as you go. The same item often appears on several listing pages, and a stable identifier such as a SKU or ID makes duplicates easy to spot.</item><item>Keep configuration such as base URLs, delays and selectors out of your code. Changing a delay should not require a redeploy.</item></paragraphs></item><item><heading>Common pitfalls</heading><paragraphs><item>Time zones matter more than they seem. Store timestamps in UTC and convert only when displaying them.</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>1</authorId><authorName>Amelia Okafor</authorName><authorSlug>amelia-okafor</authorSlug><category>Data Engineering</category><tags><item>json</item><item>scrapy</item></tags><publishedAt>2024-09-04T00:00:00.000Z</publishedAt><wordCount>170</wordCount><readingTimeMinutes>2</readingTimeMinutes></post></data></response>
