This is a creation in Article, where the information may have evolved or changed.
The work encountered in the previous period golang
of the project, a little bit of interest in it, intends to seriously study, just in the building mysql
of the main environment when found that if using an agent to test their own will be more convenient (mainly to build wheels), so the time to use golang
Wrote a TCP agent (absolutely free time, very full of work)
Demand
- Because it is to learn golang, so in order to implement the basic functions of the agent as far as possible to use the basic knowledge of Golang, do not come up to take other people's things, not conducive to tamping the foundation
- Not really simple to play, learn a thing in addition to enrich the brain, but also in order to have practical use, so it is necessary to master the engineering process
- The program is not too complicated, after all, this is my first
golang
project, more days
Design
The structure diagram is as follows:
+----------+ +------------+| Client |<--------+ | |+----------+ +-------->+-----+<--------------->| Server | | | | |+----------+ | | +------------+| Client |<----------------->| |+----------+ | | | | +------------++----------+ | L | | || Client |^----------------->| B |<--------------->| Server |+----------+ | S | | | | | +------------++----------+ | || Client |<----------------->| |+----------+ | | +------------+ | | | |+----------+ +--------->+-----+<--------------->| Server | | Client |<-------+ | |+----------+ +------------+
The most common load-balancing mode, but there are several points that need to be supported:
1. Support different scheduling strategies, such as: rotation, random, Iphash
2. To have a heartbeat check mechanism, timely remove the problematic backend server, but also to recover at the time of server recovery
3. Simple monitoring, easy to see the backend Server Agent situation and the client connection situation
4. Configuration of parameters, easy to modify
5 ..... Follow up and add ...
Realize
Github:easyproxy
Welcome to Exchange ~
Summarize
At the end of the easyproxy
first edition, more in-depth study,,,, and slice
map
channel
struct
interface
Other structures, but also play the next Golang 协程
, 反射
, and 多态
other characteristics, incidentally mastered under its engineering should pay attention 包循环引入
to, debug
, and 打包发布
other issues
Feel now reading also not empty, see Open source Code also more Mulligan ~