Skip to main content

Posts

Showing posts from August, 2015

[linux] Adjusting child processes for PHP-FPM (Nginx)

Adjusting child processes for PHP-FPM (Nginx) Problem: The following warning message appears in the logs: [26-Jul-2012 09:49:59] WARNING: [pool www] seems busy (you may need to increase pm.start_servers, or pm.min/max_spare_servers), spawning 32 children, there are 8 idle, and 58 total children [26-Jul-2012 09:50:00] WARNING: [pool www] server reached pm.max_children setting (50), consider raising it It means that there are not enough PHP-FPM processes. Solution: We need to calculate and change these values based on the amount of memory on the system: /etc/php-fpm.d/www.conf pm.max_children = 50 pm.start_servers = 5 pm.min_spare_servers = 5 pm.max_spare_servers = 35 - the following command will help us to determine the memory used by each (PHP-FPM) child process: ps -ylC php-fpm --sort:rss The RSS column shows non-swapped physical memory usage by PHP-FPM processes in kilo Bytes. On an average each PHP-FPM process took ~75MB of RAM on my machine. Appropriate valu...

[linux] How to determine the number of physical CPUs on Linux

How to determine the number of physical CPUs on Linux The   /proc/cpuinfo   file contains information about the CPUs installed on your computer however it’s quite confusing when you have to deal with multi-core processors. - list number of physical CPUs: $ cat /proc/cpuinfo | grep "physical id" | sort | uniq | wc -l 1 - number of cores: $ cat /proc/cpuinfo | grep "cpu cores" | uniq cpu cores : 2 - how many virtual processors: $ cat /proc/cpuinfo | grep "^processor" processor : 0 processor : 1 If the number of virtual processors is greater than the number of physical processors, the CPUs are using hyper-threading. Hyper-threading will only work with the SMP kernel.

[linux] awk

Awk - Reporting Tool Usage: awk ‘/pattern/ { procedure }’ | PIPE | STDIN Example file: file.txt one two three one1 two10 three one four two one two three - print entire line: awk '{ print }' file.txt or awk '{ print $0 }' file.txt - print specific columns ( $1, $2 .. $n): awk '{ print $1}' file.txt - print multiply columns: awk '{ print $1; print $2 }' file.txt awk '{ print $1, $2 }' file.txt - print columns from lines containing pattern: awk '/pattern/ { print $1 }' file.txt - print columns from lines containing digits: awk '/[0-9]/ { print $1 }' file.txt Delimiters: Default delimiter: white-space (space, tabs): awk -F: '{ print $1 }' /etc/passwd - support for character classes in setting the default delimiter: awk -F "[:;.\t]" Awk scripts: Awk scripts consist of 3 parts: 1. Before (denoted using: BEFORE) 2. During (main Awk loop) 3. After (denoted using: END) awk ...

[linux] sed

Sed - UNIX Stream Editor Usage: sed [options] ‘instructions’ file.txt | PIPE | STDIN Example file: file.txt one two three one1 two10 three one Meta-characters: ”^” - matches character(s) at the beginning of a line: sed -ne '/^pattern/p' file.txt ”$” - matches character(s) at the end of a line: sed -ne '/pattern$/p' file.txt - match line which contain only “pattern”: sed -ne '/^pattern$/p' file.txt RegEx quantifiers: ”.” - matches any character (typically expect new line) “*” - 0 or more matches of the previous character ”+” - 1 or more matches of the previous character ”?” - 0 or 1 of the previous character Character classes: a. [0-9] b. [a-z] NOTE: Character classes match one and only one character. - print first line: sed -ne '1p' file.txt - prints last printable line: sed -ne '$p' file.txt - prints lines 2-4 from file: sed -ne '2,4p' file.txt - prints all lines except line 1: sed -n...