Can i incrase number of threads to use in ntpd proccess?

#1

Hello there,

As some users know, like i posted before, i have a raspberry pi stratum 1 server running ntpd, but sometimes when the load incrases i see only one cores of raspberry pi is fully used to process the ntpd process, I already incrased de nice of process to -20 (highest priority), but i want to know if have some way to incrase the number of cores that can be used by ntpd…

Best regards,

Luiz Paulo

0 Likes

#2

Both NTPD & Chrony are single-thread applications…

I don’t know if a Pi has a Rust package, but there is this multi-threaded front-end…

https://github.com/mlichvar/rsntp

0 Likes

#3

FWIW, I tried rsntp on a Pi 3B+ some time ago and it didn’t help much. IIRC it could do only about 20-25 kpps. I suspect the bottleneck is in the USB NIC, not the CPU.

0 Likes

#4

I’m gonna try here, i’m using a full link of 100mbps (with onboard ethernet) and preempt-rt kernel… How can i configure this rsntp? is the same of ntpd configuration? Already compilled.

0 Likes

#5

You still need ntpd or chronyd to synchronize the clock. They need to be configured to listen on a different port or the loopback interface, so rsntp can bind to the NTP port and respond to client requests. Please see the README in the github repo.

0 Likes

#6

so, i should use “restrict ntpport 11123” on my ntp.conf ?

0 Likes

#7

No extra restrict commands should be necessary. ntpd cannot be configured to change the port, so it needs to listen on the loopback interface only:

interface ignore wildcard
interface listen 127.0.0.1

rsntp should be started with the following options:

rsntp -4 2 -6 0 -a $ADDRESS:123 -s 127.0.0.1:123

where $ADDRESS is the address of the real interface (it cannot bind to wildcard). If you have an IPv6 address, it should be specified with the -b option and -6 should be changed to 1 or how many threads you want to use for IPv6.

1 Like

#8

Thanks! Did you recommend some specific testing? Its running perfectly i think

0 Likes

#9

Run ntpdate or similar on a remote machine to make sure it is responding with “synchronized” packets. If your score is dropping suddenly, you know it’s wrong.

htop shows that all cores are utilized, but it would be nice to confirm it’s actually handling more packets. In my experience with a Raspberry Pi it was only slightly more, maybe 20%. That was with rsntp built by cargo build --release. Debug binary was significantly slower.

0 Likes

#10

The peak was arround 35kpps

0 Likes

#11

What was the max rate before?

0 Likes

#12

Before the rsntp The packet rate was about 7 to 12 kpps

0 Likes

#13

Good news! With rsntp the server score stays very stable, is really impressive! The only drop after reach maximum punctuation is because a reboot that i’ve made!

https://www.ntppool.org/scores/143.107.229.210

2 Likes

#14

I have also good experience with rsntp.
Its better use of resources to use rsntp instead of some other.

1 Like

#15

The only drops are for server load while i’m tweaking and compilling kernel, so, it is really good! Another question, RPI has 4 cores, can i use 3 cores for IPv4 and 1 core for IPv6? The

interface listen 127.0.0.1

flag should be different?

0 Likes

#16

rsntp -4 3 -6 1 would do that.

0 Likes

#17

i’m with this error:

thread ‘main’ panicked at ‘Couldn’t bind socket: Address already in use (os error 98)’, src/main.rs:296:27

0 Likes

#18

I’ll have to try rsntp. I have optimized chrony to the point that it can handle at least 20mbps but I had to make some compromises

0 Likes

#19

Chrony is better than ntpd? What are the advantages?

0 Likes

#20

Chrony vs NTPD comparison

Better is a matter of opinion I suppose. NTPD has been around a long time, has direct support for many (legacy) refclocks, and other good things. However the source code has really grown over the decades and is in serious need of a major overhaul.

Chrony is a more recent program, it’s also much leaner. It doesn’t have all the legacy support that NTPD has, it’s geared towards more modern OSes.

There is also NTPsec which is a fork of NTPD that has been stripped down and removed a ton of the obsolete legacy code (thus like Chrony it also only builds on more modern OSes). As the name implies it is more security focused too, I believe they have also re-written a fair amount of code.

1 Like