Lesson 8 : Advanced Scheduling Patterns
Advanced Scheduling Patterns
This build turns the scheduler into a small control plane: other services can submit tasks, business events can become tasks, urgent work jumps ahead, consumers slow down during bursts, and similar jobs are batched for efficiency.
The useful mental model is simple: the scheduler should decide when work is eligible, while the queue and workers decide how quickly work is consumed. Mixing those two responsibilities is how teams accidentally build systems that look fine in a demo and then collapse when a customer imports ten million rows.
What You Will Build
You will build a Spring Boot service with:
A task submission API for scheduler-as-a-service use cases.
Priority dispatch using an in-memory priority queue by default and RabbitMQ priority queues in Docker mode.
Token-bucket backpressure so bursts are delayed instead of overwhelming workers.
Batch accumulation for task types that become cheaper when processed together.
Event-triggered scheduling that maps external events into executable tasks.
A modern dashboard showing task state, throttling, queue depth, and recent executions.
The project runs without Docker using the in-memory queue. With Docker, it uses the official rabbitmq:3-management image.
Architecture
The API receives task requests from product services such as payments, media, analytics, or security. Each request is stored first, then published to a queue. Persisting before publishing is not ceremony; it gives support teams a record even if a worker crashes after the request is accepted.
The worker path has three gates:
Priority decides which task should be seen first.
Backpressure decides whether the worker is allowed to start more work now.
Batching decides whether the task should wait for nearby tasks with the same batch key.
This is the same idea used in systems students already know. A ride-sharing app prioritizes safety events over receipt emails. A video platform batches thumbnail generation. A commerce platform slows webhook processing during a flash sale instead of letting retries stampede the database.
Core Concept: Priority Is Not Fairness
Priority queues are often misunderstood. Priority means βsome work should move earlier,β not βlow priority work can starve forever.β In real systems, teams add aging, per-tenant quotas, or separate worker pools so low-priority work still completes.
This project keeps the implementation intentionally visible:
Keep going with the full lesson
The rest of this lesson β plus its implementation guide, runnable scripts and source code β is included with the course or an All Access plan. Create a free account to start the free lessons in every course.
Already a member? Sign in