Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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

1 Answer 1

up vote 0 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

 
discard

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.