← Back to list

The .NET Core Feature That Saved Us 40% Cloud Cost Overnight

When working in the cloud, one fear always looms overhead —  👉 The Monthly Bill

Code Crack in Dot Net, API & SQL Learning · 2026-01-16 13:16 · 6 claps · 2.6 min read paywalled
#cloud #dotnet #api #sql #software-development
Open on Medium ↗

The .NET Core Feature That Saved Us 40% Cloud Cost Overnight

Photo credit — ChatGPT

Photo credit — ChatGPT

When working in the cloud, one fear always looms overhead — 👉 The Monthly Bill

One morning, I opened the Azure Portal and saw that the bill was 40% higher than the previous month.

The code was fine, the traffic was the same, yet why was the bill increasing?

While searching for the answer, we discovered a feature in .NET Core that reduced our cloud costs by 40% overnight.

Let me tell you the whole story.

[embed]Why I Replaced 90% of My Interfaces With Records “Interfaces everywhere” — I’ve been writing code for years with this idea in mind. But after the introduction of the…medium.com

The Real Problem: Cloud Bill ≠ Traffic

Our app:

  • .NET Core Web API
  • Azure App Service
  • EF Core + SQL Server
  • Auto-scale enabled

Everything is standard.

But:

  • CPU usage is always 70–80%
  • Memory pressure is high
  • Auto-scale is constantly adding instances

👉 This means the app was inefficient

But where?

[embed]I Thought I Understood LINQ — Until It Broke My App There was a time in my programming life when I thought that after learning LINQ in C#, I had gained a new power…medium.com

Traditional .NET Thinking (which led to our downfall)

We assumed:

  • More requests → More CPU
  • More CPU → More instances
  • More instances → Higher bill

Wrong assumption

The real problem was:

Thread Blocking

[embed]Minimal APIs vs Controllers — The Result SHOCKED Me. Starting with .NET 6, Microsoft has opened a new door for us — Minimal APIs. On the other hand, the classic Controller…medium.com

The Game Changer: async/await Done Right

Yes, the feature isn’t new. But the way we were using it — that was the problem.

Previous Code (Classic Killer)

public IActionResult GetOrders()
{
    var orders = _orderService.GetOrders(); // DB call
    return Ok(orders);
}

Inside:

public List<Order> GetOrders()
{
    return _db.Orders.ToList(); // Blocking call
}

For each request:

  • A thread is being held
  • The thread is waiting for the DB response

ASP.NET Core Thread Model: Silent Cost Generator

In ASP.NET Core:

  • Thread = Resource
  • Thread Blocked = Waste

100 concurrent requests → 100 Thread blocks

  • Auto-scale kicks in
  • New instances

The Overnight Fix: True Async I/O

We only did one thing.

Updated Code

public async Task<IActionResult> GetOrders()
{
    var orders = await _orderService.GetOrdersAsync();
    return Ok(orders);
}
public async Task<List<Order>> GetOrdersAsync()
{
    return await _db.Orders.ToListAsync();
}

No business logic changes No infrastructure changes

Only non-blocking I/O

What Changed Instantly?

Most importantly:

Auto-scaling has been turned off.

Why Does This Save Cloud Costs?

Because:

  • Async frees up threads
  • Fewer threads → fewer instances
  • Fewer instances → lower bill

The cloud provider charges based on your CPU usage, not on code inefficiency.

Common Async Mistakes (We Did Them Too)

Fake Async

Task.Run(() => GetOrders());

Mixing Sync + Async

var data = GetOrdersAsync().Result;

Blocking Calls

Thread.Sleep(1000);

These are not asynchronous; in fact, they are even worse.

Other .NET Core Features That Multiply This Benefit

  • HttpClientFactory
  • IAsyncEnumerable<T>
  • BackgroundService
  • Connection Pooling

But the foundation is:

Async All The Way

Rule We Follow Now

If there is any I/O There is no place for sync code

Final Lesson

We:

  • Did not add a new server
  • Did not upgrade the DB
  • Did not add caching

We simply used one feature of .NET Core correctly.

Result: 40% Cloud Cost Saved Overnight

If your app:

  • Auto-scales excessively
  • Has consistently high CPU usage
  • Has consistent traffic but increasing bills

메타데이터
post_id
91d8acc9cc57
slug
the-net-core-feature-that-saved-us-40-cloud-cost-overnight-91d8acc9cc57
url
https://medium.com/dot-net-sql-learning/the-net-core-feature-that-saved-us-40-cloud-cost-overnight-91d8acc9cc57
canonical_url
https://medium.com/dot-net-sql-learning/the-net-core-feature-that-saved-us-40-cloud-cost-overnight-91d8acc9cc57
author_url
https://medium.com/@CodeCrack
status
ok
fetched_at
2026-06-14 11:28:49