NumCPUs best practice on multi core/multi relay servers

Hi,

Tor keeps telling me that it maxes out at 16 cores:

Wow! I detected that you have 24 CPUs. I will not autodetect any more than 16, though. If you want to configure more, set NumCPUs in your torrc

I was under the impression that by default this applies for each torrc file/tor relay individually, and that multiple torrc files will use the cores they need unless you limit it in the specific torrc file with the NumCPUs configuration parameter.

But the total load for all tor relays (each having their own torrc file) always averages out on 16 (for months now), so I begin to suspect this is also some general limit (or that it’s just coincidence that it’s both 16). My tor server still has some room to grow so I wouldn’t mind putting it to work a bit more. So my questions are:

  1. Is there indeed some general limitation of 16 cores for all tor processes together without defining a higher amount manually?
  2. If so, what would be best practice to fix this? Add 2 cores to each torrc file? Or is there some general setting to upgrade the limit?

Thanks in advance!

1 Like

NumCPUs have been a topic in the meetings and on the list in the last few weeks.
In short: leave it alone
more precisely here: Sanity check on NumCPUs

1 Like

Thanks for your reply! I already read the linked comment when I searched this forum before I posted my question, but it doesn’t answer my question sadly.

Does the default maximum of 16 cores apply to each tor relay/torrc file or to tor as a whole? If it’s the latter then the advice to let tor use all available cores also means configuring NumCPUs. But I can’t find documentation on the inner workings of this default maximum, so hence I ask to be sure :slight_smile: .

Yes, if you have 40 tor-instances you will see 40 instances with this Wow! ... Each instance starts multiple threads: htop - 2 tor-instances on quad core
I have 40 instances running on 40 CPU cores. The only problems are network I/O or the network driver. :unamused:

1 Like

Okay, then it shouldn’t matter and I can leave NumCPUs as default. Thanks for helping! Kind of sad though, I was hoping that this would be the bottleneck I’m experiencing on my Tor server. My CPU is only utilized ~60% so I was trying to locate the bottleneck to make it use ~100% and contribute more bandwidth to the network.

That’s why we all have multiple instances on one server. Only 2 instances/IP possible!

tor-instance-create 00
tor-instance-create 01
systemctl enable tor@00
systemctl enable tor@01
systemctl mask tor@default
systemctl daemon-reload

nano /etc/tor/instances/00/torrc
nano /etc/tor/instances/01/torrc
systemctl start tor

If your relay is new, be patient. Guard relays only make traffic after 3-4 months.
On the servers where I don’t pay electricity, the free CPU’s do Monero mining. ¯_(ツ)_/¯

1 Like

I’m doing pretty much the same, running 18 relays right now, of which 15 are on the same server. They run for some time now as well so that shouldn’t be the bottleneck. The difference is I’m not running Linux but FreeBSD, so running multiple relays works a bit differently for me :slight_smile: .

Actually not a bad idea to mine some crypto currency on the underutilized cores though… I might be able to contribute some more to Tor that way.

On Windows it does not matter, tor process will stick to one CPU :frowning:

This is also the case on Linux and BSD. C-Tor is not really multicore aware.
If I understand correctly, the Tor main process is on one core. The other threads are not really used. (1-3% CPU) Important the processor AES-NI option is enabled → BIOS setting.
Chapter 4 + 5 Tor: A Multi-Threaded Relay Architecture

Arti, the upcoming Tor implementation in Rust, will utilize multiple cores/threads much better.
Tor Browser first (this or next year) relays and onion services in Rust development will take a few more years.