A .NET 10 console application that benchmarks two worker scheduling strategies for processing subscription expiry — measuring the real cost difference in database reads, execution time, CPU, and memory.
| Worker | Schedule | Strategy |
|---|---|---|
OnceDailyWorker |
Once per day | Fetch and bulk-update all expired subscriptions in one operation |
EveryMinuteWorker |
Every minute (1,440×/day) | Same logic, repeated every minute to simulate a polling pattern |
Both workers produce identical results. The benchmark measures the overhead of running the same operation too frequently.
Clone the repository and run:
git clone https://github.com/tdoan123/WorkerBenchmark.git
cd WorkerBenchmark
dotnet runThe app will:
- Seed 2,000 counsellors and subscriptions (~20% expired) into a local SQLite database
- Run both workers across three benchmark rounds
- Print a performance and cost comparison table to the console
| Round | Latency | Memory Measurement |
|---|---|---|
| Round 1 | 0ms (local baseline) | Net heap delta |
| Round 2 | 1ms simulated per DB call | Net heap delta |
| Round 3 | 0ms | Total allocated bytes (GC-aware) |
Full findings, methodology, cost assumptions, and analysis are documented in the
WorkerBenchmark/
├── Models/
│ ├── Counsellor.cs # Counsellor entity + CounsellorRole enum
│ └── Subscription.cs # Subscription entity + SubscriptionStatus enum
├── Data/
│ ├── AppDbContext.cs # EF Core DbContext
│ ├── SqlCounterInterceptor.cs# Counts SELECTs/UPDATEs, injects simulated latency
│ └── SeedData.cs # Seeds 2,000 counsellors and subscriptions
├── Workers/
│ ├── OnceDailyWorker.cs # Runs once, bulk-updates expired subscriptions
│ └── EveryMinuteWorker.cs # Same logic, runs 1,440 times
├── Program.cs # Orchestrates benchmark rounds, prints results
├── REPORT.md # Full benchmark report
└── benchmark.db # SQLite database (auto-created on run)