Confusing README
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"?
agree, no one can response on this?
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.
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.