When your project involves a set of read replica instances, and you require a convenient method for managing
SELECT queries from read replicas, as well as performing create, delete, and update operations on the primary
instance, you can leverage the withReplicas() function within Drizzle
PostgreSQL
MySQL
SQLite
You can now use the db instance the same way you did before. Drizzle will
handle the choice between read replica and the primary instance automatically
You can use the $primary key to force using primary instances even for read operations
With Drizzle, you can also specify custom logic for choosing read replicas.
You can make a weighted decision or any other custom selection method for random read replica choice.
Here is an implementation example of custom logic for selecting read replicas,
where the first replica has a 70% chance of being chosen, and the second replica has a 30%
chance of being selected.
Keep in mind that you can implement any type of random selection method for read replicas