High CPU/RAM usage caused by foreman (foreman-ruby & postgres) processes

hi all,

does anyone know why we have so many foreman-ruby and postgres proccess?

We have python script which update host parameters via API.


Where can I find more informations about foreman-ruby ? is that the interface between foreman and api ?

Due to the architecture of Foreman and postgres, it is completely normal to have many processes of them running. The processes are forked a certain number of times to allow for parallel workloads.
I am not sure what foreman-ruby is, though. What OS are you running on? On RHEL I don’t see any foreman-ruby processes, but I could imagine this is the foreman process name under Debian/Ubuntu or when running from source?
The number of processes both Foreman and postgres spawn can be configured, but since they do have quite some CPU utilization, I assume they are already all working quite a lot and you should not downscale on that end.

1 Like

thansk for your answer @areyus

You are right its on Debian/Ubuntu

Where can I configure it ?

If I am not mistaken, it should be the option --foreman-foreman-service-puma-workers to foreman-installer to adjust the number of foreman processes. For postgres, I don’t know, you should consult postgres documentation for that.
Still, as stated, I would recommend against lowering the number of processes, this will mainly put more load on the remaining processes and might lead to services becoming unresponsive. The installer tries to pick sane defaults for your hardware setup if you do not specify any values.

1 Like

thank you @areyus

Ok I’ll leave it as you suggest.

I send many requestes to Foreman WEB-API to update host parameters for 300 hosts, and that take to much time and high usage an CPU/RAM. Create/Update/Delete

Is there a way to work better with api ?

That depends on your use-case. You could evaluate if setting the parameters on another level (like hostgroup, OS, or something else) might be suitable.
Otherwise, the only solution I know of would be more hardware power. I am not aware of any less resource/time consuming options for the API. Depending on how your script works, maybe there is some optimization potential there.

1 Like

You are right I’ll check my script again.

I’ll leave this as last option :slight_smile:

thank you alot @areyus

do you know why after restart foreman remove last 2 weeks reports ?

This does not sound like normal behavior :thinking: Usually, there is a cron job running (from /etc/cron.d/foreman, at least on RHEL) that does regular cleanup tasks like deleting reports that are older than one week and empty reports that are older than one day (at least of we are talking Puppet reports, other things might behave differently). I thought there there was a config option somewhere to set that interval, but I can’t find it currently. Maybe your cron is somehow broken and foreman performs those tasks on startup, too? I would suggest raising a new thread for this to get awareness for this problem in particular.

1 Like

thank you @areyus I’ll open new thread