Skip to main content

NightShift compared with Hangfire

Masterly.NightShift is a remastered fork of Hangfire 1.8.25. It keeps Hangfire's programming model and can read your existing Hangfire SQL Server data. It was refactored for .NET 8 and later, and a source generator writes direct calls to your job methods instead of calling them through reflection. Features that Hangfire leaves to paid add-ons or community packages are built in.

NightShift is an independent project. It isn't affiliated with, endorsed by or supported by Hangfire OÜ. The origin of the code and its licenses are described in NOTICE.md.

This page helps you choose between them. To move an existing app, read Migrating from Hangfire.

At a glance​

Hangfire 1.8.25NightShift 1.0
Platforms.NET Framework 4.5.1 and later, .NET Standard 1.3 and 2.0.NET 8 and later only
Calling your job methodMethodInfo.InvokeSource-generated direct call. A compiled delegate when the generator can't see the method, reflection as a last resort
JSONNewtonsoft.JsonSystem.Text.Json, with no Newtonsoft.Json dependency
BatchesPaid (Hangfire Pro)Included: BatchJob
Creating many jobs at onceThrough paid batchesIncluded: EnqueueMany
Round trips to SQL ServerFour to create a job, three for every commitTwo to create a job, one for every commit; concurrent callers share them
Waiting for a set of jobs (fan-in)Through paid batchesIncluded: ContinueJobWithAll, ContinueJobWithAny
Concurrency limits and rate limits[DisableConcurrentExecution]. Semaphores and rate limiters are paid (Hangfire Ace)Included: [Throttle], [RateLimit]
Circuit breakerNot includedIncluded: [CircuitBreaker]
Duplicate preventionNot includedIncluded: [PreventDuplicates]
Timing rules[LatencyTimeout][LatencyTimeout], [JobTimeout], [Deadline], [RunWindow], [Blackout], [SkipIfLate]
Retries[AutomaticRetry][AutomaticRetry], RetryLaterException, TerminateJobException, [RetryInProcess]
Wrapping the method callFilters onlyFilters and interceptors
Progress, console, resume after failureNot included (community packages)Included: IJobConsole, checkpoints
Plain-English timesNot included"tomorrow at 9am", "every 10 minutes from 9am to 5pm on weekdays"
MonitoringDashboard (community packages for the rest)Dashboard, OpenTelemetry, Prometheus, health checks, alerts, audit log
DashboardJobs, queues, servers, retries, recurring jobsThe same, plus insights, failure clusters, lineage, job diagnosis, job catalog, timeline, wallboard, exports
Stopping work before a deployNot includedDrain mode, for the system, a queue or a server
StorageSQL Server. Redis is paid (Hangfire Pro). Many community storagesSQL Server, Entity Framework Core (PostgreSQL, MySQL, SQLite and other providers), Redis, MongoDB and in memory, all passing one conformance suite. Other storages have to be written or ported
SupportCommunity, or paid plans with email supportCommunity, through GitHub
LicenseLGPL v3, with paid plans for the add-onsMIT AND LGPL-3.0-or-later, with every feature above included
Track recordUsed in production for more than a decadeNew: 1.0 is the first release

Hangfire's paid features are described on its pricing, Pro and Ace pages. The "not included" entries were checked against the Hangfire.Core 1.8.25 package.

Why choose NightShift​

  • You'd otherwise pay for batches or throttling. Batches, fan-in continuations, semaphores and rate limits are in the box, with no subscription.
  • You run many kinds of job and need to protect what they call. Circuit breakers, rate limits, duplicate prevention, deadlines and run windows are attributes on the job method.
  • You want to see what your jobs are doing. Live progress and console output, plus "why isn't it running?" diagnosis, failure clusters, OpenTelemetry and Prometheus, come without extra packages.
  • Your app is on .NET 8 or later and you want a smaller dependency set. There's no Newtonsoft.Json, and no code for .NET Framework hosts.
  • You already run Hangfire on SQL Server. The API is close to the same, and your existing jobs and recurring jobs keep working after the migration.

When to stay on Hangfire​

  • Your app runs on .NET Framework, or on .NET 7 or earlier.
  • You use Redis or another storage that NightShift doesn't have.
  • You depend on third-party Hangfire extensions. They're built against Hangfire's namespaces and would have to be ported.
  • You need a vendor with paid support, or a library with a long production record.

Benchmarks​

Measured against Hangfire 1.8.25 on .NET 10 and SQL Server 2022:

  • Creating jobs: a loop of Enqueue calls is about 1.25 times faster, 64 callers at once about twice as fast, and EnqueueMany creates jobs over 20 times faster than a loop.
  • Processing: about the same by default, and about 1.7 times faster with AllowDelayedDurability.
  • Memory: running a job allocates about 60% less, and serializing one over 80% less.
  • Calling the job method: about 4 times faster, which saves a few nanoseconds per job.

Benchmarks has every number, what it means, and how to run the benchmarks yourself.

See also​