Lesson 41 — Concurrent Web Scraper

Mini-project tổng hợp Tier 3: worker pool, rate limit, context, retry, JSON output.

Module 1 — Scraper Architecture Flow

Click vào từng component để xem code snippet thật trong project. Tổng cộng 6 file: main.go, scraper.go, ratelimit.go, parser.go, output.go, retry.go.

URL Queue chan string Token Bucket 5 req/s Worker 0 goroutine + http Worker 1 goroutine + http Worker N-1 goroutine + http HTML Parser x/net/html JSON Writer bufio + mutex Context (Ctrl+C)
// Click 1 component ở sơ đồ trên để xem code
// Mỗi component map 1 file Go trong solutions/

Module 2 — Worker Simulation

Chỉnh worker count, rate limit, số URL → quan sát token bucket cấp token cho worker, worker fetch (1-2s mỗi URL), ghi result. Progress bar + throughput tính realtime.

📋 Queue

👷 Workers

0
tokens

📄 Result.json

0 / 0
Elapsed: 0.0s
Throughput: 0.0 req/s
Success: 0
Failed: 0

Module 3 — Retry Timeline

Mô phỏng 1 URL fail nhiều lần với exponential backoff: attempt 1 fail → đợi 1s → attempt 2 fail → đợi 2s → attempt 3 → success hoặc give up. Chọn kịch bản để xem timeline.

0s 1s 2s 4s 7s → time
// Chọn kịch bản và bấm "Chạy" để xem retry timeline