Reputation: 75
We're having 2 nodes for reading and 1 for writing. How can I set in my code the connection to these 2 reading nodes and on every page load to choose randomly between both (I don't know if it must be random or somehow to determinate which node is more free). Also any suggestions on how to set up the connection with the master node and how to actually use it? I've never done that and every help is appreciated! My project is on Laravel 8.
Upvotes: 0
Views: 1161
Reputation: 317
You can use Read & Write connections feature: https://laravel.com/docs/9.x/database#read-and-write-connections
Then just set write host for your master and read hosts for your slaves. Hope this will help.
Upvotes: 1