Memory limits identification

0
Suppose I want to install a new custom made app on IED with 1GB RAM, my question is -> what should I put for mem_reservation and mem_limit in compose file? As I don't know how much I might need for a specific app. -> How do I really know when hardware limits are the only constraints?-> How do you guys tune your applications to run efficiently in such constrained environments?-> If I make a compose file with multiple services will it install multiple applications or just a single one? how does this scenario work?
asked
2 answers
0

Hi Rohit,

There’s no single right value. It depends on what your app actually uses, so you measure first and then set the limits. Here’s how I’d approach each question.

1. What should I put for mem_limit and mem_reservation?

On Industrial Edge there are two levels of memory settings:

    • Per service, in docker-compose.yml:mem_limit is a hard cap. If a container goes above it, it’s killed for running out of memory, and restarted if the service has a restart policy.
    • mem_reservation is a soft limit that only applies when the device is short on memory. It must be lower than mem_limit.
  • Per app, in the IE App Publisher (System page): a Memory Reservation and Memory Limit for the whole app. The reservation should reflect the app’s average usage and can’t be higher than the limit. The IED uses these values in its memory limit check (on by default), which can stop an app from being installed or started if there isn’t enough memory available.

How to find the values:

Step 1: Run the app on your PC with realistic load (real data, typical requests, the heaviest operation) and watch memory usage with:

docker stats

Step 2: Set mem_reservation to the normal steady usage and mem_limit to the peak plus about 25–30% headroom. For example, if a service normally uses 120 MB and peaks at 200 MB, use 128m and 256m.

Step 3: Set the app-level values in the App Publisher to cover all services together.

On a 1 GB device, never plan for the full 1 GB. The operating system, the Industrial Edge runtime and other apps need part of it.

2. How do I know when hardware limits are the real constraint?

  • If a container keeps restarting, check whether it was killed for memory. OOMKilled “true” is the real proof; exit code 137 on its own can also have other causes:

docker inspect --format “{{.State.OOMKilled}} {{.State.ExitCode}}” your-container-name

  • If memory stays flat and well below the limit but the app is still slow, memory isn’t the problem. Look at CPU, disk I/O or the code.
  • If installation or startup is refused, check the IED’s job status. It may be the memory limit check saying the device doesn’t have enough memory left for your app’s reservation.
  • Not every failure is hardware: unsupported compose attributes, ports already in use or configuration errors can look similar, so check the app logs too.
  • Testing on your PC is a good first check, but always confirm on the actual IED with the other apps running, since the hardware and load are different.

3. How do you tune apps for constrained devices?

  • Small base images (slim or alpine variants), and only the services you really need.
  • Tell the runtime about the limit, because some runtimes ignore container limits by default:
    • Node.js: set --max-old-space-size below your mem_limit
    • Java: use -XX:MaxRAMPercentage=75 so the heap stays inside the container limit
  • Limit caches, queues and buffers, and lower database cache settings, since databases take a lot of memory by default.
  • Process data in batches instead of loading everything into memory.
  • Rotate logs and avoid debug logging in production.
  • Watch memory over time. Usage that keeps growing usually means a leak.

4. Will multiple services in one compose file install multiple apps?

No. One compose file is one app. The App Publisher packages all services into a single Industrial Edge app, which is installed, started and stopped as one unit, with each service running as its own container. Each service still needs its own mem_limit, and the app-level memory settings should cover all of them together.

If parts need to be installed or updated independently, package them as separate apps.

References

If this helps, please mark it as the accepted answer.


answered
1

Hi Rohit,


For an Industrial Edge Device (IED) with 1 GB RAM, I would recommend measuring the application's actual memory usage first and then setting the memory reservation and limit accordingly. There is no single recommended value that works for every application.


1. What is the difference between mem_reservation and mem_limit?

  • mem_reservation is a soft memory reservation. It helps the platform manage memory when resources become constrained.
  • mem_limit is the maximum memory the container can use. If the container exceeds this limit, it may be stopped or terminated.

For example, for a lightweight service, you could start testing with:

version: "2.4"

services:
  my-service:
    image: my-service:1.0
    mem_reservation: 128m
    mem_limit: 256m

These values are only an illustrative starting point, not a guaranteed recommendation for every 1 GB device. A Node-RED application, for example, may need more memory depending on its flows, payload sizes, and installed nodes.


2. How do you determine the correct values?

  1. Check the device's available RAM and the memory consumed by the Industrial Edge platform and other running applications.
  2. Deploy your application in a test environment.
  3. Monitor its memory consumption during normal operation and peak workloads.
  4. Set mem_reservation based on the application's expected normal memory requirement.
  5. Set mem_limit high enough to accommodate measured peak usage, while leaving sufficient memory for the operating system, platform services, and other applications.
  6. Test under realistic load and monitor for out-of-memory errors or unexpected restarts.

Do not allocate the entire 1 GB to your application. The device needs memory for its operating system and Industrial Edge services as well.


3. How can you identify whether hardware is the bottleneck?

Check both memory and CPU usage while the application is running. Also review container logs for out-of-memory errors and inspect whether the application is restarting or becoming unresponsive.

Use the Apps Memory statistics in Industrial Edge Management where available. Compare the application's measured peak usage against its configured memory limit and the device's remaining available memory.


4. What happens when a Compose application contains multiple services?

Each service runs in its own container, so configure memory limits for each service separately.

For example:

version: "2.4"

services:
  api:
    image: my-api:1.0
    mem_reservation: 128m
    mem_limit: 256m

  worker:
    image: my-worker:1.0
    mem_reservation: 128m
    mem_limit: 256m

In this example, the two containers have a combined configured maximum of 512 MB. That does not mean they will always consume 512 MB, but you must account for the possibility that both approach their limits simultaneously.


Also account for shared memory, where applicable, because it contributes to the memory usage of the relevant application.


Important: If your application has multiple containers, do not confuse the individual container limits with the overall application memory reservation and limit configured in IE App Publisher. Review both configurations and ensure they are consistent with your device's available resources.


Official references


My recommendation is to start with measured memory usage rather than selecting arbitrary values. For a 1 GB device, test the application under peak load and verify that the combined application and platform memory requirements fit within the available RAM.


Hope this helps! If you find this answer helpful, please mark it as the accepted answer.

answered