ThreeMammals / Ocelot

.NET API Gateway
https://www.nuget.org/packages/Ocelot
MIT License
8.28k stars 1.63k forks source link

How to avoid calling down service in load balancer option #1041

Open uvcreation opened 4 years ago

uvcreation commented 4 years ago

Expected Behavior / New Feature

Load balancer should able to recognize the down service and stop calling service or up the service.

Actual Behavior / Motivation for New Feature

Load balancer is calling the service although the service is down and returning 500 internal server on every call.

Steps to Reproduce the Problem

  1. Created two instance of the same module and run on different port.
  2. Added load balance option for those two service instance of type RoundRobin.
  3. Kill the second service and now Ocelot still redirect to down service.

Specifications

catcherwong commented 4 years ago

Maybe you should use Service Discovery to solve this problem.

uvcreation commented 4 years ago

@catcherwong Is it possible without Service Discovery?

catcherwong commented 4 years ago

Without Service Discovery, you should remove the down service from the configuration by yourself.

Or you can set QoSOptions to ensure the quality of service.

https://ocelot.readthedocs.io/en/latest/features/qualityofservice.html

uvcreation commented 4 years ago

@catcherwong Thanks for your prompt reply but I don't think it will solved my problem. A QoS will just manipulate the status code to 503 from 500 but I want the Ocelot should able to UP the down service.

Do you know any other open source "API Gateway" which could help me with this situation?

catcherwong commented 4 years ago

A QoS will just manipulate the status code to 503 from 500 but I want the Ocelot should able to UP the down service.

Do you want to start up a down service via Ocelot?

Ocelot just forwards the requests to the downstream service.

If a service is not working properly, Ocelot can stop calling or enable CircuitBreaker to reduce the pressure on this service.

But Ocelot can not restore a down service to normal service.

uopeydel commented 4 years ago

Have any way to skip DownstreamHostAndPorts is not work? I have 5 port in DownstreamHostAndPorts and port at index 4 or else is not work(service stop by any problem). I need to let it skip that index automatically.

raman-m commented 7 months ago

@uvcreation commented on Oct 17, 2019 Hi Uttam!


@catcherwong Thanks for your prompt reply but I don't think it will solved my problem. A QoS will just manipulate the status code to 503 from 500 but I want the Ocelot should able to UP the down service.

Sorry! And this issue will be fixed as a part of #1513 Do you like status 503 in QoS or not?


Do you know any other open source "API Gateway" which could help me with this situation?

You could try awesome lite .NET gateway with the name ProxyKit :wink: ...which is in Archive :rofl: But, come on! Why not to stay with Ocelot? :tiger:

raman-m commented 5 months ago

Hello, community! Here is more news:

raman-m commented 5 months ago

@catcherwong commented on Oct 17, 2019:

Maybe you should use Service Discovery to solve this problem.

Yes, Consul has health checks feature: Define health checks Use service discovery by our Consul provider package.

raman-m commented 5 months ago

@uvcreation commented on Oct 17, 2019:

@catcherwong Is it possible without Service Discovery?

Impossible! What you need is Health Check feature. This feature is not implemented in Ocelot. We will prioritize the feature development, but any help and opened PRs are welcome!

raman-m commented 5 months ago

@ggnaegi @RaynaldM I've assigned high priority to this issue. Because there is no open PR at all, I have no idea when we can start development of Health Checks... I will add to March'24 milestone but I'm not sure about our team capacity.

RaynaldM commented 5 months ago

Ocelot is a package that brings Gateway functionality to an asp.net core application. I believe that all the natural decorum of an asp.net core application (healthCheck, Cors, StaticFiles, etc...) is the responsibility of the developer and should not be included in the Ocelot package.

raman-m commented 5 months ago

@ggnaegi Your opinion, Gui?