News for hackers. Stuff that matters.
Re:Microsoft YARP by oneplane on Sunday February 20, 2022 @03:53PM (#30409166)
Sometimes it feels like Microsoft and/or C#-enjoyers just want to re-implement everything that already exists. While having many implementations to choose from if you need to select a solution to an outstanding problem is great, it makes me wonder why re-implementing something with no discernible benefit keeps eating time/resources all over the place.

In similar cases of implementing reverse proxies in C, C++, Rust, Go and Java, there were generally benefits in various shapes and sizes like different security models, performance vs. capability trade-offs and integrated vs. specialised solutions. In this case, it just seems to be a "we don't want the stuff we didn't build ourselves" which is a shame considering the benefits of pooling resources on existing implementations would have.

Re:Microsoft YARP by cakoose on Sunday February 20, 2022 @04:20PM (#30409358)
To clarify, are you saying that:

1. There are already good reverse proxy libraries in C#?

2. There are already good reverse proxy libraries in other languages?

3. There are already good reverse proxy applications?

If it's #1, then yeah, it would be nice if the ReadMe explained why YARP is different. To be fair, they're at least consolidating a bunch of efforts within Microsoft:

> We found a bunch of internal teams at Microsoft who were either building a reverse proxy for their service or had been asking about APIs and tech for building one, so we decided to get them all together to work on a common solution, this project.

If it's #2, then what do C# developers do? Having to build your proxy in another language isn't a deal-breaker, but there are advantages to keeping your project/team/company on a single language.

(And Microsoft does contribute to Envoy [1][2].)

If it's #3, that only works up to a point. My old team used Nginx, which was perfect in the beginning. But over time we needed to customize things in ways that were difficult to do within Nginx's architecture (either in Lua or in C), leading to hackier and hackier solutions. Using a proxy library to build exactly what you need can make things much simpler.

[1] https://blog.envoyproxy.io/general-availability-of-envoy-on-...

[2] https://techcrunch.com/2020/08/05/microsoft-launches-open-se...

Re:Microsoft YARP by bob1029 on Sunday February 20, 2022 @04:32PM (#30409429)
> But over time we needed to customize things in ways that were difficult to do within Nginx's architecture (either in Lua or in C), leading to hackier and hackier solutions. Using a proxy library to build exactly what you need can make things much simpler.

This is the central argument for me regarding why we don't "just use nginx". We actually do use it for some corporate websites, but not for our main product.

There is a ton of power hiding here... With a well-supported first-party RP framework, how long would it take for a determined developer to replicate the most important bits of the nginx feature set? Imagine being able to throw a blazor dashboard on top of this stuff. Wiring up real-time events/metrics would be super trivial if you are even remotely interested in learning how the DI system operates. Mix in a little bit of SQLite and you could have something I may argue provides a better UX than what nginx offers today.

Re:Microsoft YARP by zamalek on Sunday February 20, 2022 @05:24PM (#30409829)
> But over time we needed to customize things in ways that were difficult to do within Nginx's architecture (either in Lua or in C),

Yup. Eventually a configuration language becomes a shitty programming language, so why don't we just use a programming language?

Re:Microsoft YARP by idubrov on Tuesday February 22, 2022 @01:09PM (#30431246)
Re:Microsoft YARP by kristaps on Sunday February 20, 2022 @05:01PM (#30409667)
Can you share more specifics on what you needed to customize that went beyond nginx's capabilities?
Re:Microsoft YARP by cakoose on Sunday February 20, 2022 @05:55PM (#30410062)
This was 5+ years ago so I'm a little hazy on the details. A lot of it was just plugging into our infrastructure for config, service discovery, rate limiting, logging, etc.

- Logging the exact metrics we wanted to our metrics service. (We wrote a bunch of Lua code to do this.)

- Loading the set of backend services from Zookeeper. (We had a sidecar process that would periodically sync from Zookeeper to a config file, then call `nginx reload`.)

- Routing requests to different datacenters based on where the user's data was homed. (We had Go libraries to do this, and it would have been nice to be able to just call into that. I think we ended up putting this functionality in the sidecar.)

- Changing the way we streamed a response based on an HTTP header from the application. (We ended up writing a C module for this.)

- Changing the backend selection algorithm from "least connections" to "best of 3 random choices". Nginx added support for this in 2018, apparently.

There were ton of things we solved with Lua, which wasn't ideal. Since that's the only Lua in our codebase, everyone who touches it has to make a mental switch to remember all the weird edge cases (as you do with any language), plus 1-based array indexes, plus no static types.

Plus, any Lua or C you write has be contorted to fit Nginx's multi-stage request/response architecture. If you're writing a plugin that is meant to play nice with other plugins, then the contortions may be worth it. But for us, a proxy library would have given us the freedom to write code that was simpler and easier to understand.

The team moved to Envoy after I left: https://dropbox.tech/infrastructure/how-we-migrated-dropbox-...

Re:Microsoft YARP by kristaps on Monday February 28, 2022 @04:22AM (#30497970)
Your application does indeed sound like it's beyond OTS solutions, thanks for sharing!
Re:Microsoft YARP by mrkurt on Sunday February 20, 2022 @05:33PM (#30409910)
There aren't a lot of good proxy development frameworks. There are decent lower level libraries, and proxy servers with limited scriptability.

I've spent the last 4 years at Fly.io wishing for a nice, full featured, proxy framework. This looks pretty darn good to me.

Re:Microsoft YARP by sopium on Sunday February 20, 2022 @09:42PM (#30411389)
I find hyper quite nice to work with to build reverse proxies, mostly thanks to the HTTP client and server having common types for request, response, headers and body streams etc. I agree that it is only a decent lower level library rather than a full featured proxy framework though.
Re:Microsoft YARP by js4ever on Monday February 21, 2022 @01:57AM (#30412667)
A Ruby on rails shop like fly.io would use .net?
Re:Microsoft YARP by square_usual on Monday February 21, 2022 @02:10AM (#30412734)
Wait, fly.io is a Rails shop?

(At any rate, they employ Chris McCord, the creator of Phoenix, and have spent considerable resources pushing Phoenix. So it's clear that they aren't beholden to any one language or ecosystem.)

Re:Microsoft YARP by mrkurt on Monday February 21, 2022 @03:00AM (#30413069)
I think we have more Rust and Go than Ruby at this point. Probably slightly less Elixir.

For better or worse we're not really fixated on one language.

Re:Microsoft YARP by oaiey on Monday February 21, 2022 @02:21AM (#30412812)
He explains the use case why you need a RP framework in your language of choice not his desire at fly.io (I guess :))
Re:Microsoft YARP by melony on Sunday February 20, 2022 @06:44PM (#30410369)
The Go standard library?
Re:Microsoft YARP by bob1029 on Sunday February 20, 2022 @03:59PM (#30409216)
> re-implementing something with no discernible benefit keeps eating time/resources all over the place.

> is a shame considering the benefits of pooling resources on existing implementations would have.

What exactly would you prefer these developers spend their time on instead of this work?

There are a lot of benefits to being able to integrate your own reverse proxy directly into your software stack. C# developers enjoy these as much as anyone else would.

Re:Microsoft YARP by jeeeb on Sunday February 20, 2022 @04:47PM (#30409548)
> There are a lot of benefits to being able to integrate your own reverse proxy directly into your software stack. C# developers enjoy these as much as anyone else would.

I take this at face value but it would be nice to know what the benefits are vs nginx and other off the shelf solutions.

The readme explains the benefit for Microsoft but not how it stacks against off the self solutions.

Re:Microsoft YARP by bob1029 on Sunday February 20, 2022 @05:14PM (#30409763)
> it would be nice to know what the benefits are vs nginx and other off the shelf solutions.

Biggest difference in my view is being able to make synchronous blocking calls directly into any arbitrary business code in order to determine the fate of a request. This can include rule/policy engines as well as auditing & tracing frameworks.

Re:Microsoft YARP by andreypopp on Sunday February 20, 2022 @05:59PM (#30410088)
Lua in nginx can you get very far in my experience.
Re:Microsoft YARP by damianh on Tuesday February 22, 2022 @04:31AM (#30425803)
Lua vs C# - chose your poison. There's a ton of AspNet Core libraries for handling http things e.g. JWT handling. Things that might need the licensed version of nginx.

Also it's embeddable and self-hostable into any .NET / AspNet Core application.

Re:Microsoft YARP by older on Monday February 21, 2022 @02:51AM (#30413013)
One benefit is that you can run it on your existing IIS cluster where you already run yor stuff.
Re:Microsoft YARP by akshayshah on Sunday February 20, 2022 @05:12PM (#30409747)
> The readme explains the benefit for Microsoft but not how it stacks against off the self solutions.

Totally agree. Seems to me that the main benefit is that it's easy to extend in .NET, vs. C/C++/Lua/WASM.

Re:Microsoft YARP by 123pie123 on Sunday February 20, 2022 @03:57PM (#30409199)
>Sometimes it feels like Microsoft and/or C#-enjoyers just want to re-implement everything that already exists

It sometimes feels to me, like a huge percentage of developers reinvent the wheel

Re:Microsoft YARP by civilized on Sunday February 20, 2022 @04:12PM (#30409305)
There are thousands of Java accounting apps and thousands of shitty medical billing websites.

I think most devs are definitely reinventing the wheel for the ten thousandth time

Re:Microsoft YARP by dqv on Monday February 21, 2022 @01:02AM (#30412418)
And for good reasons. I think there is an almost ignorant annoyance with devs who reinvent, but a lot of times they’re reinventing a punctured wheel or the wheel is for a bulldozer and they need one for a minivan.

I had this exact experience: “why should I reinvent the wheel?” Oh this solution doesn’t let you apply partial payments or apply one payment to multiple invoices. This one doesn’t create account statements. This one can’t fax invoices. This one only supports Stripe (and has its own undocumented billing API because who would use anything other than Stripe?). This one has a weird XML definition system for subscription pricing which makes it difficult if not impossible to handle negotiated rates on a per-account basis. Not to mention having to teach billing people how to write the weird XML. This one won’t prorate invoices. This one is a cloud service that costs $100+ a month and is liable to be unavailable when I really need it! They all have weird features that I will never use.

Ok, we’ll go with this imperfect one and make some changes. But where’s the entry point? How does weird framework in weird language even work? What are the conventions? How is the original developer differing from those conventions?

And then you come to the realization that the wheel gets reinvented because the existing wheels were made with specific business logic in mind. While this can often be generalized for a particular industry or set of use cases, it often does not and can not cover all use cases. The wheel is reinvented.

(Not so fast with the XKCD comic about new standards. We’re not imposing standards on others, we just need our software to work for us.)

Sometimes the wheel doesn’t need to be reinvented. Some help desk software I wanted to use needed some slight tweaks. The entry points were obvious and the development environment was easy to setup. I made the tweaks and was good to go.

Re:Microsoft YARP by dudeman13 on Sunday February 20, 2022 @06:52PM (#30410426)
>There are thousands of Java accounting apps

There is already a solution that lets us not reinvent this particular wheel. It's called Excel.

I hate using it.

Re:Microsoft YARP by pjmlp on Monday February 21, 2022 @03:21AM (#30413190)
Ah, that is why cars still use chariot wheels.
Re:Microsoft YARP by amelius on Sunday February 20, 2022 @06:49PM (#30410403)
And how would we cope with this in, say, 100 years, when the list of required functionalities is much larger, and a new language comes along?
Re:Microsoft YARP by codeulike on Sunday February 20, 2022 @05:49PM (#30410022)
Seems like the fact that its built in C# isn't really the main point. The main point it that it runs on asp.net infrastructure
Re:Microsoft YARP by assttoasstmgr on Sunday February 20, 2022 @04:54PM (#30409621)
Would your reaction have been different if, instead of Microsoft, this article was submitted by some random person entitled "Show HN: I built a reverse proxy in C#"?

By your logic, the world should be operating on a single OS, with a single web browser, paired with a single web server, because why re-implement something that already exists?

Re:Microsoft YARP by pydry on Sunday February 20, 2022 @04:59PM (#30409652)
Pretty much every "I built a thing" post is met with the same response. MS isnt special.

I think pretty much every open source project that wants to be taken seriously needs to compare itself with its competitors.

Re:Microsoft YARP by assttoasstmgr on Sunday February 20, 2022 @05:03PM (#30409686)
From what I can tell they built a tool for themselves to use internally, and open-sourced it. I don't think they were looking for approval or to be taken seriously.

Similarly, Igor built nginx to solve a particular problem, and I think it was a few years before it went open-source.

I can't imagine most OSS developers have delusions of grandeur.

Re:Microsoft YARP by throwuxiytayq on Sunday February 20, 2022 @05:44PM (#30409974)
Given that pretty much all of the recent Microsoft's open-source projects under the .NET umbrella, including ASP.NET Core, have been a resounding success in terms of communiry adoption, I don't think they're very shy about comparisons.

I expect some of the comments under this post to age very badly.

Re:Microsoft YARP by pjmlp on Monday February 21, 2022 @03:23AM (#30413201)
Nope, if it is an HN hyped language it gets all the love of the day, Ruby, Clojure, Rust,....
Re:Microsoft YARP by pydry on Monday February 21, 2022 @04:03AM (#30413467)
Rust rewrites get a bit more love by default because it's implicitly assumed it'll be fast and bug free compared to alternatives.
Re:Microsoft YARP by pjmlp on Monday February 21, 2022 @04:23AM (#30413616)
I doubt Rewrote it in Ada/SPARK would get the same love.
Re:Microsoft YARP by AlphaSite on Sunday February 20, 2022 @05:31PM (#30409881)
Re:Microsoft YARP by qbasic_forever on Sunday February 20, 2022 @04:02PM (#30409245)
It's only in the last 5 years that .NET was open sourced and made available officially for Linux systems. Up until then most C# use was strictly on Windows, and OSS especially for Windows server side stuff (IIS, SQL server, etc.) was (and still is) pretty rare. I've seen windows server places (Microsoft) implement everything from redis, memcached, queue systems, prometheus, lucene, DNS servers, to reverse proxies, etc. entirely from scratch out of necessity. Years and years of man hours going into building and supporting something that would be a simple debian package install on Linux.

I have no insight into it but my gut tells me windows server exclusive shops are probably dwindling and have long ago realized they needed to start moving to Linux, especially now that .NET is officially supported there. I think the days of reinventing everything in C#/.NET/windows are coming to an end fast.

Re:Microsoft YARP by rswail on Monday February 21, 2022 @02:43AM (#30412956)
C#/.NET/CLR are competing against Java/JRE/JVM.

So reinventing "everything" in a Windows Server environment is slowly coming to an end, with Windows server becoming a hypervisor for VMs/containers and a runtime for .NET/CLR.

The economics of getting all of the FOSS infrastructure tooling in a "Windows native" form is being beaten by just running them in containers/VMs on whatever hypervisor is available.

In the same way, Linux is becoming a hypervisor for containers and the various container runtimes.

Re:Microsoft YARP by pjmlp on Monday February 21, 2022 @03:24AM (#30413206)
Linux is being replaced by type 1 hypervisors, no need for Linux to run a container runtime.
Re:Microsoft YARP by oaiey on Monday February 21, 2022 @02:32AM (#30412874)
And that is not a gut prediction but history. 15 years ago the default was Windows, .NET and SQL Server. 5 years ago it is Linux in the cloud, .NET and PostgreSQL.