AWS Product Scraper: Serverless Data Pipeline
1 Software engineer, Singapore; cyrus@pastelero.ph
Abstract
Learning AWS the hard way by building a production scraping system. Understanding Lambda cold starts, DynamoDB costs, and why infrastructure as code matters.
Keywords: AWS Lambda; DynamoDB; TypeScript

The problem
I needed to collect product data from multiple websites regularly. Running scrapers on my local machine wasn't sustainable. Leaving a server running 24/7 for jobs that run a few times a day seemed wasteful.
This seemed like a perfect use case for serverless. Pay only when the scraper runs, scale automatically when needed, and not worry about server maintenance.
What I built
A fully serverless scraping pipeline on AWS:
Tech stack
| Layer | Technology | Why |
|---|---|---|
| Compute | AWS Lambda[1] | Pay per execution, auto scaling |
| Scheduler | EventBridge[2] | Cron expressions, serverless |
| Queue | SQS[3] | Decoupled processing |
| Database | DynamoDB[4] | Serverless NoSQL |
| Storage | S3[5] | Raw file storage |
| Infrastructure | AWS CDK[6] | TypeScript infra as code |
What building this taught me
1. Cold starts are real and they hurt
My first Lambda functions took 3 to 5 seconds to start from cold. For scraping, that added up fast.
I learned to optimize bundle sizes, use provisioned concurrency[7] for critical paths, and accept that some latency is just part of serverless life.
// Before: v2, bundled with the function (3-5 second cold starts)
import * as AWS from 'aws-sdk' // Huge bundle
// After: <1 second cold starts
import { DynamoDB } from '@aws-sdk/client-dynamodb' // Tree-shakeableResources:
- Lambda Cold Start Optimization[8]
- AWS SDK v3 (Modular)[9]
- Lambda's Node.js runtimes include only SDK v3[10]
2. DynamoDB pricing is tricky
I assumed "pay per request" meant cheap. Then I saw my first bill.
Scan operations[11] are expensive. Provisioned capacity vs on demand changes costs dramatically. I rewrote queries multiple times to reduce costs.
On-demand reads cost $0.25 per million when I wrote this, and $0.125 since AWS halved on-demand prices in November 2024[12].
The lesson: design your access patterns first, then design your table. Not the other way around.
Resources:
3. Infrastructure as code saves your future self
I started clicking around the AWS console. It worked until I needed to replicate the setup for staging.
CDK[6] seemed like overkill initially, but having version controlled infrastructure made everything reproducible and debuggable.
// Define entire scraping infrastructure in TypeScript
const scraperFunction = new lambda.Function(this, 'Scraper', {
runtime: lambda.Runtime.NODEJS_18_X, // Current in 2024; Lambda deprecated Node 18 on 1 September 2025
handler: 'scraper.handler',
code: lambda.Code.fromAsset('lambda'),
timeout: Duration.minutes(5),
memorySize: 1024,
})
// Schedule runs every 6 hours
new events.Rule(this, 'ScraperSchedule', {
schedule: events.Schedule.rate(Duration.hours(6)),
targets: [new targets.LambdaFunction(scraperFunction)],
})Resources:
4. Scrapers break constantly
Websites change their HTML structure without warning. I built monitoring and alerting so I know when scrapers fail, and I designed the system to gracefully handle partial failures without losing data.
// Graceful error handling with partial success
async function scrapeProducts(urls: string[]) {
const results = await Promise.allSettled(urls.map(url => scrapeOne(url)))
const successful = results.filter(r => r.status === 'fulfilled')
const failed = results.filter(r => r.status === 'rejected')
// Log failures but don't lose successful scrapes
if (failed.length > 0) {
await alertSlack(`${failed.length}/${urls.length} scrapes failed`)
}
return successful.map(r => r.value)
}Resources:
5. Memory equals speed equals cost
Lambda pricing ties memory and CPU together. Sometimes allocating more memory actually costs less because the function runs faster.
Sweet spot: 1024 MB costs about 20% more per run (1.5 against 1.25 GB-seconds[20]) but runs about 6.7x faster than 128 MB.
I experimented to find the sweet spot for each function.
Resources:
Polite scraping
I built in rate limiting, request delays, and respect for robots.txt. Partly that is the ethical thing to do, and partly it is self-preservation: aggressive scraping gets your IP banned fast.
const rateLimiter = new Bottleneck({
minTime: 2000, // 2 second delay between requests
maxConcurrent: 1, // One request at a time
})
// Respect robots.txt
const robotsParser = await fetchRobotsTxt(domain)
if (!robotsParser.isAllowed(url)) {
console.log(`Skipping ${url} - blocked by robots.txt`)
return null
}The bigger realization
Building this scraper taught me that serverless is a different way of thinking about architecture, more than "functions in the cloud." You design around events, embrace eventual consistency, and accept that distributed systems have distributed problems.
What I would do differently
Start with Step Functions[22] for orchestration. I cobbled together Lambda triggers and SQS queues manually. Step Functions would have given me better visibility into the pipeline and easier error handling.
Links
- Source: private
References
- Lambda. aws.amazon.com. https://aws.amazon.com/lambda/ ↑
- EventBridge. aws.amazon.com. https://aws.amazon.com/eventbridge/ ↑
- SQS. aws.amazon.com. https://aws.amazon.com/sqs/ ↑
- DynamoDB. aws.amazon.com. https://aws.amazon.com/dynamodb/ ↑
- S3. aws.amazon.com. https://aws.amazon.com/s3/ ↑
- AWS CDK. aws.amazon.com. https://aws.amazon.com/cdk/ ↑
- provisioned concurrency. docs.aws.amazon.com. https://docs.aws.amazon.com/lambda/latest/dg/provisioned-concurrency.html ↑
- Lambda Cold Start Optimization. aws.amazon.com. https://aws.amazon.com/blogs/compute/operating-lambda-performance-optimization-part-1/ ↑
- AWS SDK v3 (Modular). docs.aws.amazon.com. https://docs.aws.amazon.com/sdk-for-javascript/v3/developer-guide/ ↑
- Lambda's Node.js runtimes include only SDK v3. docs.aws.amazon.com. https://docs.aws.amazon.com/lambda/latest/dg/lambda-nodejs.html ↑
- Scan operations. docs.aws.amazon.com. https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/Scan.html ↑
- $0.125 since AWS halved on-demand prices in November 2024. aws.amazon.com. https://aws.amazon.com/about-aws/whats-new/2024/11/amazon-dynamo-db-reduces-prices-on-demand-throughput-global-tables/ ↑
- DynamoDB Pricing. aws.amazon.com. https://aws.amazon.com/dynamodb/pricing/ ↑
- Single Table Design. alexdebrie.com. https://www.alexdebrie.com/posts/dynamodb-single-table/ ↑
- AWS CDK Documentation. docs.aws.amazon.com. https://docs.aws.amazon.com/cdk/v2/guide/home.html ↑
- CDK Patterns. cdkpatterns.com. https://cdkpatterns.com/ ↑
- Lambda runtime deprecation dates. docs.aws.amazon.com. https://docs.aws.amazon.com/lambda/latest/dg/lambda-runtimes.html ↑
- CloudWatch Alarms. docs.aws.amazon.com. https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/AlarmThatSendsEmail.html ↑
- Dead Letter Queues. docs.aws.amazon.com. https://docs.aws.amazon.com/AWSSimpleQueueService/latest/SQSDeveloperGuide/sqs-dead-letter-queues.html ↑
- GB-seconds. aws.amazon.com. https://aws.amazon.com/lambda/pricing/ ↑
- Lambda Power Tuning. github.com. https://github.com/alexcasalboni/aws-lambda-power-tuning ↑
- Step Functions. aws.amazon.com. https://aws.amazon.com/step-functions/ ↑
- AWS Lambda Documentation. docs.aws.amazon.com. https://docs.aws.amazon.com/lambda/
- DynamoDB Best Practices. docs.aws.amazon.com. https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/best-practices.html
- Serverless Patterns. serverlessland.com. https://serverlessland.com/patterns