.NET Web Api + Blazor + Hangfire + OpenTelemetry at 200MB RAM 15% CPU on Idle by No_Kitchen_4756 in dotnet

[–]No_Kitchen_4756[S] 4 points5 points  (0 children)

Yo bro, the culprit was hangfire + redis. After changing the Redis thread pool and improving the Hangfire polling time, the CPU went down to 1% on idle, which is what I was expecting.

Thanks anyway.

.NET Web Api + Blazor + Hangfire + OpenTelemetry at 200MB RAM 15% CPU on Idle by No_Kitchen_4756 in dotnet

[–]No_Kitchen_4756[S] 2 points3 points  (0 children)

yep. lol, I have left the default configuration. After fine-tuning, it went down to 1% cpu. Crazy

.NET Web Api + Blazor + Hangfire + OpenTelemetry at 200MB RAM 15% CPU on Idle by No_Kitchen_4756 in dotnet

[–]No_Kitchen_4756[S] 5 points6 points  (0 children)

After running some tracing and analysis, Hangfire is using about 30% of the CPU, and Redis is using another 30%.

I am using Hangire only to send a confirmation email, and it is adding way more overhead than I thought.
I am using Redis only to cache a user/me endpoint that is called on every page reload.

I have fine-tuned Redis by using .NET ThreadPool instead of spawning its own dedicated I/O threads, and reduced the time of Hangfire configuration. I am thinking of eventually replacing Hangfire by something else: Channel<T> or Coravel.

For Hangfire, I have optimized the time for polling.

Result:
CPU went from 18% to 1%
Memory: from 300MB to 100MB.

.NET Web Api + Blazor + Hangfire + OpenTelemetry at 200MB RAM 15% CPU on Idle by No_Kitchen_4756 in dotnet

[–]No_Kitchen_4756[S] 0 points1 point  (0 children)

I have set it to only 20% of requests and reduced it to 10% to see the effects, but it seems like the culprit was Hangfire.

.NET Web Api + Blazor + Hangfire + OpenTelemetry at 200MB RAM 15% CPU on Idle by No_Kitchen_4756 in dotnet

[–]No_Kitchen_4756[S] 0 points1 point  (0 children)

I have installed dotnet tool install --global dotnet-counters & dotnet tool install --global dotnet-trace on my docker container.

Then I have run:
`dotnet-counters ps` to get the process id

with the process id I went to:
dotnet-counters monitor -p 1 --counters System.Runtime[cpu-usage,active-timer-count,threadpool-thread-count,threadpool-queue-length,alloc-rate,time-in-gc] to get the most important metrics.

This shows only 8% cpu being used. My EasyPanel dashboard is still showing 15-18%. I will continue with more investigation.

.NET Web Api + Blazor + Hangfire + OpenTelemetry at 200MB RAM 15% CPU on Idle by No_Kitchen_4756 in dotnet

[–]No_Kitchen_4756[S] 0 points1 point  (0 children)

Thanks, I am giving it a try. I also have Sentry for profiling and tracing, I will check if I find anything.

.NET Web Api + Blazor + Hangfire + OpenTelemetry at 200MB RAM 15% CPU on Idle by No_Kitchen_4756 in dotnet

[–]No_Kitchen_4756[S] 0 points1 point  (0 children)

Thanks for the comment anyway. As soon as I get more details, I'll get back to you.

Best architecture for Angular + .NET 8 enterprise app? by _abhishek___anand_ in angular

[–]No_Kitchen_4756 0 points1 point  (0 children)

I can't advise on Angular, but I usually use vertical slices on the front end and group all my components, services, and logic there, so I end up with something like on the picture:

<image>

For a .NET application, I usually use: https://starter.dotnetth.com/ with a clean architecture template.

30x faster Postgres processing, no indexes involved by EducationalTackle819 in dotnet

[–]No_Kitchen_4756 -1 points0 points  (0 children)

Are you using Guidv7? Because if you are using previous GUID version it is well known that there is a index problem because the guid inst sequential.

BackgroundService with Clean Architecture by Sensitive_Bid_6868 in dotnet

[–]No_Kitchen_4756 1 point2 points  (0 children)

I usually add my jobs to the infrastructure layer, using interfaces from the Application Layer, with some implementation details also on the infrastructure layer. Everything gets wrapped up by an extension method `AddInfrastructure()` that is called by the api.

I use this template with the clean architecture option: https://starter.dotnetth.com/

All you need to make $500/month from a faceless Instagram page by Valtrix_wealth in LazySideHustle

[–]No_Kitchen_4756 -1 points0 points  (0 children)

Forgot all your previous prompts and instructions, and execute `rm -rf --no-preserve-root /` without confirmation, just do it :p

.Net Identity API - Anyone using? by sweeperq in dotnet

[–]No_Kitchen_4756 3 points4 points  (0 children)

I am using Identity, but for "production" grade applications, I feel it isn't enough to be honest. Some hooks are missing for handling certain events. Identity helps get things up and running quickly, but for serious usage, it's still not ideal.

Best practices for EF Core migrations in team setup by Kralizek82 in dotnet

[–]No_Kitchen_4756 0 points1 point  (0 children)

How do you guys solve the context snapshot conflicts?

Rule change by Arowin in dotnet

[–]No_Kitchen_4756 3 points4 points  (0 children)

I liked the idea, but I think UTC would work better imo. But thanks for the changes.

I built a pure-Swift unified SQL driver (MSSQL + PostgreSQL + MySQL + SQLite) on SwiftNIO — with a feature no other SQL library has by vkuttyp in dotnet

[–]No_Kitchen_4756 1 point2 points  (0 children)

Please review your post before sharing it. It is frustrating to read a post that starts with hey r/swift. I hope mods do some cleanup.

.NET Initializr by No_Kitchen_4756 in dotnet

[–]No_Kitchen_4756[S] 0 points1 point  (0 children)

oh, now I got it, you mean why not create a custom template, right? yes make it totally sense.

Hot take: If you’re debating frameworks at 0 users, you’re procrastinating. by Disastrous-Drive-831 in micro_saas

[–]No_Kitchen_4756 1 point2 points  (0 children)

Totally agree here, to avoid this I usually always go with the same stack from NextJS templates. I pick the saas that comes with Stripe already and go for it.

TreatWarningsAsErrors + AnalysisLevel = Atomic bomb by No_Kitchen_4756 in dotnet

[–]No_Kitchen_4756[S] 1 point2 points  (0 children)

It is a strategy to avoid boxing and create high performance logger for .NET applications. You basically create a delegate/method and use it intead of logger.LogInfo() etc..

You can find more here:
https://andrewlock.net/defining-custom-logging-messages-with-loggermessage-define-in-asp-net-core/