PHP5 session clean cron job causes OOM
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
php5 (Ubuntu) |
Fix Released
|
Undecided
|
Unassigned | ||
Trusty |
Triaged
|
Medium
|
Nish Aravamudan |
Bug Description
The php5 file-based session cleaner script /var/lib/
The script performs an lsof +d /var/lib/php5, which can itself take several minutes on my servers when they serving peak traffic of about 500 req/sec. This lsof command is extremely expensive (imagine iterating 5000 threads/procs, each of which has dozens or hundreds of open files). As a result of the load of this command, the server's connections back up leading to an out of memory condition (OOM) at which point the kernel tells oom_killer to start killing processes.
The really kicker here is that my session management is not done with files (most high-performance PHP sites would not be), so all this work is done in vain.
As a subject-matter expert in PHP and GNU/Linux, I recommend we update /usr/lib/
New versions: https:/
The new sessionstorage script simply prints out which session.
For reference, I am running on AWS c3.xlarge instances with NGINX, PHP5-FPM and Redis (no MySQL, no sessions at all). sessionclean kills my instances when the total CPU usage is around 20% (where 100% is a load of 4.0 on my 4-vCPU server), so I have a lot more room for requests if this is fixed.
ProblemType: Bug
DistroRelease: Ubuntu 14.04
Package: php5-common 5.5.9+dfsg-
ProcVersionSign
Uname: Linux 3.13.0-29-generic x86_64
ApportVersion: 2.14.1-0ubuntu3.3
Architecture: amd64
Date: Tue Aug 12 23:46:17 2014
Ec2AMI: ami-62a2730a
Ec2AMIManifest: (unknown)
Ec2Availability
Ec2InstanceType: c3.xlarge
Ec2Kernel: aki-919dcaf8
Ec2Ramdisk: unavailable
ProcEnviron:
TERM=xterm
PATH=(custom, no user)
XDG_RUNTIME_
LANG=en_US.UTF-8
SHELL=/bin/bash
SourcePackage: php5
UpgradeStatus: Upgraded to trusty on 2014-07-30 (13 days ago)
modified.
mtime.conffile.
Changed in php5 (Ubuntu Trusty): | |
assignee: | nobody → Nish Aravamudan (nacc) |
tags: | removed: server-next |
On another note, why would we possibly need to run lsof every time we need to cleanup sessions? This is a very inefficient and expensive process. If someone knows how it came to be that this code was added, I would be very curious. Also, I see that recent versions of Ubuntu (14.04 for example) put a modules/ folder in /var/lib/php which is quite disconcerting since there are potentially thousands of session files in there as well.