Open-Awesome
CategoriesAlternativesStacksSelf-HostedExplore
Open-Awesome

© 2026 Open-Awesome. Curated for the developer elite.

TermsPrivacyAboutGitHubRSS
  1. Home
  2. Java
  3. shedlock

shedlock

Apache-2.0Java

A distributed lock for scheduled tasks ensuring at-most-once execution across multiple nodes.

GitHubGitHub
4.2k stars568 forks0 contributors

What is shedlock?

ShedLock is a Java library that provides distributed locking for scheduled tasks, ensuring they execute at most once across multiple nodes in a cluster. It solves the problem of duplicate task execution in horizontally scaled applications by using an external store (like a database or Redis) to coordinate locks. Tasks are annotated with `@SchedulerLock`, and if a lock is held by one node, other nodes skip execution rather than waiting.

Target Audience

Java developers building Spring Boot, Micronaut, or Quarkus applications with scheduled tasks (e.g., cron jobs) that need to run reliably in clustered or cloud environments. It's especially useful for teams deploying microservices where multiple instances might trigger the same scheduled logic.

Value Proposition

Developers choose ShedLock for its simplicity, robust integration with popular frameworks, and support for numerous lock providers. Unlike full distributed schedulers, it focuses solely on preventing concurrent execution, making it lightweight and easy to adopt without overhauling existing scheduling setups.

Overview

Distributed lock for your scheduled tasks

Use Cases

Best For

  • Ensuring cron jobs run once per cluster in Kubernetes deployments
  • Preventing duplicate processing in Spring Boot scheduled tasks
  • Coordinating batch jobs across multiple application instances
  • Safeguarding idempotent but non-parallelizable tasks (e.g., data aggregation)
  • Adding distributed locking to legacy scheduled tasks with minimal code changes
  • Building fault-tolerant scheduled tasks with auto-expiring locks

Not Ideal For

  • Teams needing a full-featured distributed scheduler with job dependencies, retries, or dynamic scheduling
  • Applications where tasks must block and wait for locks rather than skip execution
  • Environments with significant clock drift between nodes, as time-based locks assume synchronization
  • Projects requiring high-reliability locks with cache-based providers (e.g., Memcached warns of premature eviction)

Pros & Cons

Pros

Extensive Lock Provider Support

Supports over 30 backends including JDBC, Redis, Mongo, and cloud services, making it adaptable to diverse infrastructures without vendor lock-in.

Framework-Agnostic Integration

Works seamlessly with Spring, Micronaut, CDI (Quarkus), and standalone Java, minimizing framework dependencies and easing adoption.

At-Most-Once Execution

Ensures scheduled tasks run at most once per cluster using distributed locks, preventing duplicate processing in scaled deployments.

Simple Annotation-Based Setup

Just annotate methods with @SchedulerLock and configure a lock provider, requiring minimal code changes to existing scheduled tasks.

Cons

Not a Full Scheduler

Lacks job orchestration features like retries, dependencies, or dynamic scheduling; the README explicitly states it's just a lock, not a scheduler.

Time-Based Lock Risks

Duplicate execution can occur if tasks exceed lockAtMostFor or clocks are unsynchronized, as noted in the caveats section, requiring careful configuration.

External Storage Overhead

Requires setting up and maintaining an external store (e.g., database tables for JDBC), adding operational complexity compared to in-memory solutions.

Provider-Specific Limitations

Some lock providers have reliability issues; for example, the README warns that Memcached may release locks prematurely, and R2DBC support is experimental.

Frequently Asked Questions

Quick Stats

Stars4,167
Forks568
Contributors0
Open Issues22
Last commit3 days ago
CreatedSince 2016

Tags

#concurrency-control#java-library#scheduled-tasks#redis#distributed-locking#quarkus#spring-boot#task-scheduling

Built With

S
Spring Framework
M
MongoDB
J
JDBC
D
DynamoDB
Z
Zookeeper
J
Java
R
Redis

Included in

Java47.5k
Auto-fetched 23 hours ago

Related Projects

JobRunrJobRunr

An extremely easy way to perform background processing in Java. Backed by persistent storage. Open and free for commercial use.

Stars2,995
Forks319
Last commit3 days ago
db-schedulerdb-scheduler

Persistent cluster-friendly scheduler for Java

Stars1,568
Forks246
Last commit5 days ago
easy-batcheasy-batch

The simple, stupid batch framework for Java

Stars624
Forks196
Last commit3 years ago
SundialSundial

A Light-weight Job Scheduling Framework

Stars280
Forks55
Last commit11 days ago
Community-curated · Updated weekly · 100% open source

Found a gem we're missing?

Open-Awesome is built by the community, for the community. Submit a project, suggest an awesome list, or help improve the catalog on GitHub.

Submit a projectStar on GitHub