Setting Up Clustering for the Liferay Service

Because Delectable Bonsai’s website draws millions of views, it must be clustered to handle the traffic. Here, you’ll learn how to configure a two-node cluster of the production environment.

important

You must have an extra Liferay DXP instance provisioned as an add-on for your Liferay Cloud project so that you can cluster your Liferay service and add another node to it. Contact your Liferay account manager for details.

Set the Clustering Properties in LCP.json

Enable clustering and set the scale value in your Liferay service’s configuration.

  1. In your project repository, navigate to the liferay/ directory and open the LCP.json file.

  2. Add the LCP_PROJECT_LIFERAY_CLUSTER_ENABLED environment variable if it is not present. Set the value to true.

     {
         "env": {
             "LCP_PROJECT_LIFERAY_CLUSTER_ENABLED": "true"
         }
     }
    
  3. Add the scale property with a value of 1. This sets the number of nodes, which you’ll update later.

     {
         "kind": "Deployment",
         "id": "liferay",
         "scale": 1
     }
    
  4. Run the Gradle task to create the custom Dockerfile for your Liferay service.

    ./gradlew clean createDockerfile deploy
    
  5. Copy the LCP.json file into the newly created build/docker folder before deploying the build.

    cp LCP.json build/docker
    
    cd build/docker
    
  6. Use the CLI tool’s lcp deploy command to deploy only the Liferay service.

    lcp deploy --project=[project-name] --environment=prd
    

The Liferay service restarts with clustering enabled and the scale variable initialized. However, the scale is still set to one node only. Continue to update the scale to the desired two nodes.

Update the Clustering Scale

Now that you have initialized the clustering scale, update it to two nodes and create a new build to deploy it.

  1. In your project repository, navigate to the liferay/ folder and open the LCP.json file.

  2. Update the value of the scale property to 2.

     {
         "kind": "Deployment",
         "id": "liferay",
         "scale": 2
     }
    
  3. Commit and push the changes to your Git repository.

    git add liferay/LCP.json
    
    git commit -m "Enable clustering and set the clustering scale to 2."
    
    git push origin [branch_name]
    

The updated clustering configuration is now committed, and the Liferay Cloud infrastructure automatically creates a build with it.

Deploy the Configuration

Now that you have the necessary configuration for clustering, deploy the configuration to your environment.

  1. Log into the Liferay Cloud console.

  2. Click Builds at the top-right of the screen to access the Builds page.

  3. Click the Actions menu Actions menu icon for the build corresponding to the commit with your new changes, and select Deploy build to…

    Select the build to deploy with your commit message from the Builds page.

  4. Select your production environment in the Environment drop-down menu.

  5. Check the boxes acknowledging the impacts of the deployment.

    Choose the production environment and complete the form to deploy the build.

  6. Click Deploy Build.

Once your services restart, clustering is enabled, and you have two nodes of the Liferay service.

Next: configure the Liferay service to auto-scale for even more instances when they are needed.

Ask

Capabilities

Product

DXP

Contact Us

Connect

Powered by Liferay
© 2024 Liferay Inc. All Rights Reserved • Privacy Policy