Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ZOOKEEPER-4797: Allow for -XX:MaxRAMPercentage JVM setting #2122

Closed
wants to merge 1 commit into from

Conversation

frederiko
Copy link
Contributor

When running Zk in a containerized environment, it's sometimes desirable to express your heap size in terms of percentage of available memory allocated to a container.

As it stands, zkEnv.sh forces your to have -Xmx set to a value, otherwise it defaults to 1GB. Some environments wanted to set it to more, mostly related to the amount of Ram, not to an absolute value.

This is a request to implement the option of using -XX:MaxRamPercentage option when starting zookeeper.

Suggested implementation is to also make a variable ZK_SERVER_MAXRAMPERCENTAGE available to be appended to SERVER_JVMFLAGS. If the variable is set, ZK_HEAP_SERVER is ignored, if no ZK_SERVER_MAXRAMPERCENTAGE, ZK_SERVER_HEAP is set as usual.

Example output:

Without any heap size set.

./bin/zkServer.sh print-cmd
/usr/bin/java
ZooKeeper JMX enabled by default
Using config: /home/fsc/src/zookeeper/bin/../conf/zoo.cfg
"java"  ....  **-Xmx1000m**   -Dcom.sun.management.jmxremote -Dcom.sun.management.jmxremote.local.only=false org.apache.zookeeper.server.quorum.QuorumPeerMain "/home/fsc/src/zookeeper/bin/../conf/zoo.cfg" > "/home/fsc/src/zookeeper/bin/../logs/zookeeper-fsc-server-lap.out" 2>&1 < /dev/null

With ZK_SERVER_HEAP set to 2000

$ ZK_SERVER_HEAP=2000 ./bin/zkServer.sh print-cmd
/usr/bin/java
ZooKeeper JMX enabled by default
Using config: /home/fsc/src/zookeeper/bin/../conf/zoo.cfg
"java"  ...  **-Xmx2000m**   -Dcom.sun.management.jmxremote -Dcom.sun.management.jmxremote.local.only=false org.apache.zookeeper.server.quorum.QuorumPeerMain "/home/fsc/src/zookeeper/bin/../conf/zoo.cfg" > "/home/fsc/src/zookeeper/bin/../logs/zookeeper-fsc-server-lap.out" 2>&1 < /dev/null

When ZK_SERVER_MAXRAMPERCENTAGE is added (with or without ZK_SERVER_HEAP)

$ ZK_SERVER_MAXRAMPERCENTAGE=30.0 ZK_SERVER_HEAP=2000 ./bin/zkServer.sh print-cmd (ZK_SERVER_HEAP is ignored)
/usr/bin/java
ZooKeeper JMX enabled by default
Using config: /home/fsc/src/zookeeper/bin/../conf/zoo.cfg
"java" ... **-XX:MaxRAMPercentage=30.0**   -Dcom.sun.management.jmxremote -Dcom.sun.management.jmxremote.local.only=false org.apache.zookeeper.server.quorum.QuorumPeerMain "/home/fsc/src/zookeeper/bin/../conf/zoo.cfg" > "/home/fsc/src/zookeeper/bin/../logs/zookeeper-fsc-server-lap.out" 2>&1 < /dev/null

Copy link
Member

@ctubbsii ctubbsii left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Duplicate of #2121 ; 3.5 is EOL; this should be closed

@frederiko
Copy link
Contributor Author

Yes. The idea was to backport to a legacy version I run. In any case, I will keep the one to master. If approved, will backport to supported versions.

@frederiko frederiko closed this Jan 30, 2024
@frederiko frederiko deleted the ZOOKEEPER_4797_3.5 branch January 30, 2024 13:47
@mortaelth
Copy link

I can see that this never made it to master. Is there still a plan to make it?

@frederiko
Copy link
Contributor Author

I can see that this never made it to master. Is there still a plan to make it?

Not for 3.5, but I suppose #2120 will.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants