Multiple Db Connections To Leverage Multicore Use With Some Db Servers

Hi everyone,

I don’t know if I’m looking at this at the right angle but here’s what I was thinking.

Currently Mysql will use one cpu per connection (I believe PostgreSql as well).

Essentialy this means that my Yii application, regardless of the load/queries will always use the same connection to the database and thus the later will only use one CPU.

I would like to know if it would be possible to have Yii randomly jump between a set number of connections to better leverage CPU power.

I was thinking of creating a duplicate db in my configuration and then extending CActiveRecord to randomly fetch the db to use. But:

  1. I’m not sure I would get the expected behavior,

  2. maybe there is a cleaner way of doing this?

  3. maybe I’m just mad and shouldn’t even consider

Thanks for your insight!!

see this dbreadwritesplitting

or this topic