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

Confusing README #18

Open
psharpNumerex opened this issue May 29, 2014 · 3 comments
Open

Confusing README #18

psharpNumerex opened this issue May 29, 2014 · 3 comments

Comments

@psharpNumerex
Copy link

Looking at the example yml file for the pool_weight configuration:

master:
host: master-db.example.com
port: 6000
username: master_user
password: 567pass
read_pool:
- host: read-db-1.example.com
pool_weight: 2
- host: read-db-2.example.com

The explanation below says:

"the connection read-db-1 will get half the traffic as the other two connections, so presumably it's on a more powerful box."

Shouldn't that be "read-db-1 will get TWICE the traffic"?

@kithokit
Copy link

agree, no one can response on this?

@mahemoff
Copy link

mahemoff commented Nov 30, 2016

It would appear you are correct that it should be TWICE the traffic. Here's the relevant code:

        pool_weights.each_pair do |conn, weight|
          weight.times{@weighted_read_connections << conn}
        end
        @available_read_connections = [AvailableConnections.new(@weighted_read_connections)]

It handles the weighting simply by adding the connection to a list multiple times, according to the weight factor. (So the weights must be integers.) This makes it clear that, as you'd expect, connections with more weight get used more.

@dcosson
Copy link

dcosson commented Dec 14, 2016

On the topic of confusing readme, it seems incomplete regarding how to use the read pool.

By default, the master connection will be used for everything. This is not terribly useful, so you should really specify a method of using the read pool for the actions that need it. Read connections will only be used for select statements against the database.

This is done with static methods on SeamlessDatabasePool.

which static methods? It would be useful to include an example.

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

No branches or pull requests

4 participants