Using MariaDB connector for master/slave connection selection

Hi,
We have a MySQL (AWS Aurora) cluster with one master and multiple read only instances. We would like to distribute the load of read-only queries to the slaves.

See here:

This would mean we somehow need to define read-only database and a master database, and then switch between them based on whether we’re doing a read access or not.

Has anyone done this in Play? Do you have any pointers about how we could do this?

We are using Play 2.6, Java and ebean.

Many thanks,
Olafur

1 Like

Hey @ogg,

This can be configured in Play for databases:

https://www.playframework.com/documentation/2.7.x/JavaDatabase#Configuring-JDBC-connection-pools

See at the examples that you have default, orders, and customers. You can then inject the database based on the name you gave it:

https://www.playframework.com/documentation/2.7.x/JavaDatabase#Accessing-the-JDBC-datasource

But I don’t think this is supported by our play-ebean plugin.

Best.