2
votes

My application is getting a lot of database calls hence I need to start using a distributed master/slave mysql database but I'm having problems configuring play framework!

so my first question is that if it is actually possible to configure hibernate and jpa with play framework to take advantage of replication driver

if, it is not possible, is there any other technique to use a distributed mysql schema with play

this is my configuration:

db.url=jdbc:mysql:replication://[master ip]:3306,[slave ip]:3306/<dbname>autoReconnectForPools=true&roundRobinLoadBalance=true&loadBalanceBlacklistTimeout=5000&loadBalanceStrategy=random

db.driver=com.mysql.jdbc.ReplicationDriver  
db.user=<dbusername>
db.pass=<dbpassword>
2

2 Answers

3
votes

user724051's answer which was previously inserted into someone else's answer:

Multiple db is not the solution, since the app is not really using different databases. I found the problem with my configuration file, apparently you have to explicitly tell hibernate what dialect it needs to use so, this is the way to configure it (although, to this point i am suspicious if it really sends reads to slave and writes to master yet - my cpu and memory utilization on the master is still suspiciously high!)

db.url=jdbc:mysql://[master ip]:3306,[slave1 ip]:3306/<dbname>   
db.driver=com.mysql.jdbc.ReplicationDriver
db.user=<db username>
db.pass=<db password>
jpa.dialect=org.hibernate.dialect.MySQL5Dialect
1
votes

You may want to check out the MultiDB module. Its description sounds like what you are after.

Multiple Database module for the Play! framework. This module allows you to scale your Play! apps to multiple databases with a common schema.