Closed liuzhen closed 9 years ago
by "seems not working", i meant i tried to insert and query some 'user_accounts' and 'user_messages', all of which were from/into the db0 (config not in the db_shards).
but you do have db0 in your shards
@danikp I presume, I have many (more than "user_account" & "user_message") models, the outer db config (db0) is for models other than models specified in db_shards;
As for "user_account" & "user_message", records are to be inserted & looked up in all the shards, i.e. db0 & db1, using some kind of hash or the likes.
In my experiments, db1 in the shards is left intact after many "user_message" insertions.
Would you elaborate?
shards not used for load-balancing. That means, it will use first shard found for specific model. So, if you change your config so user_account will be on db0 and user_message on db1, you should see traffic on both hosts. If you set both models on both shards, only one will be used.
Ah, "vertical" sharding, right.
Thanks.
you are welcome!
closing
I set up two postgresql instances named "db0", "db1", and using following config for db/shards.
seems not working...
{db, [ {adapter, pgsql}, {db_host, "db0"}, {db_port, 5432}, {db_username, "db_username"}, {db_password, "db_password"}, {db_database, "db_database"}, {shards, [ [ {db_shard_models, [user_account, user_message]}, {db_shard_id, db_shard_id0}, % not used in boss_db_controller {db_host, "db0"}, {db_adapter, pgsql}, {db_port, 5432}, {db_username, "db_username"}, {db_password, "db_password"}, {db_database, "db_database"} ], [ {db_shard_models, [user_account, user_message]}, {db_shard_id, db_shard_id1}, {db_adapter, pgsql}, {db_host, "db1"}, {db_port, 5432}, {db_username, "db_username"}, {db_pasword, "db_password"}, {db_database, "db_database"} ]]} }