OLS 500Mb Upload - MMAP error

#1
Hello,

I am trying to upload a 500MB zip file to a PHP script. The POST request fails with CONNECTION_RESET.

I am getting the following error in stderr.log

2022-11-01 02:58:53.858 [STDERR] mmap() failed in remapBlock: Cannot allocate memory
2022-11-01 02:58:53.858 [STDERR] terminate called after throwing an instance of 'std::bad_alloc'
2022-11-01 02:58:53.858 [STDERR] what(): std::bad_alloc


I have spent hours looking at all relevant settings and can't seem to find why this would error.

Here are extracts from my httpd_config.conf

tuning {
shmDefaultDir /dev/shm/lsws
maxConnections 500000
maxSSLConnections 500000
connTimeout 300
maxKeepAliveReq 10000
keepAliveTimeout 60
sndBufSize 0
rcvBufSize 0
maxReqURLLen 32768
maxReqHeaderSize 32K
maxReqBodySize 204700M
maxDynRespHeaderSize 32768
maxDynRespSize 204700M
maxCachedFileSize 8192
totalInMemCacheSize 256M
maxMMapFileSize 256K
totalMMapCacheSize 512M
useSendfile 1
fileETag 28
enableGzipCompress 1
compressibleTypes default
enableDynGzipCompress 1
gzipCompressLevel 7
gzipAutoUpdateStatic 1
gzipStaticCompressLevel 7
brStaticCompressLevel 7
gzipMaxFileSize 10M
gzipMinFileSize 300
quicEnable 1
quicShmDir /dev/shm
}


extprocessor lsphp {
type lsapi
address uds://tmp/lshttpd/lsphp.sock
maxConns 2048
env PHP_LSAPI_CHILDREN=2048
env LSAPI_AVOID_FORK=2048M
env LSAPI_MAX_PROCESS_TIME=86400
initTimeout 60
retryTimeout 0
persistConn 1
respBuffer 0
autoStart 2
runOnStartUp 3
path lsphp80/bin/lsphp
backlog 100
instances 1
priority 0
memSoftLimit 20470000M
memHardLimit 20470000M
procSoftLimit 1400
procHardLimit 1500
}

wsgiDefaults {
maxConns 5
env LSAPI_MAX_IDLE=60
initTimeout 60
retryTimeout 0
pcKeepAliveTimeout 60
respBuffer 0
backlog 50
runOnStartUp 0
extMaxIdleTime 300
priority 3
memSoftLimit 2047M
memHardLimit 2047M
procSoftLimit 500
procHardLimit 600
}



From within PHP, running shell_exec('ulimit -a');

time(seconds) unlimited
file(blocks) unlimited
data(kbytes) unlimited
stack(kbytes) 8192
coredump(blocks) 0
memory(kbytes) unlimited
locked memory(kbytes) 64
process 24776
nofiles 1048576
vmemory(kbytes) 20961280000
locks unlimited
rtprio 0


Shell free -h:

root@webserver-r2r9r:/tmp# free -h
total used free shared buff/cache available
Mem: 11Gi 9.1Gi 1.7Gi 147Mi 837Mi 2.1Gi
Swap: 0B 0B 0B


Any help would be appreciated.
 

Cold-Egg

Administrator
#2
Please try to increase procSoftLimit and procHardLimit to e.g. 2000
And memory_limit from the php.ini file to 1 GB see if it helps.
 
#3
Thanks - but unfortunately no luck.

PHP already has memory_limit =1G
procSoftLimit and procHardLimit are child process limits and I tried increasing them, but still didn't have success.
 
Top