Aws Scheduler
AWS EventBridge Scheduler is a fully managed, serverless service on AWS that allows you to create, run, and manage scheduled tasks at scale. Brighter integrates with AWS EventBridge Scheduler to provide cloud-native scheduling for AWS workloads.
When to Use AWS Scheduler
AWS Scheduler is recommended when:
Running on AWS: Your application is deployed on AWS (EC2, ECS, Lambda, etc.)
Serverless Architecture: You prefer managed services over self-hosted solutions
AWS Native: You want to leverage AWS services directly
Scalability: You need to handle millions of scheduled messages
Cost Optimization: You want to pay per use without managing infrastructure
Multi-Region: You need to schedule across AWS regions
When NOT to use:
Multi-Cloud: Need scheduler to work across cloud providers
On-Premises: Application runs outside AWS
Complex Scheduling: Need advanced scheduling features (job chains, dependencies)
Dashboard: Need visual management interface
How Brighter Integrates with AWS Scheduler
Brighter provides two approaches for scheduling with AWS EventBridge Scheduler:
1. Direct to Target (Recommended)
When UseMessageTopicAsTarget = true (default), Brighter schedules messages directly to the target SNS topic or SQS queue:
Benefits:
Fewer moving parts
Lower latency (no intermediate handler)
Simpler architecture
2. Via FireAwsScheduler Message
When UseMessageTopicAsTarget = false or using request scheduler, Brighter schedules through an intermediate FireAwsScheduler message:
Use when:
Request scheduling (Send/Publish commands, not messages)
Target topic doesn't exist at scheduling time
Need centralized scheduler message handling
IAM Role Requirements
AWS EventBridge Scheduler requires an IAM role that allows it to publish to SNS topics and send messages to SQS queues.
Trust Policy
The role must trust the EventBridge Scheduler service:
Permissions Policy
The role must have permissions to publish messages:
Best Practice: Limit Resource to specific topic/queue ARNs instead of "*".
Automatic Role Creation
Brighter can create the role automatically if it doesn't exist:
Options:
OnMissingRole.Assume(default): Assume role exists, throw error if not foundOnMissingRole.Create: Create role if it doesn't exist
NuGet Packages
AWS Scheduler integration is available in two versions:
AWS SDK v4 (Recommended)
Uses the latest AWS SDK for .NET v4.
AWS SDK v3 (Legacy)
Uses AWS SDK for .NET v3 (deprecated in AWS).
Recommendation: Use V4 for new projects. Both packages provide identical Brighter functionality.
Configuration
Basic Configuration
Configure AWS Scheduler with minimal settings:
Configuration with Dispatcher (FireAwsScheduler Handler)
If using FireAwsScheduler approach, configure the Dispatcher to handle scheduler messages:
Configuration with Scheduler Groups
AWS EventBridge Scheduler supports organizing schedules into groups:
Options:
OnMissingSchedulerGroup.Assume(default): Assume group existsOnMissingSchedulerGroup.Create: Create group if it doesn't exist
Configuration with Flexible Time Window
EventBridge Scheduler supports flexible time windows for cost optimization:
A flexible time window allows AWS to batch executions for better efficiency. The schedule will execute within the specified window after the scheduled time.
Configuration with Custom Scheduler ID
Customize how Brighter generates scheduler IDs for messages and requests:
Use Cases:
Idempotency: Same ID prevents duplicate schedules
Tracking: Correlate scheduled tasks with business entities
Debugging: Meaningful IDs in AWS Console
Code Examples
Basic Scheduling with Delay
Schedule a command to execute after a delay:
Scheduling with Absolute Time
Schedule for a specific time:
Cancelling a Scheduled Job
Cancel a scheduled task before it executes:
Publishing Events with Delay
Schedule an event to be published:
Scheduling Modes Comparison
Configuration
UseMessageTopicAsTarget = true
UseMessageTopicAsTarget = false
Use Case
Message scheduling
Request scheduling
Latency
Lower (direct)
Higher (2-hop)
Components
Fewer
More (requires Dispatcher)
Flexibility
Target must exist
More flexible
Recommended For
Production messages
Requests and commands
Comparison with Other Schedulers
Cloud Native
AWS Only
❌
❌
❌
Serverless
✅
❌
❌
❌
Persistence
AWS Managed
Database
Database
None
Dashboard
AWS Console
Limited
Yes
No
Cancellation
✅
✅
✅
✅
Reschedule
✅
✅
✅
✅
Cost Model
Pay-per-use
Infrastructure
Infrastructure
Free
Setup Complexity
Moderate (IAM)
Moderate
Easy
Minimal
Production Ready
✅
✅
✅
❌
Multi-Cloud
❌
✅
✅
✅
Strong Naming
✅
✅
❌
✅
When to use AWS Scheduler:
Running on AWS infrastructure
Prefer serverless/managed services
Need high scalability
Cost-effective pay-per-use model
Best Practices
1. Use Direct to Target for Messages
2. Limit IAM Role Permissions
3. Use Scheduler Groups for Organization
4. Handle OnConflict Appropriately
5. Use Custom Scheduler IDs for Idempotency
6. Monitor AWS Scheduler Metrics
7. Use Flexible Time Windows for Cost Optimization
8. Test with LocalStack
Troubleshooting
Schedules Not Executing
Symptom: Schedules created but never fire
Possible Causes:
IAM role missing or incorrect permissions
Target topic/queue doesn't exist
Schedule created in wrong region
FireAwsScheduler handler not configured
Solutions:
Access Denied Errors
Symptom: AccessDeniedException when creating schedules
Cause: Application credentials lack EventBridge Scheduler permissions
Solution:
Schedule Conflicts
Symptom: ConflictException when creating schedule
Cause: Schedule with same ID already exists
Solutions:
High Costs
Symptom: Unexpected AWS Scheduler costs
Causes:
Too many one-time schedules created and not cleaned up
Short polling intervals
Solutions:
Migration from Other Schedulers
From InMemory Scheduler
No code changes required - just swap the scheduler factory!
From Quartz or Hangfire to AWS Scheduler
Benefits of moving to AWS Scheduler:
No database required
No server maintenance
Automatic scaling
Pay-per-use pricing
Related Documentation
Brighter Scheduler Support - Overview of scheduling in Brighter
Quartz Scheduler - Alternative for non-AWS environments
Hangfire Scheduler - Alternative with dashboard
InMemory Scheduler - For testing and development
Azure Scheduler - Azure equivalent
AWS SNS Configuration - Configuring AWS messaging
External Links
LocalStack EventBridge - For local testing
Summary
AWS EventBridge Scheduler is a cloud-native, serverless scheduling solution perfect for:
AWS Workloads - Native integration with AWS services
Serverless Applications - No infrastructure to manage
High Scalability - Millions of schedules supported
Cost Optimization - Pay only for what you use
Recommended for production when running on AWS infrastructure. Consider Quartz.NET or Hangfire for multi-cloud or on-premises deployments.
Key Decision Factors:
✅ Use AWS Scheduler if: Running on AWS, prefer managed services, need scalability
✅ Use Quartz if: Multi-cloud, complex scheduling, need job clustering
✅ Use Hangfire if: Need dashboard, simple setup, OK without strong naming
✅ Use InMemory if: Testing only, not for production
Last updated
Was this helpful?
