Updated on 2024-09-13 GMT+08:00

Managing an E-Commerce Application

This section describes how to connect an e-commerce application to Application Performance Management (APM) for management. Information about the application:

  • This is a Java application that is not deployed using JBoss. It can be deployed on the SUSE 12 SP2 VM in JRE 1.8 or later.
  • The application contains five microservices, each of which contains an instance:
    • apigw: API gateway, which is responsible for service authentication, request throttling, and filtering.
    • product: Product management, including product query and purchase.
    • user: User management, including user login and identity authentication during product purchase.
    • dao: Data persistence layer, which is responsible for database request operations.
    • MySQL database: Database.

The following describes how to connect the e-commerce application to APM for management.

Process

  1. Deploy the application on a Huawei Elastic Cloud Server (ECS). Note that APM supports Huawei ECSs only.
  2. Install the ICAgent. The ICAgent is a collection agent for collecting topology and tracing data in real time. You need to install the ICAgent on the ECS where the application is deployed.
  3. Modify application startup parameters to ensure that APM can monitor the application.
  4. Manage the application on APM, for example, view the application status on the topology page and view user experience on the transaction page.

Procedure

  1. Deploy the application on a Huawei ECS.

    1. Register a cloud account, top up the account, and purchase a Linux ECS. For details, see Logging In to an ECS.

      To ensure application performance, select an ECS with at least 2 vCPU cores and 4 GB memory. Select the image for the SUSE 12 SP2 Operating System (OS), which is the only OS supported by the application.

    2. Log in to the ECS, create an application directory, and go to the directory, for example, mall.
    3. Set up the MySQL database and record the address, port number, username, and password for accessing the database. The demo supports automatic database creation.
    4. Download the application package to the mall directory and install it.
      curl -l http://demos.obs.myhuaweicloud.com/demo_install.sh > demo_install.sh && bash demo_install.sh

      During the installation, replace the database information according to the following procedure:

      1. Download and open the .sh file shown in the command.
      2. Download and open the demo_03.tar file in the .sh file.
      3. Open the .yaml file in the demo_03.tar file and modify the parameters under MySQL:
        • host: address for setting up the database
        • port: port
        • user: username for accessing the database
        • pass: password for accessing the database
      4. Save the settings and go to the next step.

  2. Install the ICAgent. For details, see Initial Installation.
  3. Modify application startup parameters to ensure that the application can be monitored by APM.

    Specifically, add the following parameters to the application startup script:

    Parameter

    Description

    Example

    -javaagent

    JAR package that the collection probe depends on. The value is always /opt/oss/servicemgr/ICAgent/pinpoint/pinpoint-bootstrap.jar.

    /opt/oss/servicemgr/ICAgent/pinpoint/pinpoint-bootstrap.jar

    -Dapm_application

    Application name, which can be customized.

    vmall

    -Dapm_tier

    Application microservice name.

    In this example, microservice names include apigw, product, user, and dao.

    Application startup scripts:

    Before the modification:

    nohup java -Xms512m -Xmx2048m -jar /root/testdemo/ecommerce-persistence-service-0.0.1-SNAPSHOT.jar --spring.config.location=file:/root/testdemo/application_dao.yml > dao.log &
    nohup java -Xms512m -Xmx2048m -jar /root/testdemo/ecommerce-api-gateway-0.0.1-SNAPSHOT.jar --spring.config.location=file:/root/testdemo/application_api.yml > api.log &
    nohup java -Xms512m -Xmx2048m -jar /root/testdemo/ecommerce-user-service-0.0.1-SNAPSHOT.jar --spring.config.location=file:/root/testdemo/application_userservice.yml > user.log &
    nohup java -Xms512m -Xmx2048m -jar /root/testdemo/ecommerce-product-service-0.0.1-SNAPSHOT.jar --spring.config.location=file:/root/testdemo/application_prod.yml > prod.log &
    nohup java -Xms512m -Xmx2048m -jar /root/testdemo/cloud-simple-ui-1.0.0.jar --spring.config.location=file:/root/testdemo/ui.properties > ui.log &

    After the modification (the modified information is shown in bold):

    nohup java -javaagent:/opt/oss/servicemgr/ICAgent/pinpoint/pinpoint-bootstrap.jar -Dapm_application=vmall -Dapm_tier=vmall-dao-service -Xms512m -Xmx2048m -jar /root/testdemo/ecommerce-persistence-service-0.0.1-SNAPSHOT.jar --spring.config.location=file:/root/testdemo/application_dao.yml > dao.log &
    nohup java -javaagent:/opt/oss/servicemgr/ICAgent/pinpoint/pinpoint-bootstrap.jar -Dapm_application=vmall -Dapm_tier=vmall-apigw-service -Xms512m -Xmx2048m -jar /root/testdemo/ecommerce-api-gateway-0.0.1-SNAPSHOT.jar --spring.config.location=file:/root/testdemo/application_api.yml > api.log &
    nohup java -javaagent:/opt/oss/servicemgr/ICAgent/pinpoint/pinpoint-bootstrap.jar -Dapm_application=vmall -Dapm_tier=vmall-user-service -Xms512m -Xmx2048m -jar /root/testdemo/ecommerce-user-service-0.0.1-SNAPSHOT.jar --spring.config.location=file:/root/testdemo/application_userservice.yml > user.log &
    nohup java -javaagent:/opt/oss/servicemgr/ICAgent/pinpoint/pinpoint-bootstrap.jar -Dapm_application=vmall -Dapm_tier=vmall-product-service -Xms512m -Xmx2048m -jar /root/testdemo/ecommerce-product-service-0.0.1-SNAPSHOT.jar --spring.config.location=file:/root/testdemo/application_prod.yml > prod.log &
    nohup java -Xms512m -Xmx2048m -jar /root/testdemo/cloud-simple-ui-1.0.0.jar --spring.config.location=file:/root/testdemo/ui.properties > ui.log &

  4. Restart the application. After about three minutes, application data is displayed on the APM console.

    You can monitor applications and locate application exceptions on the Dashboard and Topology pages of the APM console. For details, see APM User Guide.