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
Active Record Master / Slave latency and update #4799
Comments
You can use Yii::$db->useMaster(function () {
// perform AR query here
}); You don't need to pass |
Can you show hod load balancing for masters is done ? |
@samdark too abstract i dont see where actually master is opened, this pool is used for slaves, can you maybe track some logic ? Would be great |
It's used for masters as well: https://github.com/yiisoft/yii2/blob/master/framework/db/Connection.php#L499 |
I see , thanks , maybe it is better to create |
Would be great to know how to limit effect of slave update with
Yii2
. The problem is that when we perform some update on user data we do it on master and to avoid eventual consistency and data latency update we should read from the master actual data that needed for current request (data that was updated). If it is for UI then it is fine since we actually can make simple query with DAO, but when it is about AR and application logic then it is becoming a little bit hard. How to reroute query to master for the AR ? Currently the only solution is passingdb
instance inall($db)
orone($db)
and other methods.@qiangxue can you maybe suggest some solution or brief overview of how it can be solved ? Also can you maybe add in docs how master balancing is supported ? I have not found it in code , would be great if you will point out it
The text was updated successfully, but these errors were encountered: