I have installed cluster MYSQL (galley with mariadb) As an application server installed Apache. on a server with Apache installed haproxy which proxies requests from php in this case installed for zabbix server cluster. But faced with deadlocks, now I want to proxy requests WRITE, INSERT, UPDATE to the second server. SELECT queries to the second and third server. I would be happy to see your suggestions. Please do not write: use mysql - proxy. I want to see what program it may to proxy SQL requests. scheme: http://www.gliffy.com/pubdoc/4474830/L.png
The book Scalable Internet Architectures covers this in some detail. The general guideline is to handle this in your application as 3 separate connections to the database, live, replicated, and analytic. Writes and reads needing immediate data go to the live DB, reads that don't need up to the instant views go to the replicated DB, and all of the heavy duty analytic queries can be read from a backup server. Moving to this setup requires the application to define the requirements for reading at development time, something 3rd-party server generally could not do.
In this case you would be able to see the queries causing deadlocks and start moving the most troublesome to the new connections.
Any TCP loadbalancers would not be able to handle SQL, you would need something SQL-aware, which HAProxy is not. I have not looked into the space at all but I have not heard of SQL aware proxies that handle consistency requirements across replicating read slaves after a write to the master.