Batch operations

Got tired to aim and click the Retry button on each failed job? It is much easier now, look at this:

Batch operations

Never knew that animated GIF optmimzation is so boring, especially for the first time.

You are also able to select all jobs in one click. Many thanks to GitHub Issues – they gave me an idea of how to make an ideal implementation of multiple items selection.

Additional metrics

When you write the code, it is important to have an instrument to measure the performance time. ASP.NET has different diagnostic tools for this task – Glimpse, MiniProfiler and other useful ones. But they are aimed to provide information about requests only, and almost useless for background jobs – they are executed outside of a request.

I’ve implemented simple diagnostic feature (and not the replacement to full-stack performance profilers, such as dotTrace) for Hangfire Monitor, and now you are able to see the following timings in Hangfire Monitor:

  • Duration – job method + all filters performance time.
  • Latency – delay between the job creation and method invocation. This metric shows you background job invocation overhead.

Additional metrics

As you can see, you can also watch the delays between state transitions. All timings have minimum resolution in 1 second. This resolution caused by using unix timestamps in Hangfire. We need to change the things, but a bit later.

These metrics are added to the SucceededState, so they are also available to state filters.

DisableConcurrentExecution filter

This filter places a distributed lock in the beginning of a method performance and releases it after it was completed using the IServerFilter interface. The type and method name are used as a locking resource. Each storage uses its own distributed lock implementation:

  • SQL Server uses sp_getapplock stored procedure;
  • Redis implementation uses the technique described in its documentation.
[DisableConcurrentExecution(timeoutInSeconds: 10 * 60)]
public void SomeMethod()
    // Operations performed inside a distributed lock

The filter is very useful in situations when you are accessing/changing shared resources that does not provide built-in locking routines. Otherwise you should make argumentative decision between using locking system provided by the resource itself, and a custom distributed locking like this filter.

For example, in SQL Server it is better to consider using different isolation levels and table hints first.


  • Added - Batch operations on jobs for Hangfire Monitor.
  • Added - Retry and delete buttons for almost every page of Hangfire Monitor.
  • Added - Duration and latency metrics for succeeded jobs.
  • Added - Display state transition latencies on job details page.
  • Added - DisableConcurrentExecution filter.
  • Misc - Tables in Hangfire Monitor received some love.

Subscribe to monthly updates

Subscribe to receive monthly blog updates. Very low traffic, you are able to unsubscribe at any time.


Subscribe to updates

Subscribe to receive monthly blog updates. Very low traffic, you can unsubscribe at any time.