HangFire 0.8.2 Released
21 May 2014 edit on githubBatch operations
Got tired to aim and click the Retry button on each failed job? It is much easier now, look at this:
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 being 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.
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 being 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.
Changes
- 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.
Comments