Technical
Lambda Functions for Scheduled Jobs
Every app eventually needs scheduled jobs. Send the weekly newsletter. Clean up expired sessions. Refresh a cache. The traditional answer is a server running cron. For small jobs, that is overkill and expensive. AWS Lambda plus EventBridge replaces cron for $0/month in the free tier.
The Architecture
EventBridge sends a scheduled event to Lambda. Lambda runs the job. Total infrastructure: two AWS resources. Total monthly cost: zero for most use cases.
EventBridge Rule (schedule) -> Lambda Function -> Job RunsNo server, no cron daemon, no uptime to monitor. EventBridge handles reliability. Lambda scales from zero to thousands of invocations per second without configuration.
A Minimal Example
Here is a Lambda handler that sends a daily email:
import boto3
def handler(event, context):
ses = boto3.client('ses')
ses.send_email(
Source='me@example.com',
Destination={'ToAddresses': ['team@example.com']},
Message={
'Subject': {'Data': 'Daily Report'},
'Body': {'Text': {'Data': 'All systems operational.'}}
}
)
return {'statusCode': 200}Thirty lines including imports. Deployed once, runs forever.
The EventBridge Rule
In SAM or CloudFormation, attaching a schedule to a Lambda is one block:
DailyReport:
Type: AWS::Serverless::Function
Properties:
Handler: app.handler
Events:
Daily:
Type: Schedule
Properties:
Schedule: cron(0 13 * * ? *)cron(0 13 * * ? *) is 1pm UTC daily. EventBridge supports full cron syntax and rate expressions like rate(1 hour).
Handling Long Jobs
Lambda has a 15-minute max execution time. For jobs longer than that, I chain Lambdas via Step Functions or SQS. Each Lambda does one piece and hands off. This is cleaner than a single long-running script anyway.
Observability
CloudWatch automatically captures Lambda logs. If a job fails, I see the traceback in the console. For critical jobs, I add a CloudWatch alarm that texts me on failure. Total setup: five minutes.
Free Tier Math
Lambda: 1 million free invocations per month. At one invocation per hour, that is 720 per month. You use 0.07% of the free tier.
EventBridge: 14 million free scheduled events per month.
For hobby projects and small SaaS, scheduled jobs cost literally zero.
When to Leave Lambda
If your job runs hot for more than 15 minutes, or needs GPU, or needs persistent connections, Lambda is not the right tool. But for the 80% of scheduled jobs that are 'run this thing every X minutes,' Lambda is the simplest answer.
See the AWS Lambda documentation and the EventBridge scheduling guide for the full setup.
RELATED READING
The Consulting Shift I Am Making In Year Two
After a year of writing and building, my consulting practice is changing shape. Shorter engagements. Sharper outcomes.
ReadThe Frontend Shift: Shipping Less JavaScript In Year Two
A year ago I reached for Next.js for everything. This year I often reach for nothing.
ReadThe Serverless Lesson I Would Write On A Sticky Note
After a year of shipping serverless projects, one rule explains most of the wins and all of the losses.
Read