coronabytes / dotnet-arangodb

.NET Driver for ArangoDB
Apache License 2.0
67 stars 18 forks source link

Support for Arango Load Balancing #43

Closed egress-jack closed 2 years ago

egress-jack commented 2 years ago

I'm not sure if this belongs perhaps in discussions or be tagged as a feature request, but we are currently investigating the use of this library versus the official Node and Java libraries.

The main one we are looking at adding is round robin and looking inside the Node and Java drivers it supports passing in an array of endpoints and then there is some internal logic that figures out which endpoint each request should be sent to.

After thinking on it, this could potentially be handled in our code, where we create multiple contexts and target each one to a different server with our own logic used to figure out which context should handle the request and all of them using the common HttpClient that we have created and augmented with Polly.NET policies

So I suppose there are two questions I'm asking:

coronabytes commented 2 years ago

contributions are welcome ;-p

now for your suggestion to just create N ArangoContext's with different coordinators and use a random/sequenced one each idemponent request should just work out of the box. Just lock one in foreach unit of work (no mixing in streaming queries / stream transactions)

beware the arango documentation where it states that not every request can be retried even if it "failed" the driver supports injecting a custom httpclient - however its untested

killerwife commented 2 years ago

I have a question about a related topic. I plan to use the load balancer detailed here. https://www.arangodb.com/docs/stable/deployment-kubernetes-services-and-load-balancer.html

Does this mean I can connect to a singular server or does it still mean I need to add some sort of logic on top for the different coordinators.

coronabytes commented 2 years ago

With a K8S Loadbalancer, I think one endpoint is enough to achieve the desired behavior. If a subsequent request enters on the wrong coordinator it will hop to the correct one - nothing that the driver needs to do. From what I read if you have a "smart" loadbalancer (don't know what the arango k8s operator does) it will route to the correct node by itself. thats probably why arango oasis does not need to expose multipe coordinator endpoints.

https://www.arangodb.com/docs/stable/http/general.html#load-balancer-support