Hello,
It's an old idea to split reads and writes on mysql. Drupal say they already have such db driver, can't find it's docs now. As you pointed out you need to decide where you want to do R/W splitting - server or application side.
For #1 the same idea goes with mysql-proxy and their r/w splitting lua script. But there's something wrong with server side solutions for R/W splitting - Limitations! The mysqlnd-ms has following limitations:
"The built-in read-write-split mechanism is very basic. Every query which starts with SELECT is considered a read request to be sent to a MySQL slave server. All other queries (such as SHOW statements) are considered as write requests that are sent to the MySQL master server. The build-in behavior can be overruled using SQL hints, or a user-defined callback function.
The read-write splitter is not aware of multi-statements. Multi-statements are considered as one statement. The decision of where to run the statement will be based on the beginning of the statement string. For example, if using mysqli_multi_query() to execute the multi-statement SELECT id FROM test ; INSERT INTO test(id) VALUES (1), the statement will be redirected to a slave server because it begins with SELECT. The INSERT statement, which is also part of the multi-statement, will not be redirected to a master server."
Is there any way to prevent 3rd party extensions from failing because of custom and complex mysql queries?
In this case the bast way is #2. Decision what query(ies) go to master and what go to slave should be done on application level. Application side driver can track mysql 'transactions' and issue all the queries to the same node in case we are dealing with something more complicated than just simple SELECT.
Regards,
Pawel Panek