seamless_database_pool icon indicating copy to clipboard operation
seamless_database_pool copied to clipboard

Confusing README

Open psharpNumerex opened this issue 11 years ago • 3 comments

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"?

psharpNumerex avatar May 29 '14 12:05 psharpNumerex

agree, no one can response on this?

kithokit avatar Jul 14 '14 07:07 kithokit

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.

mahemoff avatar Nov 30 '16 00:11 mahemoff

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.

dcosson avatar Dec 14 '16 00:12 dcosson