Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use multiple connections #10

Open
wnkz opened this issue May 11, 2015 · 2 comments
Open

Use multiple connections #10

wnkz opened this issue May 11, 2015 · 2 comments

Comments

@wnkz
Copy link

wnkz commented May 11, 2015

Hey,
At the moment, this gem only uses the first server from the array we pass, I think it would be very useful to use all of them because sometime under heavy load or when running a lot of request in a short duration, queries ended up failing.
I think it's not because the cluster cannot process the request but simply because of HTTP requests saturation.

I'm willing to work on a patch for this but I'd like your approval first ; mostly to know if it's recommended to run queries directly on secondary nodes while queries are running on the primary. I'm pretty sure it works, but I'm not sure it's recommended.

What I have in mind right now (didn't start coding anything):

  • Retry on a different server if request fails
  • Simple load balancing (round roaming)
  • (Maybe) Advanced load balancing depending on the individual load of each node of the cluster (if possible)

Let me know what you think,
Cheers,

Want to back this issue? Post a bounty on it! We accept bounties via Bountysource.

@chaudum
Copy link
Contributor

chaudum commented May 12, 2015

hi @wnkz

indeed, the client should use multiple hosts for failover scenarios. the best way to implement that is round robin "load balancing". you can perform any query on any node of the cluster. using multiple hosts for queries helps to reduce load on each of the handler nodes.

if you start implementing it, you can take a look at the python client first, where this is implemented in a clean way: https://github.com/crate/crate-python/blob/master/src/crate/client/http.py#L279
I think the code is more or less self explanatory, but if you have any questions, please ask again :)

@wnkz
Copy link
Author

wnkz commented Jun 24, 2015

What do you think about using https://github.com/mperham/connection_pool ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants