From a performance standpoint, it is very difficult to beat kestrel now. If you don't want all the fancy Microsoft bullshit (I certainly don't), use the minimal APIs and map out routes to lightweight HttpContext handlers.
thank for the pointer !
The syntax seems cool and comprehensive, i like it.
I made some test and like its name, it is very fast : performances are closed to SimpleW, just a little bellow. But its memory footprint is the half, so i'm impressed. I will check the code, sure there are interesting things into.
Edit: Of course, Aspire definitely looks interesting for more complex needs.
also what does performance matter on webservers
Agreed, but it is the least smelly pile they have on offer.
https://learn.microsoft.com/en-us/aspnet/core/fundamentals/m...
ASP.NET Core is one of the best web frameworks, extremely modular and flexible. It's low level components (http server, routing) can be used as a foundation for new web frameworks.
That said I think some diversity / competition / cross-pollination should be welcomed in the .NET space.
Not a fair comparison but I’m glad Avalonia exists despite WPF, for example.
Joking aside, I do agree that ASP.NET Core is a behemoth. On .NET 9, I just now did `dotnet new webapi` followed by `dotnet publish --self-contained -p:PublishSingleFile=true` and the binary is 103MB. That would blow up the size of a mobile app considerably, just to listen to HTTP.
There a separate use case that SimpleW won't solve: When you're on a platform that .NET Core doesn't support, like Raspberry Pi Zero (armv7l). In this case all you have is the mono framework and binding to raw ports.
> Joking aside
author here.
I agree with your remark ^^
Each time i read some news about a new framework with tag "blazingly fast", i'm thinking "lol".
So i had to resist to the temptation... And finaly when doing a small benchmark, performances were not bad at all (https://stratdev3.github.io/SimpleW/guide/performances.html) and i let the "clickbait" title.
My targets are small to medium traffic and embeded devices (dotnet/android).
app.MapGet("/api/test/hello", () => "Hello World!");
As a general web server, I think I'd always go for Kestrel over this, but as another poster said, if you're trying to add an endpoint to some desktop application, this would be perfect.
You're right.
To be fair, i have to run many other benchmarks including one with the best recommanded optimizations for each projects.
a little time consuming but definetely on my todo list.
I've just tried the same, but with native-aot (build to native code). On Windows it was around 10mb, including routing, JSON serialization and openapi support. Startup is nearly instant.
If you include the dotnet runtime it's much bigger, but that's expected.
Edit: built with dotnet publish -r win-x64 -c Release /p:PublishAot=true /p:PublishTrimmed=true /p:PublishSingleFile=true
I think you are expecting too much here.
I thought about mentioning AOT and trimming, but my comment was already long.
AOT in ASP.NET is still a moonshot in most cases, and a non-starter in existing web apps due to dependencies not supporting AOT.
Worth mentioning that as of .NET 9 AOT is not supported on Android.
agree, that's why there is a performance benchmark at https://stratdev3.github.io/SimpleW/guide/performances.html with code as you can reproduce at your own.
i'm adding other tests, more complete than the hello world one.
We moved a couple of critical services over to Go because of those two issues and it turned a few heads.
I'd blame Serverless more than ASP.NET Core for the bad performance in that case though.
I notice Apple had similar problems and moved some of their back end to Swift from JVM recently. There was a post on here.
I have some heavy ASP.Net stuff too, yep, we have to prewarm it before putting into production.
You can create a class library ASP.NET Core Server by using a FrameworkReference [1]. I can't remember the library, but there was one that had its own `IHostedService` with its own embedded ASP.NET Core Server startup within it.
If your `WebApplication` requires services, of course you're going to have to register its dependencies on its `IServiceCollection`. Though, you can use factory methods for service registration to use an external `IServiceProvider`.
For console applications, I would recommend using `Host.CreateEmptyApplicationBuilder` [2]. Makes it a lot easier to configure services for Console applications. It also handles `IHostApplicationLifetime`s.
[1] https://learn.microsoft.com/en-us/aspnet/core/fundamentals/t...
[2] https://gist.github.com/pethin/7e5edd7614ff2f51c06c086e1bc7c...
Starting with 3.0 (or 5.0?) they ditched the Startup class and just added in everything by default. Much easier for the regular web application. The modular approach is still everywhere though. You can just pick the components you need, most of them also run without DI, it's just a bit of a hassle to manage all those dependencies manually.
The full asp.net out-of-the-box experience is tailored to the most common use case, which is a plain web service.
I think you can even run the Kestrel HTTP server without all the asp.net pipelines, infrastructure and without dependency injection.
Also the common WebApplication.CreateBuilder() includes a lot of default configuration (batteries included), there is also CreateSlimBuilder() and CreateEmptyBuilder().
In your opinion. Not everyone is of the same mind when it comes to software design. Sometimes the motivations are different.
As a community we should encourage those looking to find their own path. We become myopic otherwise.
That's the reason I asked the question "why?". It's probably much slower (asp.net got performance/memory optimized to a ridiculous extent), and might contain dangerous vulnerabilities (creating a secure http server is hard!).
I wanted to start with something small where I could read or write the code in a reasonable amount of time.
My usage was, and still is, for low traffic. I don't intend to replace the Kestrel beast.
Just a framework you can quickly understand without being lost in documentation once you want to custom a part.
I don't think so.
The fact is there are very few dotnet web servers. ASP.NET Core is supported by the owner of the dotnet langage who is also the M of the GAFAM.
There is some place in the ecosystem for other alternatives
It's not my favorite, it starts slow and I'd rather go up to JS/TS for scripting flexibility or down to Rust for really lightweight performance with fast startups. It's one of the better all-around options though. I'd rather use it over Java every day of the week and there are adapters for most things you'd ever need to communicate with.
SRE here, very few because Microsoft is strongly opinionated with ASP.Net and those opinions most sense for VAST majority of their users.
I have a much more nuanced view.
I think that ASP.Net is the de facto standard for being backed by Microsoft since many years. From the gold time when ASP means IIS to now when Kestrel was cannibalized by Microsoft.
As a developer, working with the most widely used stack guarantees that these choices won’t be questioned in critical situations. I’m not saying Kestrel is bad, but it doesn’t automatically fit every scenario.
- 15 years ago, there were Apache or IIS.
- Then nginx changes the game and kicks their ass
- Then webserver starts being written into script langage for better integration (Ruby, Python), no more CGI and nginx as reverse
- Then node changes the game
- Now : caddy and other alternatives... but still not web server in PHP (troll inside)
I see a pattern to not believe aspnetcore is the only one and the best.
...based on what?
.NET has had a hard time shaking off that old stigma, and to be fair, by the time it was really good, a lot of places already moved on to other tech (in particular, Go) .NET missed its window to escape the enterprise and despite being great, will probably never be seen as sexy.
I love it though. It's by far one of the most productive frameworks, and C# is pleasant to work with, and F# even more so.
author here.
You don't have to keep it behind a reverse proxy like nginx.
But you can, especially if you have multiple APIs and you want to keep thing separated for security reason.
Example :
nginx:443 (reverse proxy, domain name routing)
|
|-> website1:8081 - docker container with SimpleW
|-> website2:8082 - docker container with SimpleW
|
...
That's what web servers are made for, no? Like Apache, Nginx etc. I mean, you could certainly put HAProxy in front but you'd need a good reason to do this.
More often than not, for any serious application backend, you probably want a web application firewall (WAF) in front of it and SSL termination upstream of the web server.
These are three different tools that do different things. The point is that these are better examples of the "modern MS ASP Infra" space than "nginx, iis".
that's the reason why i start the project. I had time and wanted something simple as my needs.
The default template is great and everything in VitePress has been thinking to create documentation. Very nice project.