There was a problem loading the comments.

WildFly Installation and Tuning

Support Portal  »  Knowledgebase  »  Viewing Article

  Print

Applicable Plans - All Cloud Hosting Plans

WildFly Installation and Tuning

Overview

Note - this is the WildFly installation and tuning guide. Information on how to deploy your WildFly applications is found in the WildFly Application Deployment User Guide.

WildFly is the continuation of the open source JBoss Application Server (JBoss AS) project. The project was renamed by Red Hat in order to differentiate the open source JBoss AS project from the commercial Red Hat JBoss Middleware project. More information about WildFly can be found here - What Is WildFly?

One of the main advantages of WildFly is the Undertow web server. Undertow was built to be fast, lightweight, and scalable to over a million connections. If you are deploying a high performance, single purpose application, Undertow is the best choice. More information about Undertow can be found here - Undertow Web Server.

WildFly is a very complex and powerful application that is intended for advanced users who are deploying enterprise grade applications. Before deploying your applications with WildFly, make sure that you really need all the features that WildFly provides. To make the best use of WildFly you need to be experienced in Java application programming and deployment.

Note! This user guide uses WildFlyX or wildflyX to refer to WildFly versions. Please make sure to substitute your version of WildFly (wildfly8/WildFly 8, wildfly9/WildFly 9, wildfly10/WildFly 10 where applicable).

WildFly Deployment

Installing WildFly
    Installing WildFly using a Control Panel
    Installing WildFly using the command line

Starting and Stopping WildFly
    Using the Control Panel
    Using the Command line

WildFly Administration Console

WildFly Application Deployment

Tuning WildFly
    Set the Java Heap correctly
    How to find the correct Java Heap settings
    Adjusting the Java Heap settings


WildFly Deployment

There are two operating modes for WildFly deployment: as a Standalone server, and as a Managed Domain

  1. Standalone server: a Standalone server is a single instance of WildFly running as an independent process. The eApps default operating mode for WildFly deployment is a Standalone server.

  2. Managed Domain: a Managed Domain is a collection of WildFly server instances managed from a single control point. Managed domains can span multiple physical or virtual servers. This is an advanced configuration. More information about setting up a Managed Domain can be found here - WildFly Managed Domains.

More information about WildFly Operating Modes can be found here - WildFly Operating Modes.

The default deployment approach for WildFly at eApps is to have Apache as the front-end for WildFly and to use either mod_jk or mod_proxy_ajp to pass requests from the Apache web server to WildFly. This allows the Apache web server to serve static content and applications that require Apache (PHP or HTML applications), and the Undertow web server that is built-in to WildFly to serve JSPs and Servlets.

If you do not need to serve PHP or HTML applications and want to maximize the performance of your WildFly server you can turn off and disable the Apache web server. This will allow you to configure the Virtual Server to pass all requests directly to the Undertow web server included with WildFly.

Information on how to deploy your applications is covered in the WildFly Deployment User Guide. This User Guide explains how to deploy your applications with or without Apache, and also covers now to upload and deploy your WAR file from the WildFly Administration Console - User Guide: Application Deployment with WildFly operating in Standalone Mode


Installing WildFly

Pay careful attention to the resources allocated to the Virtual Server that will be used for WildFly deployment, especially the available RAM. WildFly can be very memory intensive, and a lack of resources is one of the main reasons for poor performance.

For a small WildFly application, start with at least 1024 MB of RAM, and be prepared to scale upwards as necessary. For larger WildFly applications, start with at least 2048 MB of RAM, and again be ready to scale upwards if your traffic and resource needs demand it.

There are two choices for installing WildFly:

  1. The default method is to use one of the CentOS WildFly X (ISPmanager CP) templates when you create your Virtual Server, which installs the most current version of WildFly 9 or WildFly 10 that is available at eApps, Java SE 8, and mod_jk. You can create a Virtual Server using the WildFly template by going to the Create-A-Cloud® store and selecting the appropriate template and resources.

  2. You can also create your Virtual Server with one of the CentOS templates, and install WildFly and related applications individually. To run Java applications using WildFly, you will need to install WildFly and Java SE 8. Install Java SE 8 first. If you are going to use the mod_jk deployment method you will need to install mod_jk. If you are going to use the mod_proxy_ajp deployment method, no additional applications will need to be installed. mod_proxy_ajp is an Apache module, and is available with Apache.

For either installation choice, you will need to install either MySQL database server and MySQL JDBC Driver, MariaDB database server and MySQL JDBC Driver, or the PostreSQL database server and PostgreSQL JDBC Driver. Which database you choose will depend on your existing codebase and preferences, and also which template you are using. MariaDB is only available on CentOS 7 templates, MySQL and PostgreSQL can be installed on CentOS 6 or CentOS 7. See the user guides for each database for more information - Database User Guides.

Installing WildFly using a Control Panel

Installing applications using the ISPmanager Control Panel

If you are using the ISPmanager Control Panel, you can install WildFly and related applications from there.

NOTE - if your codebase requires Java SE 7, you can only install WildFly 8 or WildFly 9. WildFly 10 is not compatible with Java SE 7. Java SE 7 can be installed from the ISPmanager Control Panel.

  • For ISPmanager 4, go to Server Settings > Applications. Make sure to install Java SE 8 first, then install WildFly and any other related applications. More information on installing applications can be found here - Installing Server Applications

  • For ISPmanager 5, go to Settings > Features. Make sure to install Java SE 8 first, then install WildFly and any other related applications. More information on installing applications can be found here - Installing Features (Server Applications)

Information on how to tell which version of ISPmanager you are using can be found here - ISPmanager versions

Installing WildFly using the command line

You can install WildFly and related applications from the command line of the Virtual Server. You will need to install Java SE 8 and several Java plugins first, and then install WildFly. All of this is done using yum.

To install Java SE 8 and the related applications, use the yum install -y java-1.8.0-oracle java-1.8.0-oracle-plugin java-1.8.0-oracle-jdbc java-1.8.0-oracle-src java-1.8.0-oracle-devel java-1.8.0-oracle-javafx command.

[root@eapps-example ~]# yum install -y java-1.8.0-oracle java-1.8.0-oracle-plugin java-1.8.0-oracle-jdbc java-1.8.0-oracle-src java-1.8.0-oracle-devel java-1.8.0-oracle-javafx

To install WildFly, use the yum install -y wildflyX command. Remember to substitute your version of WildFly for "wildflyX".

[root@eapps-example ~]# yum install -y wildflyX

If you are going to use the mod_jk approach for WildFly, you will need to install mod_jk using the yum install -y mod_jk command.

[root@eapps-example ~]# yum install -y mod_jk

If you are going to install your database from the command line, please see the specific user guide for that database:

  • Instructions for installing and configuring MySQL and phpMyAdmin from the command line are in the MySQL User Guide.

  • Instructions for installing and configuring MariaDB and phpMyAdmin from the command line are in the MariaDB User Guide

  • Instruction for installing and configuring PostgreSQL and phpPgAdmin from the command line are in the PostgreSQL User Guide

 

If you are going to use the Standalone deployment with Apache and mod_jk or mod_proxy_ajp, you will also need to create a website in Apache.


Starting and Stopping WildFly

WildFly can be stopped, started or restarted from either the Control Panel or the command line of the server.

Using the Control Panel

Using the ISPmanager Control Panel

The way to start, stop, and restart WildFly from ISPmanager will depend on which version of ISPmanager you are using.

  • For ISPmanager 4, go to Management Tools > Services, and highlight the wildflyX service. Then click on Stop, Start, or Restart in the upper right corner. More information about managing service in ISPmanager 4 is available here - Managing Services

  • For ISPmanager 5, go to System > Services, and highlight the wildflyX service. Then click on Start, Stop, or Restart in the upper left corner. More information about managing services in ISPmanager 5 is available here - Managing Services

Using the Command line

This can be done by connecting to the command line of your VS using SSH. You will need to be the root user to run these commands.

Starting WildFly

  • For CentOS 6, use the service wildflyX start command:

    [root@eapps-example ]# service wildflyX start

  • For CentOS 7, use the systemctl start wildflyX command:

    [root@eapps-example ~]# systemctl start wildflyX



Stopping WildFly

  • For CentOS 6, use the service wildflyX stop command:

    [root@eapps-example ]# service wildflyX stop

  • For CentOS 7, use the systemctl stop wildflyX command:

    [root@eapps-example ~]# systemctl stop wildflyX

 

Restarting WildFly

  • For CentOS 6, use the service wildflyX restart command:

    [root@eapps-example ]# service wildflyX restart

  • For CentOS 7, use the systemctl restart wildflyX command:

    [root@eapps-example ~]# systemctl restart wildflyX

 

WildFly Status

  • For CentOS 6, use the service wildflyX status command:

    [root@eapps-example ]# service wildflyX status

  • For CentOS 7, use the systemctl status wildflyX command:

    [root@eapps-example ~]# systemctl status wildflyX


WildFly Administration Console

In WildFly, the jmx-console and the web-console have been replaced with the WildFly Administration Console. The Administration Console is the root context for the default WildFly installation, and is available at http://eapps-example.com:8080 (substitute your own domain name or IP address for eapps-example.com).

This takes you to the Welcome to WildFly page.

WildFly 8 Welcome Page

 

To access the Administration Console, click on the Administration Console link. You can also access the Administration Console directly by going to http://eapps-example.com:9990 (substitute your own domain name or IP address for eapps-example.com).

To log in to the Administration Console, you will need to use the admin user and password. The admin user password is found in the /opt/wildflyX/.mgmtsecret file - note that the file is a dot file. This password is randomly generated for each WildFly installation.

Once you have the password, you can log in to the Administration console.

WildFly Admin Console - Home

More information on how to use the WildFly Administration Console to deploy your application can be found in the User Guide for deployment - WildFly User Guide: Deployment in Standalone Mode


WildFly Application Deployment

With WildFly you can deploy your applications with the Apache web server being used to serve PHP or HTML based content while the Undertow web server serves all JSPs and Servelets. If you are not using any HTML or PHP content, you can turn off the Apache Web Server and have the built-in Undertow web server serve all JSP and Servelet content.

Information on how to deploy your applications is covered in the WildFly Deployment User Guide - User Guide: Application Deployment with WildFly


Tuning WildFly

Set the Java Heap correctly

Java Heap Settings - an overview

Warning! The most common issue with WildFly, by far, is a lack of available resources. In many cases, this is due to the Java Heap size either not being configured at all, or not being configured correctly. In other cases, the plan is simply too small for the type of application being run on it. For example, while it is possible to run WildFly with only 768 MB of RAM, that plan does not have the resources for a true enterprise application or a site that receives a high volume of traffic.

One of the most important parts of tuning WildFly for better performance is to optimize the Java Heap settings. The Java Heap size is the amount of memory allocated to the Java Virtual Machine (JVM). The heap is where Java objects live, and there must be enough memory allocated to the JVM to support the needs of the deployed WildFly applications.

How to find the correct Java Heap settings

By default WildFly is configured to have an Initial Java Heap Size of 512 MB, and a Maximum Java Heap Size of 512 MB. Depending on your application and configuration, you may need to adjust this value in order to correctly optimize WildFly.

To find the correct heap size, you will have to stop WildFly, and use the Linux free -m command to see the available memory, and then multiply that value by two, and then subtract that result from the total RAM available for your plan. This number will be roughly what you need to set for the maximum heap size.

The following must be done from the command line of the VS, with the WildFly service stopped. See the SSH user guide for more information if needed.

[root@eapps-example ]# free -m
             total       used       free     shared    buffers     cached
Mem:          4096       1840       2255          0         32        777
-/+ buffers/cache:       1030       3065
Swap:         1027          0       1027
[root@example ~]#

In this example, with WildFly stopped, the operating system and all other applications and services running consume 1030 MB of RAM.

Multiply this value by two giving a total of 2060, and subtract that from the total available RAM for a value of 2036 MB for the maximum heap.

Remember, this is just a rough estimate. You may find that you need to adjust this number up or down as necessary, depending on how your application is configured and what other services your system is running.

Generally, the maximum heap size should be just under half the amount of memory available. You can of course adjust this value higher or lower, but you may have to experiment to determine the true optimum heap size

If your JVM runs out of heap space, the message java.lang.OutOfMemoryError may appear in the /var/log/wildflyX/standalone file. This message lets you know that you need to either adjust your heap settings, consider upgrading your plan, or optimize your application to use less memory and resources.

You can also use the same free -m command as shown above, but with WildFly still running. This will show you if you are hitting memory limits in your plan. If your free memory drops below 100 MB, that is a sign that you may be pushing the resource limits in your plan. If this is the case, you should monitor the memory usage for several days to see if that number is consistent, or was just an anomaly due to peak load condition.

Adjusting the Java Heap settings

To set the Java Heap for WildFly you must modify the wrapper.java.initmemory and the wrapper.java.maxmemory settings in your /etc/wildflyX/wildfly.conf file. It is best to set the init parameter lower than the maximum parameter to ensure that Java does not initialize more memory than is actually needed. This will optimize memory for non-Java processes.

The following must be done from the command line of the VS as the root user. See the SSH User Guide for more information if needed.

[root@eapps-example ]# cd /etc/wildflyX
[root@eapps-example ]# vim wildfly.conf

Using a text editor (in this example the vim editor), edit the wildfly.conf file and change the settings below to your desired heap size values.

The default values for the Java Heap Size are 512 MB for Initial and 512 MB for Maximum. This is the same no matter which offering you have. You will generally need to adjust the wrapper.java.maxmemory upwards, and leave the wrapper.java.initmemory as is.

# Initial Java Heap Size (in MB)
wrapper.java.initmemory=512

# Maximum Java Heap Size (in MB)
wrapper.java.maxmemory=512

Make whatever changes are needed, and then save and exit the wildfly.conf file. You will need to restart WildFly for the new Heap settings to take effect.



Share via
Did you find this article useful?  

Related Articles


Comments

Please login to post a comment.

Order By: 
Hernan  
Great article.

Question, is there a maximum for the Xmx parameter for initializing Wildfly?

Thanks.
  0

On-Premise Help Desk Software by SupportPal

Categories

© Cloudscale365