YARP vs Basic HTTP Redirect
I have simple asp.net core web api acting as reverse proxy, it simply redirects incoming payload to inernal network servers with HttpClient. I am curious if I can increase my performance and reduce network related latency. Can YARP be an option, not experienced with it ?
3 Replies
these all hosted in windows machines on IIS for now
Not sure if any library or implementation will be faster than pure HttpClint requests (optimized with HttpClientFactory and some network cache)
I think you might get several advantages by using a real reverse proxy, e.g. configuration-based routing (not having to touch code every time you want to update forwarding), load balancing, caching, rate limiting and so on..
I don't really use yarp myself, but I think a) yarp also has a way to do direct http forwarding like you do, built in. And b), Yarp should be able to be faster since I assume your solution would probably forward with httpclient at the controller / minimal api level, at a point when your request went aaaaall the way through the middleware pipeline
With yarp you could e.g. move the forwarding ahead of e.g. model binding
Making the forwarding faster on paper
So yarp is a reasonable middle ground if you have an existing API and need to add reverse proxy capabilities
If you were to use a dedicated reverse proxy like e.g. nginx or caddy, you can speed this up even more, since yarp is a layer 7 proxy and these might, depending on your config, even work on layer 4
https://microsoft.github.io/reverse-proxy/articles/direct-forwarding.html
This might be an entry point to do what you are currently doing and then slowly trying out other yarp features
lets see what they have, thanks
pipeline overhead could be a thing