Lots of fork() failed, please increase process limit: Resource temporarily unavailable

#1
I use openlitespeed 1.4.23 ,Ubuntu 16.04 LTS and get lots of fork failed messages
Every day openlitespeed blocks and need to kill litespeed and start lsws to work again.
All other processes like mysql,node works fine .
I have set ulimit -n and -u to 1024000 , also for nobody user.
This are settings for external application
LiteSpeed SAPI App
Name lsphp56
Address uds://tmp/lshttpd/lsphp56.sock
Notes Not Set
Max Connections 1000
Environment PHP_LSAPI_MAX_REQUESTS=10000
PHP_LSAPI_CHILDREN=10000
Initial Request Timeout (secs) 20
Retry Timeout (secs) 0
Persistent Connection Yes
Connection Keep-Alive Timeout 100
Response Buffering No
Auto Start Yes
Command $SERVER_ROOT/fcgi-bin/lsphp-5.6.15
Back Log 100
Instances 1
suEXEC User Not Set
suEXEC Group Not Set
umask Not Set
Run On Start Up Yes
Max Idle Time Not Set
Priority -20
Memory Soft Limit (bytes) 512M
Memory Hard Limit (bytes) 512M
Process Soft Limit 0
Process Hard Limit 0

Process Soft Limit 0
Process Hard Limit 0 has been set to 0 because before was 512000 and problem existed.

Cpu processor its all the time under 10% and load <1.
 
#3
They have been set also to 1024000 both of them and nothing changes. The problem started from the day I installed openlitespeed .
Lots of numbers was set on Soft limit and hard limit and problem persisted.
 
#8
Problem solved, its because TaskMax systemd attribute. It was introduced in systemd 228 and makes use of the cgroups pid subsystem, which was introduced in the linux kernel 4.3. A task limit of 512 is thus enabled in systemd if kernel 4.3 or newer is running.
The lsws has to be started by systemct/ service and should be active
service lsws status

lsws.service - LSB: lshttpd
Loaded: loaded (/etc/init.d/lsws; bad; vendor preset: enabled)
Drop-In: /etc/systemd/system/lsws.service.d
ââ50-TasksMax.conf
Active: active (running) since Sat 2016-09-24 02:59:23 EEST; 6 days ago
Docs: man:systemd-sysv-generator(8)
Process: 205870 ExecStop=/etc/init.d/lsws stop (code=exited, status=0/SUCCESS)
Process: 205884 ExecStart=/etc/init.d/lsws start (code=exited, status=0/SUCCESS)
Tasks: 234 (limit: 65536)
CGroup: /system.slice/lsws.service



The simple and permanent solution is to run "systemctl set-property lsws.service TasksMax=65536" or higher number.
This problem appears on any service using with more than 512 threads .
Any ulimit modified conf, cant change this behaviour,there's no other solution.

It would be a good ideea for this command to be run/implemented on the next versions of litespeed.
 

mistwang

LiteSpeed Staff
#9
What Linux distribution are you using? We will try to build a test environment for that.
In the mean time, can you try updating the systemd unit file see if we can turn it off.

you need to edit /usr/local/lsws/admin/misc/lshttpd.service

adding
CPUAccounting=false
TasksAccounting=false
MemoryAccounting=false
under "[Service]" section, then you need restart lsws service multiple times, the updated service file will be applied automatically. see if that will take care of the extra layer of limit applied by systemd.
 
#10
Ubuntu 16.04 LTS 4.3.0-5-generic x86_64
I dont have lshttpd.service file at that path, but added
"CPUAccounting=false
TasksAccounting=false
MemoryAccounting=false" to the /etc/systemd/system/lsws.service.d which is the same file, but it doesn't overlay the default 512 limit shown at service lsws status.
 
Top