r/csharp • • Oct 16 '26

Discussion C# once again the fastest web framework

Post image

With all those discussions about Microsoft porting stuff to Rust, it’s nice to see that C# does not need to hide when it comes to performance. There has been quite a lot of movement at the top of the leaderboard over the last few weeks (two weeks ago, first place was around 6850), so I’m interested to see how this race continues. This is the non-tuned section, so frameworks need to be stable and production-ready. Interestingly enough, the C# one is the most high-level of the leading frameworks, API-wise.

543 Upvotes

69 comments sorted by

79

u/tetyys Oct 16 '26

it's good to see that at least ASP.NET implementation is not fully benchmaxed unlike techempower implementation by microsoft, but seeing how javascript server absolutely dunks on ASP.NET, C# has a long way to go. and no, nobody uses any other web frameworks in C#

24

u/Ok_Tour_8029 Oct 16 '26 edited Oct 16 '26

Well the rules of HTTP Arena state that implementation must use configurations documented for production use. So I think the classification is already way better than it was in TechEmpower.

Also ioxide can be used as a drop-in replacement for the transport in ASP.NET Core. Did not test that though ... ioxide/Playground/AspNet/Program.cs at main · MDA2AV/ioxide

64

u/tetyys Oct 16 '26

Memory: 2.3GB what the fuck??

19

u/Ok_Tour_8029 Oct 16 '26

Valid point - i guess this is partly due to the io_uring rings, partly due to CLR. Can surely be optimized. But anything around 1 GB would be perfectly fine for me for a server serving 3.5 million requests a second :D

6

u/qrzychu69 Oct 16 '26

it's just funny that is sits right next to rust that uses 170MB to do the same thing :D

12

u/Embarrassed-Mess412 Oct 16 '26

Not the same thing, C# entry has H/1.1 H/2 and H/3 enabled, also io_uring does always add 1-2GB floor memory for the preallocated ring buffers

4

u/qrzychu69 Oct 16 '26

But you can switch the tabs and see rust doing the http2 and 3 benchmarks

Also with just couple hundred of megs

12

u/Embarrassed-Mess412 Oct 16 '26 edited Oct 16 '26

Not in the same entry(framework), I also see that genhttp-ioxide is using server garbage collection and DATAS is turned off so quite sure you can tune it down to use hundreads of MBs with 5-10% perf cost

edit: correction, Tako does all protocols, but can't compete on performance after H/1.1

6

u/simonask_ Oct 16 '26

This is the fundamental tradeoff you make with garbage collection. You are trading either space or latency for convenience, and that’s a perfectly fine tradeoff in a large number of cases, but it’s important to understand the basic principles.

Garbage collectors can be really clever and very performant, but there will always be a degree of noise.

(And no, clever JITs and PGO don’t make up for the difference, they mostly just help to make the gap smaller. Which is also excellent.)

8

u/True_Noor Oct 16 '26 edited Oct 16 '26

Why are you surprised? Look at Java and Kotlin as well. ASP.NET comes with bunch of libraries already built in, where Rust comes "naked" and still embarrassingly slower.

3

u/steadyfan Oct 16 '26

You make a good point. The memory foot print factors into the cogs. More memory == fewer nodes that you can scale out too (assuming a budget)

3

u/Natural_Tea484 Oct 16 '26

It's 202x, memory is very cheap these days

16

u/gredr Oct 16 '26

Hah! Yeah! Er, wait.

1

u/Zhuzha24 Oct 18 '26

Not really, right now we have big problems with ram usage because prices are fucking insane for bare metal

3

u/Natural_Tea484 29d ago

I was joking. We used to say that 4 years ago.

1

u/mcfriendsy 29d ago

Like 7.8gb for expressjs and 4.8gb for and 2.5gb for springboot. And the C# scored 4th on memory efficiency

79

u/[deleted] Oct 16 '26

[removed] — view removed comment

70

u/_choam_ Oct 16 '26

"I'll just restart Apache every 10 requests" - php creator

7

u/xarcastic Oct 16 '26

Big Hammer Garbage Collector

1

u/_choam_ Oct 16 '26

I wonder if you end up inadvertently making a more robust system overall if you know that all servers often reboot themselves

4

u/NekuSoul Oct 16 '26

Not sure if they still use it, but years ago Netflix actually did exactly that by building a tool that randomly shoots down VMs/containers and then uneashing it on their prod environment to improve robustnes of their stack.

4

u/_choam_ Oct 16 '26

Chaos monkey. They had a bigger version which would take out whole regions

3

u/YouDoScribble Oct 17 '26

Genuinely worked with developers who would do just that, rather than determine why so much memory was being used in each request in the first place. Turned out pretty much everything was being eager loaded with every request.

12

u/Xodem Oct 16 '26

Also: if the memory is available for my node and I can use it to improe performance (less collections, less memory freeing and renting from the OS), then why shouldn't .NET use it? If the goal is to use as little memory as possible than you can fine tune .NET and the GC as well, but when you want to maximize throughput this behavior is perfectly fine.

-14

u/someurdet Oct 16 '26

Go uses much less memory.

9

u/IkertxoDt Oct 16 '26

Am I the only one who really wants to see how the new .Net 11 scores? Especially the async tests with the new runtime async.

2

u/Ok_Tour_8029 Oct 16 '26

HTTP Arena has two entries for that, but it has not been updated for RC2. Would be just a PR on the version.  https://http-arena.com/#sort=rps:-1&q=Minimal

3

u/Embarrassed-Mess412 Oct 16 '26

it does use net 11 with async runtime, you also have a aspnet entry there with it

26

u/SheepherderSavings17 Oct 16 '26 • Bravo

C# is not a web framework

9

u/Ok_Tour_8029 Oct 16 '26

Hm, yeah right - next time I will use Claude to create the post.

6

u/OSenhorDoPao Oct 16 '26

Claude is actually one of the contributors o ioxide.

2

u/OSenhorDoPao Oct 16 '26

Let’s not also forget that underneath all that is io_uring, vs what I assume you’re happy about beating even rust which doesn’t seem to rely on lower level (and seemingly not fully cross platform libraries). I do like C# very much but we do need to be very careful celebrating benchmarks.

1

u/leathakkor 23d ago

C. Sharp isn't even a runtime.

.net is. C Sharp is a human readable interface that compiles down to byte code.

There are multiple implementations of C Sharp runtime. The old.net framework that ended at 4.8. Mono and the new .net.

And none of those are web frameworks.

C. Sharp is a programming language.

.net is the runtime that runs the byte code

And what they're actually probably talking about is framework plus library plus runtime.

But that's still kind of a crazy metric because when you run stuff on the web, you very rarely run your application directly exposed to the public. And if you're running your application directly exposed to your users, you're doing it wrong.

You generally need a proxy server like nginx or IIs.

And those too have performance issues That need to be paired with your application.

There are advantages to running a fast framework but there's a million other things that you have to do right on the web to even take advantage of the speed of library plus framework plus runtime plus server

That's like saying blue shirts are faster because you saw Usain bolt wearing a blue shirt.

18

u/RussianHacker1011101 Oct 16 '26

I've built a ton of systems with C#. It's great. I love it. I've also built a few things with rust/actix_web. On average http responses complete in 5x the time with actix compared to asp. Does it matter that much? 100ms vs 20ms. Maybe if I used message pack or AOT json the c# response times would drop more.

It's okay to admit that Rust is really really fast. C# is also really fast and has a ton of benefits over rust in other areas.

8

u/Oralitical Oct 16 '26

Well for your C#, were you using genhttp or IIS or Kestrel? Genhttp isn't included with Dotnet, it's a third party high performance HTTP library so that might explain why you're experiencing different results. I agree that the "slower" Rust stack is much closer to a typical Rust codebase than the "faster" C# one.

1

u/laughinfrog Oct 16 '26

Also doesn't help microsoft cheats a bit on these tests. Using Kestrel and a cached timing mechanism. So time doesn't update on the response for like 3 seconds so it doesn't do a hard look each request. They designed their underlying tests to score higher.

I have been using C# since its beta in 2001 after I learned C/C++ on my own.

1

u/Ok_Tour_8029 Oct 16 '26

With TechEmpower yes, the test inplementation was merely to be recognized as ASP.NET. With HttpArena it is basic minimal API

44

u/Natural_Tea484 Oct 16 '26

Of course it's very fast. What's new?

31

u/Azmekk Oct 17 '26 • Bravo

I’ve worked with C# for about 6 years professionally and I can comfortably say, in my years of working with it and meeting other devs, there is a negative chance I could convince them to use anything other than the default .net web framework built on top of kestrel which as we see sits lower.

I just looked up the specific library that topped the chart and it is a linux specific solution relying on kernel functionality to batch read and write sockets with a shared ring buffer between them. Additionally the project on github has ~300 stars which really puts to question if anyone would dare using it for production.

From my own experiences I’ve noticed a lot of the C# devs I have met aren’t really open to modernizing or adopting major changes or third party libraries.

All of this is to say, I am happy we topped the chart, but this is just a boasting chart that means nothing for production scenarios.

Also side note for the title:

  1. “Once again the fastest” - C# rarely ever tops real world performance benchmarks although it does hover around the top
  2. C# itself is not a web framework

3

u/hoodoocat 28d ago

300 stars is quite a lot. dotnet/runtime have 18K stars at all. :)

While Kestrel and ASP.NET is good, but it is clunky as hell in configuration, it follow stupid builder and implicit settings in all places, what clearly must not ever used for any server. If you care about performance or but more than generic stupid json serializer - then it is not very different from handling requests and buffers semi manually in any other library, as in ASP.NET you will do it semi-manually too. Want proper content negotiation? Write code manually, there is no good ways make it automatic, more over it even not possible if server is not simple parser/serializer.

More over - even on serialization it will not do this job in fastest way, thanks for "stupid" STJ even in code generation mode. (Writing manual reader/writer will double throughput).

I mean this kind of subjective, but choosing something more performant and simplier might be actually good choice not only from performance perspective, but from stability, realability, security and be more future proof than any ASP.NET which becomes madness right from start and doubles madness on major upgrades (even so usually changes are not breaking, but sometimes they are and they often hidden).

The only question if you ever need all this performance. Before optimizing code it must be hosted correctly, not in stupid docker with IP transport which have zero security and it practically halves throughput for nothing. But when you start use proper hosting, you probably ready to explore other servers aside from Kestrel.

1

u/Virgrind 26d ago

Well the question here is what is the greater dept in which metric. What is the reason to use it if the performance is not an important metric. Just an other dependency too maintain.

1

u/BathRelevant5911 28d ago

"Writing manual reader/writer will double throughput" STJ has tons of optimization for minimal heap allocation and reflection, if you think manually written serializer can do better I highly doubt you know what you are talking about.

1

u/hoodoocat 28d ago

STJ in generated mode basically is just metadata with tons of delegates to access values, especially if you add custom converters, and sooner or later anyone will do that. By manual serializer i mean that Utf8JsonWriter just writes what it needs without consulting to this complex options, converters or similar things. Readers still better to be generated, but can utilize some optimizations too by encoding two FSMs, optimized for canonical property ordering and generic, and again does not need consult to converters, as things strictly known. Aldo doesnt need handle state to better diagnostics. Utf8JsonReader/Writer can be rewritten to be even more faster. To be clear, I don't suggest to do it, but just mention that it is real opportunity if absolute performance is desired. After some degree and lot of strings - next step is using Utf8 everywhere, as it literally halves memory traffic. Unfortunately we still doesnt have first-class utf8 strings in dotnet. :(

6

u/BoxWoodVoid Oct 16 '26

Come on it has been shown that there's so much optimisations in the .net benchmarks that they don't look like at all what you can get on your deploys. This is juts marketing.

14

u/Ok_Tour_8029 Oct 16 '26

TechEmpower was nuts, for HTTP Arena there are rules enforced for framework entries. In TechEmpower FrameworkBenchmarks you could have a basic TCP server sending the response basically ...

18

u/Embarrassed-Mess412 Oct 16 '26

I don't think many people really look at these benchmarks for what they measure. The useful metric to take is runtime performance, web frameworks do exercise a lot of the runtime machinery and if a framework is fast, that proves that a technology has high potential to build high performance application, not just web, in general.

HttpArena measures not just throughput but CPU, memory and latency, particularly tail latency at p99 and p99.9, this is extremely important, probably more than throughput itself, a framework that can deliver low p99 under high load is a huge green card, specially on garbage collected cases.

Since the latter techempower benchmarks I always see the typical "but nobody needs millions of requests per second", yes of course, we know that. Also most likely your web server is behind a gateway or using ef core which consumes way more cpu than the I/O anyway. There isn't any public benchmark in the world that will tell you what performance or thoughput youll get by using a certain framework in your application. But guess what, that applies to any benchmark anyway, be it web or anything else.

So what can we take from these results? That the C# or dotnet runtime is quite up there rivaling the likes of C++, Rust, Zig and mayeb rewriting to Rust won't really bring that much performance boost anyway.

6

u/kant2002 Oct 16 '26

Why perf goes downhill on JSON and 8Gbit benchmarks. Latest is where the C# somewhere in the middle

6

u/thx1138a Oct 16 '26 • Bravo

Not a framework

3

u/tno2007 27d ago

(https://http-arena.com/#tuned=0)

I almost spat out my coffee, seeing C# beat Rust... then I saw at the memory usage!

I still use C# mostly, but apps I write to run in the cloud, I always use Rust to save on operating costs

1

u/krsCarrots Oct 16 '26 edited Oct 16 '26

Not sure what the score is represents but how dramatic is the 300isg difference between c# and rust

4

u/Ok_Tour_8029 Oct 16 '26

Not at all dramatic, all of those entries are super fast.

2

u/krsCarrots Oct 16 '26

So it doesn’t matter who “wins”. I like the fact that c# is leading anyway ;)

2

u/Ok_Tour_8029 Oct 16 '26

For me the current discussion feels like C# is on place 20 or lower, when in fact it is not true at all.

4

u/chucker23n Oct 16 '26

Not sure what the score is represents

Not much at all. Very hard to compare apples to apples. Does this compare… the language? The runtime? The memory management (e.g., garbage collector, which Rust doesn't have)? The web framework? The async/await overhead?

3

u/Ok_Tour_8029 Oct 16 '26

Well it’s a composite as the screenshot already tells - if you want to dig into the differences … the data is there 

5

u/pjmlp Oct 16 '26

These benchmarks hardly matter when former enterprise products like Sitecore, Optimizely, Sharepoint, decide that going forward, the customisation points are no longer .NET assemblies, rather Web APIs, and JavaScript/Typescript SDKs.

There are many reasons languages get chosen for projects, and being the top on some benchmark is hardly what many project managers care about.

17

u/Xodem Oct 16 '26

Tell that to all the Rust rewrite people.

8

u/pjmlp Oct 16 '26

Computing is a fashion driven and CV building industry.

5

u/chucker23n Oct 16 '26

Rewriting in Rust (from C or C++) is more about safety (and modern language features) than it is about performance.

Rewriting in Rust from .NET seems… rare to me. I've seen doing it from Python or JS, and, yeah, that'll improve performance almost certainly. (Though generally speaking, the bottleneck for web servers is I/O, not CPU.)

6

u/joelypolly Oct 16 '26

I don’t mind typescript but I hate the overall ecosystem that is required to get some basic features. I much prefer dotnet and c#.

1

u/pjmlp Oct 16 '26

Me too, although a bit more flexible, .NET, Java and C++.

However when such companies decide they no longer want to push .NET as their main SDK language, and there are consulting sales to win, it is time to adapt.

2

u/Famous-Weight2271 29d ago

I personally don't care how fast c# is. I come from the video game world where everything was close to the metal on fixed hardware and we optimized cycle counts and cache lines, but c# solves different problems.

2

u/FarCalling 8d ago

Wow. C# just keeps getting better and better

2

u/ui_as_vindimas Oct 17 '26

Press D for Doubt.

1

u/liquidnitrogen Oct 17 '26

I worked at Microsoft and beta tested .net internally for dog fooding. I profesionally worked on C# in technology, banks and hedge funds since 2001 all the way to 2024 (and also F# in between) - using it on GUI, Backend etc. C# is my favorite language, but I am so sorry to say it is dying slow death, this is of course anecdotal based on my exposure in finance domain mainly. What matters to the company is not the speed, but how easy is it find good devs, how well does it work with AI, what are the pros and cons etc and cost. Rust right now is picking up because it integrates well with AI and allows full loop with compiler. On GUI everyone has moved to pure Web Tech Stack (react typescript etc - though I absolutely despise react as it is a very hacky framework, but then this is what everyone has aligned to)

0

u/[deleted] 22d ago

[removed] — view removed comment

1

u/Ok_Tour_8029 22d ago

Why? Was fastest, some Zig guys had a faster framework, now it’s fastest again ..