Peter Korsgaard wrote:
> I'm working on a SQL proxy for distributing load as a project at
> university. The idea is to have a system, which can transparently be
> inserted between an existing database and its clients, to allow the system
> performance to scale by adding more databases as the load increases. This
> way we don't need to recode the clients.
> Below is a diagram of the system.
> Client 1 Database 1
> _____ _____
> | | | |
> | |<----- Proxy (distributor) ----->| |
> |___| | SQL _____ SQL | |___|
> ------------->| |<-----------
> . | | .
> . ------------->|___|<----------- .
> | SQL SQL |
> Client n | | Database m
> _____ | | _____
> | | | | | |
> | |<----- ----->| |
> |___| |___|
> The job of the proxy is to look at the querys: If the query is a select it
> can be transmitted to only on of the databases, but if it is an
> update/insert it has to go to all of them. Furthermore it should monitor
> the set of databases, and exclude databases that stop working, and update
> them when thay again become available.
As Sinisa has said, it would be better to use the internal replication
capabilities and just send the update query to the master instead of all
servers. Then the only issue you have to worry about is what to do when the
master is down - the rest will be taken care of by the replication code.
> I have been browsing a bit around mysql.com and looking at the c client
> library, but I haven't been able to find any information about the
> protocol used between the mysql database and the client, Is such
> information available anywhere, or could anyone point me to areas of
> interest in the mysql server code?
Why do you need to speak the protocol yourself? If you link againt
libmysqlclient, you will get all the functionality you need to talk to the
servers. Do you have a reason do go below the provided client API? Even in this
case, you should still link against libmyclientclient and use the provided
functions, such as mysql_real_connect() to establish connection, my_net_read()
and my_net_write() to send/receive individual packets, etc. Look at the sources
in libmysql/libmysql.c and libmysql/net.c - they are the best documentation.
MySQL Development Team
__ ___ ___ ____ __
/ |/ /_ __/ __/ __ \/ / Sasha Pachev <sasha@stripped>
/ /|_/ / // /\ \/ /_/ / /__ MySQL AB, http://www.mysql.com/
/_/ /_/\_, /___/\___\_\___/ Provo, Utah, USA