Morning traffic is a bit large, the site export traffic about 5M, access quality is not very good, the Web response is relatively slow, the system load is high.
It's strange to check the next Web node and all the Web server's httpd threads are full load. Because all Web nodes share the Session Directory through NFS to achieve session consistency, check the next NFS file server, IO Read and write more large, check the session_tmp directory, found that the Session directory temporary files reached more than 70,000, The initial judgment may be due to the lower IO performance caused by excessive file levels in the first-level directory.
Never thought about the efficiency of the session storage, today I thought of the session multilevel storage problem, to solve a directory under the session file too much reading and writing efficiency problem, check the next php.net in fact, PHP in the configuration has given the relevant options.
Php.net on the note: http://cn.php.net/manual/zh/ref.session.php
Session.save_path defines the parameters that are passed to the storage processor. If the default files processor is selected, this value is the path to the file creation. The default is/tmp. See Session_save_path (). This directive also has an optional N parameter to determine the directory depth of the session file distribution. For example, setting to ' 5;/tmp ' will make the session file and path created similar to
/tmp/4/b/1/e/3/sess_4b1e384ad74619bd212e236e52a5a174if. To use the N parameter, you must first create the directories before you use them. In the Ext/session directory there is a small shell script called mod_files.sh that can be used to do this. Also note that if you use the n parameter and N is greater than 0, automatic garbage collection will not be performed and more information is php.ini. In addition, if you use the N parameter, be sure to enclose the value of Session.save_path in double quotes "quotes" because the delimiter semicolon (;) is also an annotation symbol in php.ini.
Session.save_path string
In the definition Session.save_path you can define the path of multilevel storage, modify the php.ini
Session.save_path = "2;/data/session_tmp"
The session file is divided into two levels of storage, that is,/data/session_tmp/4/b/sess_4b1e384ad74619bd212e236e52a5a174if, take the first two characters, but PHP does not generate directories, you need to manually build, So I wrote a script to generate the initial directory.
Reference
<?php
$string = '0123456789abcdefghijklmnopqrstuvwxyz';
$length = strlen($string);
for($i = 0; $i < $length; $i++) {
for($j = 0; $j < $length; $j++) {
func_mkDir('/session_tmp/'.$string[$i].'/'.$string[$j]);
}
}
?>
After Session Directory classification processing, the IO processing value increases, the HTTP process reduces, the web processing efficiency is obviously improved