LFCS Operation of Running Systems Practice Question
An e-commerce company runs a critical application on a Linux server that occasionally becomes unresponsive. The server has 64GB RAM and runs a Java application. The operations team notices that during peak hours, the system becomes very slow and eventually the application crashes with 'OutOfMemoryError'. After restart, it works fine for a while. They suspect a memory leak but also want to ensure the system does not go down during peak hours. The system uses systemd to manage the Java service. The administrator needs to implement a solution that: (1) automatically restarts the service if it becomes unresponsive, (2) limits the memory usage of the service to prevent OOM kills on the system, and (3) provides early warning of high memory usage. Which of the following approaches best meets these requirements?
⚠ Common exam trap
It's easy for candidates to confuse ulimit or sysctl settings with cgroup-based memory limits, or assume cron-based polling is sufficient for unresponsiveness detection, overlooking systemd's built-in WatchdogSec mechanism.
Answer choices
Why each option matters
Answer the question above first, then reveal the full breakdown to understand why each option is right or wrong.
Correct answer & explanation
✓
Configure systemd service with WatchdogSec=30, Restart=on-failure, MemoryMax=32G. Also set up a log watcher that alerts when memory usage exceeds 28G via journalctl and a custom script.
It uses systemd's WatchdogSec to detect unresponsiveness and Restart=on-failure to automatically restart the service, while MemoryMax=32G enforces a hard memory limit via cgroups to prevent OOM kills. The custom log watcher provides early warning by alerting when memory usage exceeds 28G, satisfying all three requirements.
Answer analysis
Option-by-option breakdown
For each option: why learners choose it and why it is or isn't the right answer here.
- ✗
Set up a cron job to run every minute that checks memory usage with free and if > 90%, restart the service with systemctl restart. Also configure MemoryMax=32G in the systemd unit.
Why it's wrong here
Polling via cron cannot detect an unresponsive service, only host-wide memory pressure, and restarts blindly without systemd's own watchdog or MemoryMax enforcement. MemoryMax=32G alone is sound, but the monitoring half fails requirement (3): systemd's OnFailure or MemoryHigh units give early warning where free does not.
- ✗
Configure sysctl vm.overcommit_memory=2 to prevent overcommit, and allocate huge pages for Java. Also set Restart=always in the systemd unit.
Why it's wrong here
Disabling overcommit and huge pages address allocation policy, not per-service cgroup limits, so the Java process can still exhaust RAM and trigger system OOM kills. Restart=always recovers after a crash but gives no early warning. This suits tuned database workloads, not leak containment.
- ✗
Use ulimit -v 33554432 in the service script to limit virtual memory, and set Restart=always. Also configure a cron job to send alerts when dmesg shows OOM.
Why it's wrong here
ulimit -v caps virtual address space, which the JVM reserves far in excess of heap, causing startup or allocation failures rather than a real memory ceiling. dmesg OOM alerts arrive after the kill. systemd's MemoryMax and watchdog handle both requirements natively.
- ✓
Configure systemd service with WatchdogSec=30, Restart=on-failure, MemoryMax=32G. Also set up a log watcher that alerts when memory usage exceeds 28G via journalctl and a custom script.
Why this is correct
WatchdogSec=30 restarts the service when it stops responding, Restart=on-failure handles crashes, and MemoryMax=32G caps consumption below the 64GB total, preventing system-wide OOM kills. The journalctl watcher alerts before the 28G threshold, meeting all three requirements.
Go deeper
Related to this question
About these practice questions
One of 406 original LFCS practice questions on Courseiva, each with a full explanation and wrong-answer analysis — not exam dumps or protected exam content. Learn why practice questions differ from exam dumps →
JA
Written by Johnson Ajibi, MSc IT Security
Senior Network & Security Engineer · founder of Courseiva
This LFCS practice question is part of Courseiva's free Linux Foundation certification practice question bank. Courseiva provides original exam-style practice questions with explanations, topic-based practice, mock exams, readiness tracking, and study analytics to help learners prepare for the LFCS exam.