[kwlug-disc] fun: 10k to a million threads and more?

Chris Frey cdfrey at foursquare.net
Tue May 30 19:09:44 EDT 2023


On Tue, May 30, 2023 at 04:18:44PM -0400, Khalid Baheyeldin wrote:
> That tells me that systemctl has taken over yet another component ... sigh
> ...
> 
> Is there a way to do the same thing from the older CLI tools?

Systemd runs everything in a cgroup of some kind.  So my normal user
login (user-1000.slice) has its own set of limits.

If you're not using systemd, then you're probably also not using cgroups
in your day-to-day work, and this won't apply to you.  So the /proc
and ulimit settings I listed before *should* work in theory.


> And can this limit (and others) be increased for non-root users?

I believe so.  I did:

	# create a new slice with new config (run as root)
	systemctl set-property maxthreads.slice TasksMax=100000

	# run a new shell in that slice (run as me)
	systemd-run --slice=maxthreads.slice --uid=cdfrey --shell

	# confirm new shell is in the right cgroup
	cat /proc/self/cgroup |grep pids

	# check my new limits:
	systemctl show maxthreads.slice |grep TasksMax

But I ran into the ulimit problem next.  I have a hard ulimit
max user processes of 10000, and I need to be root to change that.
Not sure how to change that in an already-running shell.

> On two different systems running Ubuntu 20.04, I get different values:
> 
> This is on the server edition
> # systemctl show user-1000.slice | grep TasksM
> TasksMax=41871
> 
> This is on Xubuntu
> # systemctl show user-1000.slice | grep TasksM
> TasksMax=31142

I suspect this is due to the version of the kernel and the size of
RAM on the machines.  I have a Bullseye machine with much more RAM
that shows TasksMax of 65999.  I haven't probed deeply as to why.

- Chris




More information about the kwlug-disc mailing list