4

I host a website with a game client that uses TCP for connections. I am currently looking for a way to proxy my connections from one server to my origin server. I have tested Iptables forwarding and I have found that whilst it works HaProxy seems to perform better. The problem I'm facing is HaProxy randomly disconnects users after a random time of their connection being open. It's often less than 2 minutes. I'm quite new to Linux and of course I am a novice to haProxy.

Here my configuration, the origin IP address has been removed for obvious reasons:

global
daemon
maxconn 1000

defaults
    mode tcp
    timeout connect 5000ms
    timeout client 5000ms
    timeout server 5000ms

frontend proxy-in
    mode tcp
    bind *:1233
    default_backend proxy-out

backend proxy-out
    mode tcp
    server s1 127.0.0.1:1232

listen admin
    bind *:7772
    stats enable

Thank you. More details can be provided (if needed).

Matthew
  • 51
  • 4

1 Answers1

1

Depending on how your gaming server works, you'll probably need to work with your timeout client and your timeout server. These are currently set to 5 seconds in your configuration.

These settings relate to your tcp session. If you want to balance things a little better to your servers you may also want to look at persistence profiles to balance certain connection to the same servers. Again it really depends on your configuration.

Also look at the balance option to look through docs.

Example algorithm in haproxy docs: (http://cbonte.github.io/haproxy-dconv/configuration-1.5.html#balance)

leastconn   The server with the lowest number of connections receives the
            connection. Round-robin is performed within groups of servers
            of the same load to ensure that all servers will be used. Use
            of this algorithm is recommended where very long sessions are
            expected, such as LDAP, SQL, TSE, etc... but is not very well
            suited for protocols using short sessions such as HTTP. This
            algorithm is dynamic, which means that server weights may be
            adjusted on the fly for slow starts for instance.

May also need tcp keep alive setup: (http://cbonte.github.io/haproxy-dconv/configuration-1.5.html#option%20tcpka)

You can also actively view your sessions with a great tool call haproxyctl which you can find on github or install with gem install haproxyctl.

> haproxyctl show sess

0x1eb23c0: proto=tcpv4 src=172.12.0.149:57749 fe=https be=<NONE> srv=<none> ts=08 age=1m36s calls=40 rq[f=400000h,i=0,an=1ch,rx=1m23s,wx=,ax=] rp[f=008000h,i=0,an=00h,rx=,wx=,ax=] s0=[7,8h,fd=2,ex=] s1=[0,0h,fd=-1,ex=] exp=1m23s
0x1e3b170: proto=tcpv4 src=172.12.0.149:57750 fe=https be=<NONE> srv=<none> ts=08 age=1m36s calls=31 rq[f=400000h,i=0,an=1ch,rx=1m23s,wx=,ax=] rp[f=008000h,i=0,an=00h,rx=,wx=,ax=] s0=[7,8h,fd=3,ex=] s1=[0,0h,fd=-1,ex=] exp=1m23s
0x1e35da0: proto=tcpv4 src=172.12.0.149:57751 fe=https be=<NONE> srv=<none> ts=08 age=1m36s calls=35 rq[f=400000h,i=0,an=1ch,rx=1m23s,wx=,ax=] rp[f=008000h,i=0,an=00h,rx=,wx=,ax=] s0=[7,8h,fd=8,ex=] s1=[0,0h,fd=-1,ex=] exp=1m23s
0x1e4fa50: proto=tcpv4 src=172.12.0.149:57754 fe=https be=<NONE> srv=<none> ts=08 age=1m36s calls=15 rq[f=400000h,i=0,an=1ch,rx=1m23s,wx=,ax=] rp[f=008000h,i=0,an=00h,rx=,wx=,ax=] s0=[7,8h,fd=9,ex=] s1=[0,0h,fd=-1,ex=] exp=1m23s
nhuanca
  • 91
  • 1
  • 6