Re: Is jdbc replication driver slower than normal jdbc driver ?
Hi Jongse,
Connector/J multi-host connection features (replication, load-balanced and fail-over) are implemented as layers on top of each other and, finally, on top "physical"/plain connections. Having said that, there is obviously some inherent costs for internal management, but it shouldn't affect performance significantly when compared to single-host connections.
What you are observing is, I think, a different issue, and it can have many different natures.
As you correctly described, by setting a connection to read-only, you are internally instructing the driver to send queries to a slave host instead of the master and, since you are observing slowdowns only in this case, I would recommend you to start narrowing your tests;
1st, replace your connection string by a load-balanced one -- jdbc:mysql:loadbalance://(...) -- with slaves ONLY, and run the tests a few times. If still running slow, this confirms that there could be a problem in the slaves load-balanced sub connection that is used internally by the top level replication connection.
2nd, also test each slave individually using a plain connection. This will let you to know if there is one or more unreachable slaves that is causing frequent fail-overs to the other servers.
Assuming that there is some problem when connecting to one or more of your slaves, you may be able to speedup things by limiting the number of retries the driver will attempt each time it tries to use that slave(s), by setting a very small value (say, 1 or 2) to the connection property 'retriesAllDown'. But mind that this doesn't fix your original connectivity problem, you are going around it instead and you shouldn't do it.
I hope that helps.