Projects tigase _server server-core Issues #1325
Allow setting socket buffer size (#1325)
Andrzej Wójcik (Tigase) opened 3 years ago

Currently, the only option to adjust TCP socket buffer size is by settings the net-buffer property on the instance of ConnectionManager using the Tigase configuration file. However, this not only increases the TCP socket buffer size used by the operating system but also increases internal TCP buffers which are used for processing data from the socket, and forces them not to scale to smaller values than net-buffer value.

While this allows best performance, it causes significant memory usage when a lot of connections are being used., ie. changing net-buffer from 2KB to 4KB increase memory usage by a single connection from 12KB to 24KB. On the other hand, with long round trip times, it would be better to have bigger TCP socket buffers to speed up reading/sending batch of data over the network and we do not need to keep bigger internal buffers all the time as we do not need (or want) to increase performance of those connections.

The best would be to create a new variable named socket-buffer which wouldn't be set by default (null) and in this case, net-buffer size would be used. However, if it would be set, it's value would be used as TCP socket buffer size.

Andrzej Wójcik (Tigase) commented 3 years ago

On macOS SO_RCVBUF value is by default used initially, then macOS automatically adjusts its value. This behavior can be disabled with the following command:

sudo sysctl -w net.inet.tcp.doautorcvbuf=0
Andrzej Wójcik (Tigase) commented 3 years ago

I've implemented settings SO_RCVBUF size with the socket-buffer-size property of ConnectionManager which value, if set, is used instead net-buffer as SO_RCVBUF value.

I've confirmed with a manual test that this works. After review, it will be deployed on our installation to confirm that it works correctly.

wojciech.kapcia@tigase.net commented 3 years ago

Looks ok

Andrzej Wójcik (Tigase) commented 3 years ago

As discussed in mam-75 and over IM, I've adjusted default values and added documentation. Please review.

wojciech.kapcia@tigase.net commented 3 years ago

I merged the changes and added release notes

issue 1 of 1
Type
Task
Priority
Normal
Assignee
Version
tigase-server-8.3.0
Spent time
5h
Issue Votes (0)
Watchers (0)
Reference
tigase/_server/server-core#1325
Please wait...
Page is in error, reload to recover