3
@page page-core Network Core
5
The Network core is built around the socket handling and brings a client and server connection
9
@see network_mysqld_con
11
@section section-lifecycle Connection Life Cycle
13
Connections can be in one of several states which are basicly resembling the 4 basic phases
14
of the @ref protocol :
21
The plugins can change the default behaviour of the network core and impliment one of three
24
@li @ref page-plugin-admin implements only the listening side
25
@li client plugins implement only the connection side
26
@li @ref page-plugin-proxy implements both sides
28
@subsection section-scripting Scripting
30
Most plugins implement a set of those callbacks and expose them to a scripting layer.
32
For now the scriping is provided by Lua, a simple, fast and easy to embed scripting language.
33
We expose most of the internals into the scripting layer and provide modules to operate
34
on the data that we pass into the scripting layer
36
@section section-network-core-layer Network Core Layer
38
The MySQL Proxy network engine is meant to handle several thousands connections at the same time. We
39
want to use it for load-balancing and fail-over which means we have to handle the connections for
40
a larger group of MySQL backend servers nicely. We aim for 5k to 10k connections.
41
Up to MySQL Proxy 0.7 we use a pure event-driven, non-blocking networking approach is described in
42
http://kegel.com/c10k.html#nb using libevent 1.4.x.
43
A event-driven design has a very small foot-print for idling connections: we just store the
44
connection state and let it wait for a event.
46
@section section-threaded-scripting Threaded Scripting
48
Usually the scripts are small and only make simple decisions leaving most of the work to the network layer.
49
In 0.9 we will make the scripting layer multi-threaded allow several scripting threads at the same time,
50
working from a small pool threads.
52
That will allow the scripting layer to call blocking or slow functions without infecting the execution of
55
Lifting the global plugin mutex will mean we have to handle access to global structure differently. Most
56
of the access is happening on connection-level (the way we do the event-threading) and only access to
57
global structures like "proxy.global.*" has to synchronized. For that we will look into using Lua lanes
58
to send data around between independent Lua-states.