No, this is a dumb idea. It will make your application run slower and less reliably than the alternative....
Set up both machines as webserver and database server. One as the mysql master, the other as the slave. The add round-robin DNS. If you like you can weight the website address on the machine hosting the slave to push more of the traffic there.
For a fully transparent failover approach a master-master approach may be better - you can still implement update affinity for one node and web request affinity for the other if you really want.
This allows you to:
- split the load evenly and controllably across the two systems
- improve the availability of the system by several orders of magnitude
- simple and fast recovery from a terminal outage on either node
Seperating the functionality across the 2 nodes means that you now have 2 single points of failure. If you model the probability of failure for the 2 approaches, with say a probability of failure of 0.001, then using equivalent nodes, the probability of failure resulting in the system being unavailable is 0.001 x 0.001. OTOH, for the stacked approach the probability of failure resulting in the system being unavailable is 0.001 + 0.001
Having to go across the network every time you need to read from the database (for most applications db reads are much more frequent than writes) is usually at least 10 times slower than access a local service.