litespeedtech / openlitespeed

Our high-performance, lightweight, open source HTTP server
https://openlitespeed.org
GNU General Public License v3.0
1.2k stars 194 forks source link

Swap is filling up - TTL is set to 3600, but files is not deleted on regular basis after TTL expiry #316

Open exetico opened 2 years ago

exetico commented 2 years ago

Hi,

My lshttpd/swap folder is filling up, due to unique minified CSS-files (and JS, but that's temporary fixed).

I know I changed something on the server at the 2022-05-16 which forced it to generated far many unique minified filed, but I'd expect OLS to clean up the cache/swap-files after the TTL is passed/expired, or checked regularly on a daily/hourly interval or so.

In LSCWP I've defined the TTL to a max of 3600, so this is part of my config:

<IfModule mod_expires.c>
ExpiresActive on
ExpiresByType application/pdf A3600
ExpiresByType image/x-icon A3600
ExpiresByType image/vnd.microsoft.icon A3600
ExpiresByType image/svg+xml A3600

ExpiresByType image/jpg A3600
ExpiresByType image/jpeg A3600
ExpiresByType image/png A3600
ExpiresByType image/gif A3600
ExpiresByType image/webp A3600

ExpiresByType video/ogg A3600
ExpiresByType audio/ogg A3600
ExpiresByType video/mp4 A3600
ExpiresByType video/webm A3600

ExpiresByType text/css A3600
ExpiresByType text/javascript A3600
ExpiresByType application/javascript A3600
ExpiresByType application/x-javascript A3600

ExpiresByType application/x-font-ttf A3600
ExpiresByType application/x-font-woff A3600
ExpiresByType application/font-woff A3600
ExpiresByType application/font-woff2 A3600
ExpiresByType application/vnd.ms-fontobject A3600
ExpiresByType font/ttf A3600
ExpiresByType font/otf A3600
ExpiresByType font/woff A3600
ExpiresByType font/woff2 A3600

</IfModule>

In OLS > Module > Cache, I'm using the following config:

checkPrivateCache   1
checkPublicCache    1
maxCacheObjSize     10000000
maxStaleAge         200
qsCache             1
reqCookieCache      1
respCookieCache     1
ignoreReqCacheCtrl  1
ignoreRespCacheCtrl 0

enableCache         0
expireInSeconds     3600
enablePrivateCache  0
privateExpireInSeconds 3600

But the server is still growing in size, with files much older than 3600 sec:

[root@production swap]# find . -maxdepth 3 -type f -printf '%TY-%Tm %s\n' | awk '{b[$1]+=$2} END{for (date in b) printf "%s %5.1f MiB\n", date, b[date]/1024**2}' | sort
2020-01   0.0 MiB
2020-04   0.4 MiB
2020-08   0.1 MiB
... (removed)
2022-02   0.8 MiB
2022-03   0.7 MiB
2022-04   0.3 MiB
2022-05 6603.1 MiB

[root@production swap]# find . -maxdepth 3 -type f -printf '%TY-%Tm-%Td %s\n' | awk '{b[$1]+=$2} END{for (date in b) printf "%s %5.1f MiB\n", date, b[date]/1024**2}' | sort
2020-01-11   0.0 MiB
2020-04-01   0.4 MiB
2020-08-12   0.1 MiB
... (removed)
2022-05-13   0.0 MiB
2022-05-14   0.4 MiB
2022-05-15   0.4 MiB
2022-05-16 305.8 MiB
2022-05-17 671.2 MiB
2022-05-18 649.7 MiB
2022-05-19 644.9 MiB
2022-05-20 691.2 MiB
2022-05-21 709.9 MiB
2022-05-22 562.6 MiB
2022-05-23 551.9 MiB
2022-05-24 502.2 MiB
2022-05-25 477.2 MiB
2022-05-26 601.8 MiB
2022-05-27 232.9 MiB

More details here: https://golitespeed.slack.com/archives/C3QRCDP44/p1653642082393049

Problems/Questions

1) Shouldn't the old swap files be removed on regularly basis?

2) Is there a "problem" with my current setup, of is this the expected outcome?

3) If so, how should I process from here to keep the cached files to a more limited amount (x days old)?

System info OpenLiteSpeed 1.7.15 LiteSpeed Cache Report Number: PYBWTPVS (if the details helps with any debugging)

therealgilles commented 2 years ago

Can we get this fixed? It would be nice to have a max disk space setting.

exetico commented 2 years ago

Currently I'm using the following command: /usr/bin/find /tmp/lshttpd/swap -name "*.lsz" -type f -mtime +1 -exec rm -f {} \;

WIth the following cron-timing: 0 5 * * *

It's odd that it's not fixed, yet.

therealgilles commented 2 years ago

My /tmp space is 1.5GB and lshttpd keeps growing to 1.3GB:

1.3G    /tmp/lshttpd