13 Replies Latest reply: Feb 8, 2013 11:25 AM by Babul Reddy RSS

    Specifying Heap Size & JVM Memory for JBoss Instance / Node !!

    saswata mandal Newbie

      Dear all,

       

            In the current scenario , we have multiple jboss server instances running in the same cluster.

       

      The run.bat file in the bin directory under the JBoss Server installation location contains the following :-

       

      rem JVM memory allocation pool parameters. Modify as appropriate.
      set JAVA_OPTS=%JAVA_OPTS% -Xms128m -Xmx512m

       

      So , this setting has been done at the server level , which means , all the server instances of this server will have the same JVM memory allocation.

       

      But , we want to set the Heap Size and JVM Memory Allocation at the Server Instance / Node level , so that different server instances / nodes can be started with their own Heap Size and JVM Memory Allocation settings.

       

      This may be specified , at runtime while starting the server instance using the -D option ( dont know how to do for the Heap Size and JVM Memory Allocation )OR , in any config file in the specific node's server configuration directory.

       

       

      Kindly , suggest , how to achieve this requirement.

       

       

      Thanks & Regards

      Saswata Mandal.

        • 1. Re: Specifying Heap Size & JVM Memory for JBoss Instance / Node !!
          saswata mandal Newbie

          Hi Experts ,

           

               any suggestions !!!

           

           

          Cheers

          saswata

          • 2. Re: Specifying Heap Size & JVM Memory for JBoss Instance / Node !!
            Peter Johnson Master

            Why not make copies of run.bat, one for each instance, and set the heap sizes in those copies?

            • 3. Re: Specifying Heap Size & JVM Memory for JBoss Instance / Node !!
              saswata mandal Newbie

              The run.bat file in the C:\jboss-4.2.0.GA\bin contains :-

               

              @echo off
              rem -------------------------------------------------------------------------
              rem JBoss Bootstrap Script for Win32
              rem -------------------------------------------------------------------------

              rem $Id: run.bat 60996 2007-02-28 13:44:01Z dimitris@jboss.org $

              @if not "%ECHO%" == ""  echo %ECHO%
              @if "%OS%" == "Windows_NT"  setlocal

              set DIRNAME=.\
              if "%OS%" == "Windows_NT" set DIRNAME=%~dp0%
              set PROGNAME=run.bat
              if "%OS%" == "Windows_NT" set PROGNAME=%~nx0%

              pushd %DIRNAME%..
              set JBOSS_HOME=%CD%
              popd

              REM Add bin/native to the PATH if present
              if exist "%JBOSS_HOME%\bin\native" set PATH=%JBOSS_HOME%\bin\native;%PATH%
              if exist "%JBOSS_HOME%\bin\native" set JAVA_OPTS=%JAVA_OPTS% -Djava.library.path=%JBOSS_HOME%\bin\native

              rem Read all command line arguments

              REM
              REM The %ARGS% env variable commented out in favor of using %* to include
              REM all args in java command line. See bug #840239. [jpl]
              REM
              REM set ARGS=
              REM :loop
              REM if [%1] == [] goto endloop
              REM         set ARGS=%ARGS% %1
              REM         shift
              REM         goto loop
              REM :endloop

              rem Find run.jar, or we can't continue

              set RUNJAR=%JBOSS_HOME%\bin\run.jar
              if exist "%RUNJAR%" goto FOUND_RUN_JAR
              echo Could not locate %RUNJAR%. Please check that you are in the
              echo bin directory when running this script.
              goto END

              :FOUND_RUN_JAR

              if not "%JAVA_HOME%" == "" goto ADD_TOOLS

              set JAVA=java

              echo JAVA_HOME is not set.  Unexpected results may occur.
              echo Set JAVA_HOME to the directory of your local JDK to avoid this message.
              goto SKIP_TOOLS

              :ADD_TOOLS

              set JAVA=%JAVA_HOME%\bin\java

              rem A full JDK with toos.jar is not required anymore since jboss web packages
              rem the eclipse jdt compiler and javassist has its own internal compiler.
              if not exist "%JAVA_HOME%\lib\tools.jar" goto SKIP_TOOLS

              rem If exists, point to the JDK javac compiler in case the user wants to
              rem later override the eclipse jdt compiler for compiling JSP pages.
              set JAVAC_JAR=%JAVA_HOME%\lib\tools.jar

              :SKIP_TOOLS

              rem If JBOSS_CLASSPATH or JAVAC_JAR is empty, don't include it, as this will
              rem result in including the local directory in the classpath, which makes
              rem error tracking harder.
              if not "%JAVAC_JAR%" == "" set RUNJAR=%JAVAC_JAR%;%RUNJAR%
              if "%JBOSS_CLASSPATH%" == "" set RUN_CLASSPATH=%RUNJAR%
              if "%RUN_CLASSPATH%" == "" set RUN_CLASSPATH=%JBOSS_CLASSPATH%;%RUNJAR%

              set JBOSS_CLASSPATH=%RUN_CLASSPATH%

              rem Setup JBoss specific properties
              set JAVA_OPTS=%JAVA_OPTS% -Dprogram.name=%PROGNAME%

              rem Add -server to the JVM options, if supported
              "%JAVA%" -version 2>&1 | findstr /I hotspot > nul
              if not errorlevel == 1 (set JAVA_OPTS=%JAVA_OPTS% -server)

              rem JVM memory allocation pool parameters. Modify as appropriate.
              set JAVA_OPTS=%JAVA_OPTS% -Xms128m -Xmx512m

              rem With Sun JVMs reduce the RMI GCs to once per hour
              set JAVA_OPTS=%JAVA_OPTS% -Dsun.rmi.dgc.client.gcInterval=3600000 -Dsun.rmi.dgc.server.gcInterval=3600000

              rem JPDA options. Uncomment and modify as appropriate to enable remote debugging.
              rem set JAVA_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,address=8787,server=y,suspend=y %JAVA_OPTS%

              rem Setup the java endorsed dirs
              set JBOSS_ENDORSED_DIRS=%JBOSS_HOME%\lib\endorsed

              echo ===============================================================================
              echo.
              echo   JBoss Bootstrap Environment
              echo.
              echo   JBOSS_HOME: %JBOSS_HOME%
              echo.
              echo   JAVA: %JAVA%
              echo.
              echo   JAVA_OPTS: %JAVA_OPTS%
              echo.
              echo   CLASSPATH: %JBOSS_CLASSPATH%
              echo.
              echo ===============================================================================
              echo.

              :RESTART
              "%JAVA%" %JAVA_OPTS% "-Djava.endorsed.dirs=%JBOSS_ENDORSED_DIRS%" -classpath "%JBOSS_CLASSPATH%" org.jboss.Main %*
              if ERRORLEVEL 10 goto RESTART

              :END
              if "%NOPAUSE%" == "" pause

              :END_NO_PAUSE

               

               

              So, If i change the HEAP SETTINGS of the file for node 1, save it to the bin directory by the name runnode1.bat , and in the command prompt type :-

               

              runnode1 - c node1 -b IP ADDRESS -g CLUSTER NAME

               

              , will that solve my requirement ??

               

              Is that a GOOD IDEA to do that ??

               

              Because I thought , there must be some way to pass the HEAP VALUES at runtime by the run -D option for the nodes !!!

               

              OR , to specify the HEAP VALUES in a configuration file for the specific nodes !!

               

              Thanks & Regards

              Saswata Mandal.

              • 4. Re: Specifying Heap Size & JVM Memory for JBoss Instance / Node !!
                Peter Johnson Master

                Please don't use bold text, it looks as if you are shouting.

                 

                You cannot set the heap sizes using -D options.

                 

                Your plane on creating runnode1.bat and editing the heap settings in there is a good one. I would go even further and hard-code the "- c node1 -b IP ADDRESS -g CLUSTER NAME" within runnode1.bat - you could add it to this line:

                 

                "%JAVA%" %JAVA_OPTS% "-Djava.endorsed.dirs=%JBOSS_ENDORSED_DIRS%"  -classpath "%JBOSS_CLASSPATH%" org.jboss.Main - c node1 -b IP ADDRESS -g CLUSTER NAME %*

                • 5. Re: Specifying Heap Size & JVM Memory for JBoss Instance / Node !!
                  saswata mandal Newbie

                  Isn't there any way to pass the HEAP VALUES at runtime by the run -D option while starting server instances ??

                   

                  cheers

                  saswata mandal

                  • 6. Re: Specifying Heap Size & JVM Memory for JBoss Instance / Node !!
                    saswata mandal Newbie

                    Hi,

                     

                    Can we create our own properties and use the C:\jboss-4.2.0.GA\server\node1\deploy\properties-service.xml  file utilize them ??

                     

                    Cheers

                    saswata

                    • 7. Re: Specifying Heap Size & JVM Memory for JBoss Instance / Node !!
                      Peter Johnson Master

                      I asked you to not use bold text, so now you are using bold and blue. Does that mean you are yelling at me? I usually do not respond when I get yelled at.

                       

                      Go and read the JVM documentation regarding the use of the -D option (since you did not believe my original aswer to your question).

                      • 8. Re: Specifying Heap Size & JVM Memory for JBoss Instance / Node !!
                        saswata mandal Newbie

                        OK SORRY , I GOT YOUR MESSAGE LATELY .

                         

                        WHY SHOULD I SHOUT , WE ARE HERE TO HELP EACH OTHER.

                         

                         

                        CHEERS

                        SASWATA

                        • 9. Re: Specifying Heap Size & JVM Memory for JBoss Instance / Node !!
                          saswata mandal Newbie

                          Hi Peter,

                           

                               You actually read my mind .

                           

                          I was about to ask you , how can we include the :- run -c node1 -b ipaddr -g clustername , in the runnode1.bat.

                           

                          Your suggestions are really helpful , I shall implement them as you have suggested and shall get back to you soon.

                           

                           

                          Thanks & Regards

                          saswata mandal.

                          • 10. Re: Specifying Heap Size & JVM Memory for JBoss Instance / Node !!
                            Praveen Kumar Newbie

                            Hi Mandal,

                             

                               Do like this,create two jboss instance say,

                             

                            /opt/jboss1 and /opt/jboss2 so that your node1 in jboss1 and node2 in jboss2.Finally makeJVM settings in their respective run.bat.

                             

                             

                            No need to use bold or colored letter .

                             

                             

                            Enjoy..

                            Praveen

                            • 11. Re: Specifying Heap Size & JVM Memory for JBoss Instance / Node !!
                              saswata mandal Newbie

                              I liked , Peter's idea of copying the run.bat file in the bin directory , renaming them for different nodes , and modified jvm settings for the specific nodes.

                               

                              That way , we shall have multiple nodes with different jvm settings in the same JBOSS Server.

                               

                              I am going to implement it today , and shall update the post.

                               

                               

                              Thanks & Regards

                              saswata mandal. 

                              • 12. Re: Specifying Heap Size & JVM Memory for JBoss Instance / Node !!
                                saswata mandal Newbie

                                Hi Peter,

                                 

                                    Your suggestion, has worked fine .

                                 

                                I am able to run the nodes with different JVM configurations.

                                 

                                 

                                Thanks & Regards

                                saswata mandal.

                                • 13. Re: Specifying Heap Size & JVM Memory for JBoss Instance / Node !!
                                  Babul Reddy Newbie

                                  Hi  All,

                                   

                                   

                                  I have a doubt on  Jboss memory allotment

                                  I have  5 cluster nodes in JBOSS1 

                                  I want to give  5 different memory settings for all nodes

                                  Cluster1 -  2048

                                  Cluster2 - 1024

                                  Cluster3 -  3.5 GB

                                  Cluster4  - 4GB

                                   

                                  Please can I know how can we set the memory setting for each  cluster node.

                                   

                                  Thanks

                                  Babul