Friday, December 5, 2008

Running more Threads on Linux

Have you wondered sometimes you can't put on more threads for your scripts on Linux? Well the answer is simple. The Default settings for per-thread stack size is 10240 and the maximum number of processes the user can invoke is as large as 71680(this may vary from system to system). These defaults are responsible for limiting the number of threads that you can use in your programs. So reducing these values will allow you to use more threads. The commands you will use for this case is ulimit which shows or sets the resources for a Linux process. Based on my experience, I usually use these values by typing on the prompt:

ulimit -s 2048 --> I got 2gig of RAM, so for bigger RAM try to use larger values like 4096
ulimit -u 8068

There you go! Now you can play with more threads on your scripts.

0 comments: