Project

General

Profile

What values for TCP_KEEPALIVE fit mobile chat application with Tigase

Igor Khomenko
Added over 4 years ago

I'm investigating TCP_KEEPALIVE options to detect broken connection

Here are what settings Tigase team suggests http://www.tigase.org/content/linux-settings-high-load-systems

net.ipv4.tcp_keepalive_time=60
net.ipv4.tcp_keepalive_probes=3
net.ipv4.tcp_keepalive_intvl=90

To understand these values I use next guide http://www.gnugk.org/keepalive.html

sysctl -w net.ipv4.tcp_keepalive_time=60 net.ipv4.tcp_keepalive_probes=3 net.ipv4.tcp_keepalive_intvl=10

This sample command changes TCP keepalive timeout to 60 seconds with 3 probes,
10 seconds gap between each. With this, your application will detect dead TCP
connections after 90 seconds (60 + 10 + 10 + 10).

So, for example I would like to have 15 seconds broken connection timeout

I set

net.ipv4.tcp_keepalive_time=5
net.ipv4.tcp_keepalive_probes=2
net.ipv4.tcp_keepalive_intvl=5

How much load will these settings produce?

For mobile applications it's too critical to detect broken connection as fast as possible.

Please advise


Replies (11)

Avatar?id=6023&size=32x32

Added by Artur Hefczyc TigaseTeam over 4 years ago

I am afraid we cannot answer the question. We have never run such a detailed tests. This kind of testing is extremely expensive and time consuming so we usually run such tests and investigation under a contract agreements.

Added by Igor Khomenko over 4 years ago

Thanks Artur,

can you please comment another issue related to the TCP_KEEPALIVE settings

for example I set

net.ipv4.tcp_keepalive_time=5
net.ipv4.tcp_keepalive_probes=2
net.ipv4.tcp_keepalive_intvl=5

then I had switched Internet off on my iPad and opened Tigase logs.

Sometimes Tigase realises broken connection in 15 seconds (according to the formula above), but sometimes it takes more time to detect.

Do you have any ideas why?

Added by Igor Khomenko over 4 years ago

hmm,

If I add these settings to the file /etc/systcl.conf - it works ok

but if I just use command line to set

# sysctl -w net.ipv4.tcp_keepalive_time="5"
# sysctl -w net.ipv4.tcp_keepalive_probes="2"
# sysctl -w net.ipv4.tcp_keepalive_intvl="2"

it works strange

Avatar?id=6023&size=32x32

Added by Artur Hefczyc TigaseTeam over 4 years ago

Maybe you should try values without quotes?

# sysctl -w net.ipv4.tcp_keepalive_time=5
# sysctl -w net.ipv4.tcp_keepalive_probes=2 
# sysctl -w net.ipv4.tcp_keepalive_intvl=2

Added by Luca Stucchi about 4 years ago

Hi Igor, sorry for introducing me in this old thread, but were you able to evaluate the impact on your server for your tests ? I am following exactly your same path, did you have luck along the way or it was beating too hard your poor server ?

Thanks in advance,

Luca

Added by Igor Khomenko about 4 years ago

Yes, it works for me

But better way is to use Tigase 5.2.3 or newer - it provides the same settings in init.properties

Added by Luca Stucchi about 4 years ago

Kidding ? Where did you find the indication for that ? That would be great !

BTW I am already using Tigase 7 so that would give me a lot of help !

I couldn't find any reference on http://docs.tigase.org/tigase-server/7.0.0/Administration_Guide/html/ , but I will find it !

Thank you so much !

Luca

Added by Igor Khomenko about 4 years ago

Look at

  1. --watchdog_delay

  2. --watchdog_ping_type

  3. --watchdog_timeout

http://docs.tigase.org/tigase-server/7.0.0/Properties_Guide/html/#watchdogDelay

Added by Luca Stucchi about 4 years ago

Oh, OK, I am already using the watchdog, but I thought it was a complement to the operative system settings, not a replacement.

I just run a test and It looks like either the watchdog timeout is ignored, or it is considered AFTER a disconnection was detected.. so we return to the scenario of before

these are my settings:

c2s/watchdog_delay[L]=10000
c2s/watchdog_timeout[L]=60000
c2s/watchdog_ping_type=xmpp

In particular, watchdog_timeout passes without triggering anything... I have the impression that the disconnection detection is still ruled by TCP_KEEPALIVE properties and so I should lower those values before anything else.

Does this make any sense ?

Regards,

Luca

Added by Igor Khomenko about 4 years ago

I didn't try the watchdog settings

but TCP_KEEPALIVE properties works for me great

just one thing regarding TCP_KEEPALIVE properties: they change these settings across all server, not only Tigase app

Added by Luca Stucchi about 4 years ago

It makes sense ! In fact this confirms my perception that TCP_KEEPALIVE and watchdog are two different settings, working on different levels.

And yes I knew that setting the TCP_KEEPALIVE properties at server level every application running on that server will share the same settings, but it will be OK.

All the best,

Luca

    (1-11/11)