Users Pricing

forum

Home Forums How to isolate Hangfire job processing into a separate Background Worker in ASP.NET Core? – MindStick

How to isolate Hangfire job processing into a separate Background Worker in ASP.NET Core?

Manish Sharma 17 17 Sep 2026

Currently, our ASP.NET Core Web API handles both user HTTP requests and heavy Hangfire background job executions. During peak hours, CPU usage spikes heavily, degrading API response times.

Architecture Separation

We want to move the server component (job execution) into a standalone Worker Service project while keeping job creation inside the Web API project.

Web API Enqueue Setup

// Enqueuing job from API endpoint without processing local jobs
app.MapPost("/api/reports", (IBackgroundJobClient jobClient) => 
{
    // Trigger background execution without running processing server locally
    jobClient.Enqueue(() => Console.WriteLine("Processing report..."));
    return Results.Accepted();
});

What is the best practice for sharing job interfaces and contract models between the API client project and the standalone worker service? How do we ensure that the Web API project only enqueues tasks without spawning a Background Processing server instance?


0 Answers

Markdown for AI

A clean, structured version of this page for AI assistants and LLMs.

Open .md