Linux ulimit Performance Tuning

Source: Internet
Author: User

UlimitThe resources used to start a shell process are shell built-in commands.


Function Description:Controls shell program resources. Note:Ulimit is a built-in shell command that can be used to control shell execution program resources. Syntax format:Ulimit [-acdfhlmnpsstvw] [size] Parameters:-A: displays the current resource limit settings. -C sets the maximum value of the core file, in blocks. -D <Data Partition size> maximum value of the Program Data Partition, in KB. -F <file size> the maximum file that can be created by shell. The unit is block. -H: Set the hard limit of resources, that is, the limit set by the Administrator. -M <memory size> specifies the maximum memory available, in KB. -N <file quantity> specifies the maximum number of files that can be opened at the same time. -P <buffer size> specifies the size of the MPs queue buffer, in 512 bytes. -S <stack size> specifies the maximum number of stacks, in KB. -S: Set the elastic limit of resources. -T specifies the maximum CPU usage time, in seconds. -U <program count> the maximum number of programs that can be opened by users. -V <virtual memory size> specifies the upper limit of virtual memory available, in KB. Ulimit-a to view all limit values

Application instance:

When writing a program in Linux, if the program is large, you will often encounter a "segment error" (segmentation fault) problem, mainly because of the initial stack size of the Linux system) it is too small, generally 10 m. Generally, the stack size is set to 256 MB, so there is no segment error! Command:

Ulimit-s 262140

If you want the system to automatically remember this configuration, edit the/etc/profile file, under the "ulimit-s-c 0>/dev/null 2> & 1" line, add "ulimit-s 262140" and save and restart the system.

Linux limits the maximum number of processes for each user. To improve performance, you can set the maximum number of processes for each linux user based on the device resources. Below I will set the maximum number of processes for a Linux User to 10000:

Ulimit-u 10000

For Java applications that require many socket connections and make them open,
You are advised to use ulimit-n xx to modify the number of files that can be opened by each process. The default value is 1024.
Ulimit-N 4096 increases the number of files that each process can open to 4096. The default value is 1024.
Other important settings recommended for unlimited are:

Data Segment Length: ulimit-D Unlimited
Maximum memory size: ulimit-M Unlimited
Stack size: ulimit-s Unlimited
CPU time: ulimit-T Unlimited
Virtual Memory: ulimit-V Unlimited

Core-limits the size of the kernel file. When a program crashes, the stored images of the process are copied to the core file in the current working directory of the process. The core file is only a memory image (with debugging information added) and is mainly used for debugging. The core file is a binary file, and a corresponding tool is required to analyze the memory image when the program crashes. Nofile-the maximum number of opened files for applications that require many socket connections and make them open, it is best to use ulimit-N or set the nofile parameter, set the number of file descriptors to a higher value than the default value.

Reference recommendations:

Linux ulimit Optimization

Improve system performance through ulimit

Poor man's profiler

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.