DynaScaleHangfire 1.0.7

There is a newer version of this package available.
See the version list below for details.
dotnet add package DynaScaleHangfire --version 1.0.7
                    
NuGet\Install-Package DynaScaleHangfire -Version 1.0.7
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="DynaScaleHangfire" Version="1.0.7" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="DynaScaleHangfire" Version="1.0.7" />
                    
Directory.Packages.props
<PackageReference Include="DynaScaleHangfire" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add DynaScaleHangfire --version 1.0.7
                    
#r "nuget: DynaScaleHangfire, 1.0.7"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package DynaScaleHangfire@1.0.7
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=DynaScaleHangfire&version=1.0.7
                    
Install as a Cake Addin
#tool nuget:?package=DynaScaleHangfire&version=1.0.7
                    
Install as a Cake Tool

DynaScaleHangfire

A dynamic scaling extension for Hangfire that provides real-time queue monitoring and automatic server scaling capabilities.

Features

  • Real-time Queue Monitoring: Monitor job queue lengths and processing status
  • Dynamic Server Scaling: Automatically scale Hangfire servers based on queue load
  • RESTful API: Simple HTTP endpoints for queue management
  • Web Dashboard Integration: Seamless integration with Hangfire dashboard
  • Configurable Scaling Rules: Customizable thresholds and scaling policies
  • Health Monitoring: Built-in health checks and status reporting

Installation

NuGet Package

dotnet add package DynaScaleHangfire

Manual Installation

  1. Clone this repository
  2. Build the project
  3. Reference the built assembly in your project

Quick Start

1. Add Services

using Hangfire.DynaScale.Extensions;
using Hangfire.DynaScale.Models;

var builder = WebApplication.CreateBuilder(args);

// Add DynaScale services
builder.Services.AddHangfireDynaScale(new HangfireSettings
{
    MinWorkerCount = 1,
    MaxWorkerCount = 10,
    ScaleUpThreshold = 5,
    ScaleDownThreshold = 2,
    CheckIntervalSeconds = 30
});

2. Configure Middleware

Option A: Automatic Setup (Recommended)

var app = builder.Build();

// Automatically creates wwwroot directory and adds static files middleware
app.UseHangfireDynaScaleWithStaticFiles();

Option B: Manual Setup

var app = builder.Build();

// Add static files middleware manually
app.UseStaticFiles();

// Add DynaScale routes
app.UseHangfireDynaScale();

3. Access Dashboard

Navigate to /dynamic-scaling to access the DynaScale dashboard.

Configuration

The HangfireSettings class allows you to configure:

  • MinWorkerCount: Minimum number of worker processes
  • MaxWorkerCount: Maximum number of worker processes
  • ScaleUpThreshold: Queue length threshold to trigger scale up
  • ScaleDownThreshold: Queue length threshold to trigger scale down
  • CheckIntervalSeconds: How often to check queue status

How It Works

DynaScaleHangfire monitors your Hangfire job queues in real-time and automatically scales the number of worker processes based on the configured thresholds. When the queue length exceeds the scale-up threshold, it increases the worker count. When the queue length falls below the scale-down threshold, it decreases the worker count.

The web dashboard provides real-time monitoring of:

  • Current queue lengths
  • Active worker count
  • Scaling history
  • System performance metrics

Automatic wwwroot Creation

This package automatically creates a wwwroot directory in your project if it doesn't exist when using UseHangfireDynaScaleWithStaticFiles(). This ensures that Hangfire's dashboard static files are properly served.

Project Structure

DynaScaleHangfire/
├── Controllers/
│   └── DynaScaleController.cs          # REST API endpoints
├── Extensions/
│   ├── ApplicationBuilderExtensions.cs # Middleware configuration
│   └── ServiceCollectionExtensions.cs  # DI configuration
├── Models/
│   └── HangfireSettings.cs            # Configuration models
├── Services/
│   ├── HangfireServerManager.cs       # Core scaling logic
│   └── IHangfireServerManager.cs      # Service interface
└── wwwroot/
    └── js/
        └── dynamic-scaling.js         # Frontend JavaScript

Configuration Options

Setting Type Default Description
MinWorkerCount int 1 Minimum number of worker servers
MaxWorkerCount int 10 Maximum number of worker servers
ScaleUpThreshold int 100 Queue length threshold for scaling up
ScaleDownThreshold int 10 Queue length threshold for scaling down
CheckIntervalSeconds int 30 Interval between scaling checks

Development

Prerequisites

  • .NET 7.0 SDK or later
  • Visual Studio 2022 or VS Code
  • SQL Server (for Hangfire storage)

Building

dotnet restore
dotnet build
dotnet test

Testing

dotnet test

Creating NuGet Package

dotnet pack -c Release

Contributing

  1. Fork the repository
  2. Create a feature branch (git checkout -b feature/amazing-feature)
  3. Commit your changes (git commit -m 'Add some amazing feature')
  4. Push to the branch (git push origin feature/amazing-feature)
  5. Open a Pull Request

License

This project is licensed under the MIT License - see the LICENSE file for details.

Contact

Acknowledgments

  • Built on top of Hangfire
  • Inspired by modern microservices scaling patterns
  • Community contributions and feedback
Product Compatible and additional computed target framework versions.
.NET net7.0 is compatible.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 was computed.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed.  net9.0 was computed.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 was computed.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
1.0.36 90 7/4/2025
1.0.35 95 7/4/2025
1.0.34 90 7/4/2025
1.0.33 94 7/4/2025
1.0.32 107 7/4/2025
1.0.31 124 7/4/2025
1.0.30 116 7/4/2025
1.0.29 143 7/3/2025
1.0.28 127 7/3/2025
1.0.27 136 7/3/2025
1.0.26 126 7/3/2025
1.0.25 130 7/3/2025
1.0.24 133 7/3/2025
1.0.23 135 7/3/2025
1.0.22 127 7/3/2025
1.0.21 143 6/30/2025
1.0.20 129 6/30/2025
1.0.19 124 6/30/2025
1.0.18 122 6/30/2025
1.0.17 127 6/30/2025
1.0.16 126 6/30/2025
1.0.15 205 6/30/2025 1.0.15 is deprecated because it is no longer maintained and has critical bugs.
1.0.14 203 6/30/2025 1.0.14 is deprecated because it is no longer maintained and has critical bugs.
1.0.13 206 6/30/2025 1.0.13 is deprecated because it is no longer maintained and has critical bugs.
1.0.12 206 6/30/2025 1.0.12 is deprecated because it is no longer maintained and has critical bugs.
1.0.11 207 6/30/2025 1.0.11 is deprecated because it is no longer maintained and has critical bugs.
1.0.10 209 6/30/2025 1.0.10 is deprecated because it is no longer maintained and has critical bugs.
1.0.9 177 6/27/2025 1.0.9 is deprecated because it is no longer maintained and has critical bugs.
1.0.8 118 6/27/2025 1.0.8 is deprecated because it is no longer maintained and has critical bugs.
1.0.7 124 6/27/2025 1.0.7 is deprecated because it is no longer maintained and has critical bugs.
1.0.6 125 6/27/2025 1.0.6 is deprecated because it is no longer maintained and has critical bugs.
1.0.4 163 6/27/2025 1.0.4 is deprecated because it is no longer maintained and has critical bugs.
1.0.3 175 6/26/2025 1.0.3 is deprecated because it is no longer maintained and has critical bugs.
1.0.2 289 6/26/2025 1.0.2 is deprecated because it is no longer maintained and has critical bugs.