DynaScaleHangfire 1.0.23
See the version list below for details.
dotnet add package DynaScaleHangfire --version 1.0.23
NuGet\Install-Package DynaScaleHangfire -Version 1.0.23
<PackageReference Include="DynaScaleHangfire" Version="1.0.23" />
<PackageVersion Include="DynaScaleHangfire" Version="1.0.23" />
<PackageReference Include="DynaScaleHangfire" />
paket add DynaScaleHangfire --version 1.0.23
#r "nuget: DynaScaleHangfire, 1.0.23"
#:package DynaScaleHangfire@1.0.23
#addin nuget:?package=DynaScaleHangfire&version=1.0.23
#tool nuget:?package=DynaScaleHangfire&version=1.0.23
DynaScaleHangfire
A dynamic scaling extension for Hangfire that provides real-time server and queue monitoring with dynamic worker count management.
Features
- Server & Queue Monitoring: Monitor individual servers and their queue configurations
- Real-time Worker Count Management: Update worker counts for specific server-queue combinations
- Bulk Operations: Apply worker count changes to all servers for a specific queue
- Server Status Tracking: Monitor server health and activity status
- Machine-based Grouping: Group servers by machine name for better organization
- RESTful API: Simple HTTP endpoints for server-queue management
- Web Dashboard Integration: Seamless integration with Hangfire dashboard
- Automatic Static Files: JavaScript files are automatically copied to build output
Installation
NuGet Package
dotnet add package DynaScaleHangfire
Manual Installation
- Clone this repository
- Build the project
- 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 with custom options
builder.Services.AddHangfireDynaScale(new DynaScaleOptions
{
MaxWorkerCount = 50,
DefaultWorkerCount = 10
});
// Or use default options
builder.Services.AddHangfireDynaScale();
2. Configure Middleware
var app = builder.Build();
// Automatically creates wwwroot directory and adds static files middleware
app.UseHangfireDynaScaleWithStaticFiles();
3. Access Dashboard
Navigate to /dynamic-scaling
to access the DynaScale dashboard.
Configuration
DynaScaleOptions
public sealed record DynaScaleOptions
{
public int MaxWorkerCount { get; init; } = 100;
public int DefaultWorkerCount { get; init; } = Environment.ProcessorCount * 5;
}
MaxWorkerCount
: Maximum number of workers that can be set for any queue (default: 100)DefaultWorkerCount
: Default worker count for new servers (default: Environment.ProcessorCount * 5)
How It Works
DynaScaleHangfire uses Hangfire's monitoring APIs to provide real-time information about your Hangfire servers and their queue configurations. The system allows you to:
- View all active Hangfire servers grouped by machine name
- Monitor server health and activity status
- Modify worker counts for specific server-queue combinations
- Apply worker count changes to all servers for a specific queue
- Monitor queue performance and job processing
The web dashboard provides real-time monitoring of:
- Machine names (grouped servers)
- Queue configurations per server
- Current worker counts
- Server activity status
- Last heartbeat information
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 # Data models
├── Services/
│ ├── HangfireServerManager.cs # Core monitoring logic
│ └── IHangfireServerManager.cs # Service interface
├── build/
│ └── DynaScaleHangfire.targets # MSBuild targets for file copying
└── wwwroot/
└── js/
└── dynamic-scaling.js # Frontend JavaScript
API Endpoints
GET /dynamic-scaling/servers
- Get all server-queue configurations grouped by machinePOST /dynamic-scaling/servers/{serverName}/queues/{queueName}/set-workers
- Update worker count for a specific server-queue
Request Body for Set Workers
{
"workerCount": 5,
"applyToAllServers": false
}
workerCount
: The new worker count to setapplyToAllServers
: If true, applies the worker count to all servers for this queue
Data Models
ServerInfo
public sealed record ServerInfo
{
public string ServerName { get; init; } // Machine name
public bool IsActive { get; init; } // Server activity status
public DateTime LastHeartbeat { get; init; } // Last heartbeat time
public List<QueueInfo> Queues { get; init; } // Queue configurations
}
QueueInfo
public sealed record QueueInfo
{
public string QueueName { get; init; } // Queue name
public int CurrentWorkerCount { get; init; } // Current worker count
public int MaxWorkerCount { get; init; } // Maximum worker count
}
SetWorkersRequest
public sealed record SetWorkersRequest
{
public int WorkerCount { get; init; }
public bool ApplyToAllServers { get; init; }
}
Development
Prerequisites
- .NET 7.0 SDK or later
- Visual Studio 2022 or VS Code
- Hangfire storage provider (SQL Server, Redis, PostgreSQL, etc.)
Building
dotnet restore
dotnet build
Creating NuGet Package
dotnet pack -c Release
Contributing
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature
) - Commit your changes (
git commit -m 'Add some amazing feature'
) - Push to the branch (
git push origin feature/amazing-feature
) - Open a Pull Request
Contact
- Project Link: https://github.com/anilterzi/DynaScaleHangfire
- Issues: https://github.com/anilterzi/DynaScaleHangfire/issues
Acknowledgments
- Built on top of Hangfire
- Uses Hangfire's monitoring APIs for real-time data
- Community contributions and feedback
Product | Versions 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. |
-
net7.0
- Hangfire.Core (>= 1.8.6)
- Microsoft.AspNetCore.Mvc.Core (>= 2.2.5)
- Microsoft.Extensions.DependencyInjection.Abstractions (>= 7.0.0)
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 | 127 | 7/3/2025 | |
1.0.25 | 131 | 7/3/2025 | |
1.0.24 | 134 | 7/3/2025 | |
1.0.23 | 136 | 7/3/2025 | |
1.0.22 | 128 | 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.14 | 203 | 6/30/2025 | |
1.0.13 | 206 | 6/30/2025 | |
1.0.12 | 206 | 6/30/2025 | |
1.0.11 | 207 | 6/30/2025 | |
1.0.10 | 209 | 6/30/2025 | |
1.0.9 | 177 | 6/27/2025 | |
1.0.8 | 118 | 6/27/2025 | |
1.0.7 | 124 | 6/27/2025 | |
1.0.6 | 125 | 6/27/2025 | |
1.0.4 | 163 | 6/27/2025 | |
1.0.3 | 175 | 6/26/2025 | |
1.0.2 | 289 | 6/26/2025 |