0

I have an application that uses Imagemagick's convert utility to resize images. The application has an API exposed which executes a convert command for each request. The application usually serves ~20 requests/s but can spike to upto 200/s. I want to limit the overall memory that Imagemagick's multiple convert processes take.

I have explored setting of resource limits for memory, map and disk in Imagemagick but all these settings seem to apply for per-convert execution. Haven't found any configuration to restrict overall/total usage of multiple simultaneous convert executions.

I have also explored setting config at OS level like ulimit. But these seem to be at process ID level. My need is to restrict total memory of all parallel convert processes.

So I have 2 questions,

  1. Does imagemagick have some configuration that will allow me to do it?
  2. If no then how can I achieve this on a Kubernetes pod running on Centos.

Do note that the convert process is executed for each API request received and terminates after processing the image. So each API request executes a new convert command.

Swastik Gupta
  • 149
  • 1
  • 1
  • 12
  • If the user executing the process is not root, you can enforce limits for that user executing the process via `/sys/fs/cgroup/memory/memory.limit_in_bytes`. You can refer [this](https://unix.stackexchange.com/questions/134414/how-to-limit-the-total-resources-memory-of-a-process-and-its-children) for more details – harshavmb Nov 08 '22 at 12:12
  • It is being executed as root. Further, the application running is a java app and is also running as root user. Restricting it at user level would restrict it for the java process too. – Swastik Gupta Nov 08 '22 at 12:21

0 Answers0