Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

For network apps that create one thread per connection (like Pound), threadcount can become a bottleneck on the number of concurrent connections you can server.

I'm running FreeBSD 8 x64:

$ sysctl kern.maxproc
kern.maxproc: 6164

$ sysctl kern.threads.max_threads_per_proc
kern.threads.max_threads_per_proc: 1500

$ limits
Resource limits (current):
  cputime              infinity secs
  filesize             infinity kB
  datasize             33554432 kB
  stacksize              524288 kB
  coredumpsize         infinity kB
  memoryuse            infinity kB
  memorylocked         infinity kB
  maxprocesses             5547
  openfiles              200000
  sbsize               infinity bytes
  vmemoryuse           infinity kB
  pseudo-terminals     infinity
  swapuse              infinity kB

I want to increase kern.threads.max_threads_per_proc to 4096. Assuming each thread starts with a stack size of 512k, what else do I need to change to ensure that I don't hose my machine?

share|improve this question
For a sane application you shouldn't be running into the max_threads limit. But then, scaling applications is rarely sane. Performance suffers when you have thousands of threads. Instead of screwing with the limits, that are pretty high, it's worth considering replacing Pound with Pen, or another load balancer with is select() based. That will get you a bit further before you run into the OS limits. – pehrs Apr 21 '10 at 21:13
select() has fairly low limits as well, though you'll see much better performance when you've got a thousand connections going. On the BSDs kqueue is the way to go, on Linux epoll. But this is a discussion for the developers (whom you should be contacting, and requesting they change their app, thread-per-connection is old-school). – Chris S Apr 21 '10 at 23:01
Let's assume that Pound is in there for a reason (it is) and can't be trivially replaced (it can't). – sh-beta Apr 21 '10 at 23:18
up vote 1 down vote accepted

FWIW, I set kern.threads.max_threads_per_proc to 4096 without modifying any other settings and haven't seen any ill effects. Pound even got there a couple times (eating up 2GB of RAM while doing so).

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.