orleans cluster and load balancing implementation
The netcore6 project, the microservice framework chooses orleans, it seems that there are no projects in use in China, and there are many pits and no information.
The orleans document can solve almost, only look at the official information.
Introduction | Microsoft Orleans Chinese Documentation
Various problems such as how to receive service exceptions, how to release links, and memory leaks are all solved.
I did a few service tests earlier, and found that the same request or the same several requests are only concentrated on one service, and no matter how long the service takes, it will wait indefinitely for one request to finish before the next one, unless one hangs up and the next One on top. This is obviously not the desired effect
(the service here is to change the file by cpoy). This is the problem of not being able to load balance.
I scoured the Internet and tested the source code. Except for the insignificant load mentioned by Azure, there is no way to find it.
Fighting the king at night suddenly got inspiration. Since it is not available outside, it is better to create conditions by yourself.
I thought about using consul a long time ago, but it's not as simple as an http request, so it won't work with its own capabilities. If you want to do the load, why not make several identical services, request several services randomly or cyclically on the client side, and the interface of the services should be exactly the same, just look like different services.
The result is simpler than expected. You only need to configure the port, and subsequent requests do not require manual polling or randomization.
This is also the final solution, although there will be a few more services. (This is a real new service, the code is the same, but the service namespace name is different.)
The demo code is as follows:
The various configurations in the project are much more complicated than this, so I won't go into details.
exercise/Orleans/Orleans.MultiClient-Test at master liuzhixin405/exercise (github.com)
This is my issue:
how can orleans server response load balancing · Issue #7497 · dotnet/orleans (github.com)