Simplified .
Net Background Jobs with
Hangfire
INTRODUCTION
Rag Dhiman
@ragdhiman
Background Job
Some .Net code which needs to be run in the
background because running it on the main thread is
not appropriate; Due to its nature or due to a specific
requirement.
Hangfire
Is an open-source framework that helps you to create,
process and manage your background jobs in a reliable
way.
Demo
Hangfire
- Without
- With
Course Overview
Getting to Know Background
Introduction
Job Types
Hangfire Dashboard and Best Practices and Scaling
Persisting Jobs Hangfire
Summary Hangfire features
Hangfire architecture
Installing Hangfire
Hangfire integration
Hangfire Pro
Hangfire Features
Why Not Do It Yourself?
Hangfire is simple to use
Management and visibility of jobs
Reliability of jobs
Can be distributed or simple
ASP.Net issues
- Request thread is king
- Multiple instances
- AppDomain and App Pool recycling
Hangfire is available and ready
Fire and forget jobs
Delayed jobs
Recurring jobs
Continuation jobs
Batch jobs
Batch continuations
Hangfire Architecture
Hangfire Server
3. Fetch next
Hangfire Client
2. Return to a
caller
4. Perform in
background
1. Create a job
Job Storage
Installing Hangfire
Route Delivery Application
- ASP.Net MVC web application
Demo
- Generates delivery schedules based on:
- Drivers
- Customers
- Deliveries
- Optimization request to generate
delivery schedules (long running task)
Route Delivery Application
ASP.Net MVC Models Data
Drivers Driver
UnitOfWork
Customers Customer
Deliveries Delivery Repositories
Schedules Schedule Route
EDM Delivery
Optimization
Request
Optimization
Requests
Optimization Engine
Demo Installing Hangfire
- Hangfire references
- Hangfire configuration
- Fire and Forget background job
- Hangfire Dashboard
Installing Hangfire
ASP.Net MVC Models Data
Drivers Driver UnitOfWork
Customers Customer
Deliveries Delivery Repositories
Schedules Schedule
EDM Route
Optimization Delivery
Request
Optimization
Request
Optimization Engine
Hangfire Hangfire
Client Server Hangfire
Storage
Hangfire Integration
Single Process
Application
Hangfire Job
Storage Hangfire Application
Web Garden
Web Application 1
Hangfire Application
Web Application N
Hangfire Job
Storage
Hangfire Application
Web Farm
Web Application 1
Hangfire Application
Server 1
Web Application N
Hangfire Job
Storage DB Server
Hangfire Application
Server N
Separate Service
Application
Hangfire Web
Client Application
Windows Service
Hangfire Job
Storage
Hangfire Server
Separate Server
Hangfire Web
Client Application
App Server
Windows Service
Hangfire Job
Storage DB Server
Hangfire Server
Backend Server
Hangfire Pro
Batch jobs
Chaining batches
Complex workflows
Support Redis storage
Performance counters
Summary Hangfire features
Hangfire architecture
Installing Hangfire
Hangfire integration
Hangfire Pro