Skip to content

feat: introduce environment-aware JVM resource profiles#138

Open
RustamSheoran wants to merge 2 commits into
openMF:devfrom
RustamSheoran:feature/jvm-profiles-auto-optimization
Open

feat: introduce environment-aware JVM resource profiles#138
RustamSheoran wants to merge 2 commits into
openMF:devfrom
RustamSheoran:feature/jvm-profiles-auto-optimization

Conversation

@RustamSheoran
Copy link
Copy Markdown

Overview

This PR introduces environment-aware JVM and Kubernetes resource profiles for PH-EE deployments in Mifos Gazelle.

The current deployment configuration relies heavily on static JVM sizing and duplicated service-level heap configuration, despite Gazelle targeting deployment environments with dramatically different runtime characteristics:

  • constrained Raspberry Pi / ARM systems

  • single-node VM deployments

  • larger multi-node Kubernetes clusters

This PR introduces a profile-driven deployment model (micro/std/perf) with container-aware JVM ergonomics and layered Helm configuration composition to improve deployment portability, operational safety, and maintainability.


Key Changes

Environment-Aware Deployment Profiles

Introduces layered PH-EE deployment profiles:

  • micro

  • std

  • perf

located under:

config/profiles/phee/

These overlays provide environment-specific Kubernetes resource requests/limits while preserving compatibility with existing deployment flows.


Automatic Profile Resolution

Adds automatic profile selection logic based on detected host memory:

Profile | Detected RAM -- | -- micro | < 8GB std | 8GB – 32GB perf | > 32GB

Profile selection remains overrideable and defaults safely when overlays are unavailable.

Implemented in:

src/environmentSetup/helpers.sh

Container-Aware JVM Ergonomics

Replaces hardcoded JVM heap sizing (-Xms/-Xmx) with container-aware JVM ergonomics:

-XX:InitialRAMPercentage=75.0
-XX:MaxRAMPercentage=75.0

This allows JVM heap allocation to scale dynamically according to Kubernetes resource limits instead of relying on static service-specific heap sizing.

Additional JVM cleanup includes:

  • removal of duplicated hardcoded GC configuration

  • removal of duplicated heap sizing fragments

  • preservation of existing service-level overrides where required


Helm Merge Safety Improvements

During implementation, a critical Helm merge issue was identified:

Helm replaces YAML lists rather than deep-merging them.

Injecting JAVA_TOOL_OPTIONS through profile overlays would have overwritten existing deployment.extraEnvs definitions and silently removed critical configuration values (AWS credentials, S3 configuration, service-specific env vars, etc.).

To avoid this:

  • JVM ergonomics are now centralized in base configuration

  • overlays only modify map-based resource structures and scalar overrides

  • existing environment lists remain fully preserved

This significantly reduces deployment risk and improves long-term maintainability.


Files Modified

Added

  • config/profiles/phee/micro.yaml

  • config/profiles/phee/std.yaml

  • config/profiles/phee/perf.yaml

Updated

  • config/ph_values.yaml

  • src/environmentSetup/helpers.sh

  • src/deployer/phee.sh

  • src/commandline/commandline.sh


Validation

Validated:

  • shell syntax (bash -n)

  • profile fallback behavior

  • Helm overlay merge safety

  • backwards compatibility with existing deployment flow

  • JVM/container resource alignment

  • preservation of existing environment variables


Operational Impact

This PR improves:

  • deployment portability across hardware classes

  • JVM behavior under Kubernetes cgroup limits

  • maintainability of PH-EE runtime configuration

  • operational consistency across environments

  • resource safety for constrained deployments

  • deployment ergonomics for future scaling/profiling work


Related

Addresses DMP 2026 JVM optimization work / Issue #103.

- Introduce layered Helm composition for PH-EE (base + profile overlays)
- Implement host-RAM auto-detection (Micro < 8GB, Std 8-32GB, Perf > 32GB)
- Switch to container-aware JVM ergonomics (-XX:MaxRAMPercentage=75.0)
- Leverage JVM internal ergonomics for auto-GC selection based on K8s limits
- Fix Helm list-merging risks by isolating overlays to map-based resources
- Resolve DMP 2026 Issue openMF#103
@RustamSheoran RustamSheoran requested a review from a team May 10, 2026 13:06
@tdaly-mifos
Copy link
Copy Markdown
Contributor

👋 Hi @RustamSheoran — thank you for your pull request.

This PR is currently blocked because we do not have a Contributor License Agreement (CLA) on file for your GitHub account.

To get unblocked:

  1. Complete the form at https://mifos.org/about-us/financial-legal/mifos-contributor-agreement
  2. Complete the CLA signing process
  3. Once verified you will be added to the approved contributors list and this PR check will be cleared

@tdaly-mifos tdaly-mifos added the cla-required CLA signature required before this PR can be merged label May 10, 2026
@tdaly-mifos tdaly-mifos removed the cla-required CLA signature required before this PR can be merged label May 10, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants