0

Sometime ago we have came upon interesting problem. Sometime (not everytime, lets pretend nearly each 100-200 hit) session_start() takes very long time. Up to 60 seconds. (longest one was 63, generally around 50).

Server run CentOS 6.5 (linux kernel 2.6.32-431.17.1.el6.x86_64) nginx/1.4.7 (yep i know it is old) + Apache/2.2.15 + PHP 5.3.3 (using mod_php) Two intel SSD 530 makes Raid 0 There is a lot of free ram 5+ GB. I tried to tune vm.swappiness value may be it is because of some memory-disk transaction. No help.

It appears even if there is almost no load on server.
Session stored in files. Put sessions on ramdrive (tmpfs). No help. There are around couple hundreds session files in directory. So there shouldn't be lookup problem. Sometimes the same issue occurs on include/require, php takes seconds to load file before starting it processing. So it is some io issue. atop/top hasn't shown anything abnormal while session start process hangs.

free -m output during hang

             total       used       free     shared    buffers     cached
Mem:         32101      23485       8616          0       1532      15642
-/+ buffers/cache:       6310      25790
Swap:        16383       1222      15160

free -m output normal

             total       used       free     shared    buffers     cached
Mem:         32101      23438       8662          0       1532      15623
-/+ buffers/cache:       6281      25819
Swap:        16383       1222      15160

nginx write this in log in time of slowdown

2015/09/29 15:40:36 [warn] 16854#0: *14779 an upstream response is buffered to a temporary file /var/cache/nginx/proxy_temp/1/02/0000000021 while reading upstream

tried setting proxy_max_temp_file_size but with no help.

May be anyone knows what could be the reason, or in this direction to dig

5
  • Hi, session_startup is not a PHP function. Are you using some sort of framework? How have you identified that this is session related? Can you show a snippet of the benchmark code and maybe 300 sample results?
    – MonkeyZeus
    Sep 29, 2015 at 13:02
  • sorry, session_start
    – TKF
    Sep 29, 2015 at 13:05
  • i have profiled every code string until narrowed to one string. the call of session_start(), although it seems more like some server issue than php itself.
    – TKF
    Sep 29, 2015 at 13:06
  • Are you using opcache? maybe is the time need to recompile and save in the cache again, if opcache is active maybe don't have memory for all your code (opcache.memory_consumption or opcache.max_accelerated_files). Other test could be use APC to save the sessions, the you will see if is problem with disk I/O. Sep 29, 2015 at 14:27
  • It is PHP 5.3 so no opcache. isn't tmpfs as target for session file saving lacks of disk i/o problems?
    – TKF
    Sep 29, 2015 at 15:09

0

You must log in to answer this question.

Browse other questions tagged .