Skip to content

encryptedtouhid/CpuGuard.NET

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

38 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

CpuGuard.NET

A middleware to limit CPU usage for ASP.NET Core applications. Effortless CPU Usage Control for ASP.NET Core Applications.

Installation

Install the NuGet package:

dotnet add package CpuGuard.NET

Usage

Whole Application CPU Limit Example:

    public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
    {
        app.UseRouting();

        // Use the whole application CPU limit middleware with 20% CPU limit and 1 second monitoring interval
        app.UseCpuLimitMiddleware(20.0, TimeSpan.FromMilliseconds(1000));

        app.UseEndpoints(endpoints =>
        {
            endpoints.MapControllers();
        });
    }

Specific Request CPU Limit Example:

    public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
    {
        app.UseRouting();
        
        // Use the specific request CPU limit middleware with 15% CPU limit and 1 second monitoring interval
        app.UseCpuLimitRequestMiddleware(15.0, TimeSpan.FromMilliseconds(1000));

        app.UseEndpoints(endpoints =>
        {
            endpoints.MapControllers();
        });
    }

Resources

About

CPU Usage Control for ASP.NET Core Applications

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages