syncthing using up, all system resources ubuntu/ filling ressource limit

Hi, I am running syncthing on a server I rent to sync a few folders, between my devices. I am running syncthing in a screen, on the server. The server is running

OS: Ubuntu 22.04.5 LTS x86_64 Kernel: 5.2.0-1160.105.1.vz7.214.3

and I use the server for some other things too. One thing, that in the past was severly disturbed by syncthing using too many system ressources, is a minecraft server. But I can’t start it. Because

[Server thread/ERROR]: Encountered an unexpected exception java.lang.OutOfMemoryError: unable to create native thread: possibly out of memory or process/resource limits reached

But as soon as I restart syncthing through the web ui, the server starts without issues.

In the past, I as far as I remembered I had an error somewhere else, since syncthing had the maximum ammount of files open.

So somehow it seems to accumalate over runtime with syncthing. Running Syncthing v1.28.1, Linux (64-bit Intel/AMD Container)

Is there a setting I can tweak or a starting argument I can give?

I start syncthing with the command

screen -d -m syncthing serve --home="<userpath>/syncthing" --gui-address="http://0.0.0.0:8384"

(replaced my exact user path to )

What’s the output of running ulimit -a in shell on that server?

user@server ulimit -a
real-time non-blocking time  (microseconds, -R) unlimited
core file size              (blocks, -c) 0
data seg size               (kbytes, -d) unlimited
scheduling priority                 (-e) 0
file size                   (blocks, -f) unlimited
pending signals                     (-i) 4124744
max locked memory           (kbytes, -l) 1048576
max memory size             (kbytes, -m) unlimited
open files                          (-n) 1024
pipe size                (512 bytes, -p) 8
POSIX message queues         (bytes, -q) 819200
real-time priority                  (-r) 0
stack size                  (kbytes, -s) 8192
cpu time                   (seconds, -t) unlimited
max user processes                  (-u) 62987
virtual memory              (kbytes, -v) unlimited
file locks                          (-x) unlimited

Looks reasonable. I suspected there could be a low limit on the number of threads as this is some sort of openvz setup? That does not look like it’s the case so I don’t know.

Did you rule out that you’re not actually running out of memory on your host?

Yes, I am renting the server from local Company.

this is the output of top, in a state where some Ressource has run out

top - 11:29:06 up 29 days, 22:57,  4 users,  load average: 0,07, 0,07, 0,06
Tasks:  60 total,   1 running,  59 sleeping,   0 stopped,   0 zombie
%Cpu(s):  0,3 us,  0,2 sy,  0,0 ni, 99,4 id,  0,0 wa,  0,0 hi,  0,0 si,  0,0 st
MiB Mem :   8192,0 total,   7073,0 free,    575,4 used,    543,6 buff/cache
MiB Swap:      0,0 total,      0,0 free,      0,0 used.   7616,4 avail Mem 

I just now tried to start the mincraft server to see what would happen/if the problem is there. I had multible “./start.sh: fork: retry: Resource temporarily unavailable” and then after exiting the screen and trying again

[0.003s][warning][os,thread] Failed to start thread "G1 Main Marker" - pthread_create failed (EAGAIN) for attributes: stacksize: 1024k, guardsize: 4k, detached.
Error occurred during initialization of VM
Could not create ConcurrentMarkThread
[0.004s][warning][os,thread] Failed to start thread "G1 Conc#0" - pthread_create failed (EAGAIN) for attributes: stacksize: 1024k, guardsize: 4k, detached.
[0.005s][error  ][gc,task  ] Failed to create worker thread

All of that is consistent with the number of threads/processes being artificially limited to a low number, it’s just not visible in your ulimit output :person_shrugging:

A shot in the dark, but maybe it’s caused by a systemd unit. LimitNPROC is a huge footgun once containers are involved…

1 Like

Syncthing’s a resource hog. Fix it with ulimit and fs.inotify.max_user_instances. Minecraft deserves better

It is?!

I thaught syncthing was relatively light weight, and I could run everything. But I guess that’s not the case.

I think I will look to manage my shares always syncing otherwise, than to have syncting running on the server. I had the Idea of using another user for it, with tight ulimites, but I currently don’t really have the time to learn and set that up.

Thank you for your help :slight_smile:

ulimit has no bearing on a program’s resource usage - it just crashes the program if it tries to exceed the limit.

1 Like