New on LowEndTalk? Please Register and read our Community Rules.
How to limit what memory app can see and utilize in Linux?
So say for example I have a 32 GB server from Hetzner and have a Site Owner License from Litespeed. My license won't run on a 32 GB and I don't want to create a VM for this. I only want the Litespeed app to see and utilize 8 GB from the 32 GB I have. Is there a good way to do this? All other applications including the OS will fully utilize the RAM.
Comments
That’s a pretty lame limitation on litespeed’s part. If it has an 8 GB limitation it should limit itself to using 8GB regardless of how much is installed. Tons of other software from Oracle, SQL Server, IBM, etc. works that way.
I believe you will need a container at minimum because Litespeed might be getting the total available memory from hardware instead.
No easy way, no. You need to debug Litespeed with strace or gdb, see how it determines available memory, then you could make a modified lib and LD_PRELOAD for Lightspeed's startup. For example, you can fake the time: https://github.com/wolfcw/libfaketime
You should try a container.
Linux has just a solution out of the box: cgroups; these let you establish limits that must be obeyed by members of the cgroup. Then you can migrate the process into the cgroup at run-time. This is bumpless and the process is not disturbed. Find details about cgroups here:
https://docs.fedoraproject.org/en-US/Fedora/15/html/Resource_Management_Guide/ch-Using_Control_Groups.html
This is the first thing I tried. While cgroups do limit the memory by the user apache (or even root), it does not limit the memory the apps "see." So while litespeed can only use 8 GB memory, it still sees the 32 GB memory and it does not run. Throws the error:
[ERROR] [LICENSE] License key operation failure: ERR LR.R: Site Owner license cannot be used on server with more than 8GB memory.
It would be hilarious if it's just using free or /proc/meminfo...replace with your own file and you're good to go LOL
Same domain and workers limit, but 60% more per month for the privilege of using your own hardware with more RAM. Fuck that noise.