Improve company productivity with a Business Account.Sign Up

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1913
  • Last Modified:

open file descriptors

on Linux server how do I find what is the maximum number of open file descriptors per JVM process and how do I change it and what is the recommended number? so its 3 questions :)
0
Buffon
Asked:
Buffon
  • 6
  • 5
1 Solution
 
slyongCommented:
Hi,

I am not sure how to find the maximum number of open file descriptors per JVM.  On Linux, the system wide file descriptor can be found:

# cat /proc/sys/fs/file-max

to change it
# echo "65535" > /proc/sys/fs/file-max

to check how many file descriptor being used:
# cat /proc/sys/fs/file-nr
1400    119     65535
   |           |          |__ maximum number of file descriptors allowed on the system
   |           |    
   |           |__ total free allocated file descriptors
   |
   |__  total allocated file descriptors

to show the open file descriptor for processes:
# lsof
0
 
BuffonAuthor Commented:
thanks for reply, but I already know about max for wide system, I really need it per process (I think its the same for jvm process) and not wide system :(
by the way what is "total free allocated file descriptors"?
0
 
ravenplCommented:
The default fd limit for any process in linux is 1024
You can verify it: ulimit -n
You can change: ulimit -n 10240 # but increasing the limit is allowed only to root user.
If You want increase it system wide - You would have to do two things
- put the command in some early init script (like /etc/rc.d/rc)
- increase it for each user that logs into the system, it's /etc/security/limits.conf - add line like
*              -       nofile          10240
0
A proven path to a career in data science

At Springboard, we know how to get you a job in data science. With Springboard’s Data Science Career Track, you’ll master data science  with a curriculum built by industry experts. You’ll work on real projects, and get 1-on-1 mentorship from a data scientist.

 
BuffonAuthor Commented:
is it recommended to increase it? what is the impact on system?
0
 
ravenplCommented:
The limit there is mainly for security reason(as You already know there is limited number of FDs in whole system), but it also helps debugging leaking applications(the other question ;).
It's not recommended to increase this limit globally (as I suggested above) - but if application needs more than 1024 or leaks(then it's temporarty sollution) I would advise to increase the limit for this application only.
In the latter case the application(daemon) have to be initially run as root.
0
 
BuffonAuthor Commented:
ok it runs as root and I have root access, so its not a problem. how do I increase this number only for this application?
0
 
ravenplCommented:
How the application is started?
0
 
BuffonAuthor Commented:
through ssh, as root, java Server......
0
 
ravenplCommented:
Then simply create a script which will run the app (or maybe it's already script), and before running the app/java add
ulimit -n 10240
0
 
BuffonAuthor Commented:
bash script? so it applies only for current session application? I run it with & parameter and then I close the ssh, will it work?
0
 
ravenplCommented:
the ulimit works for current process and all childs(but each process has it's own limit).
> I run it with & parameter
Yes. But of course the application has to be capable of running in background. Otherwise use nohup command in addition
nohup command parameters &
0
 
BuffonAuthor Commented:
yes, of course it continues to run in background, so no need for nohup?
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 6
  • 5
Tackle projects and never again get stuck behind a technical roadblock.
Join Now