All Products
Search
Document Center

Enterprise Distributed Application Service:How do I handle slow startup caused by a large number of services registered with or subscribed to by an HSF application?

Last Updated:Jun 13, 2023

Problem description

If a large number of services are registered with or subscribed to by a High-speed Service Framework (HSF) application that is developed by using Pandora Boot, the startup of the application becomes slow.

Causes

An HSF application developed by using Pandora Boot sets the default time period that is used for address synchronization from the service registry (ConfigServer) to each published service (provider) or consumed service (consumer). The default time period is 3,000 milliseconds. If a large number of services are published or consumed, each service needs to wait for address synchronization in sequence. This leads to slow application startup.

Solutions

  1. Open the application.properties file of the application and specify the spring.hsf.max-wait-address-time parameter. Unit: milliseconds.
    • Configure the parameter that specifies the global default time period for address synchronization. Sample code:
      spring.hsf.max-wait-address-time = 500
      全局默认同步时间
    • Configure the parameter that specifies the time period for address synchronization for a single service interface. Sample code:
      spring.hsf.max-wait-address-times.<Complete name of a single service interface>=<Time period for address synchronization>
      设置等待事件
  2. (Optional) Use the addressWaitTime parameter to separately specify the time period for a consumer interface. Unit: milliseconds.
    During service subscription, a thread is blocked within the time period specified by this parameter to wait for address synchronization. This prevents empty address errors when the service is called. This parameter is required for an interface that needs to subscribe to a service when a consumer application is started. We recommend that you set the parameter to a value in the range from 3000 to 5000 milliseconds. Otherwise, the Error code: HSF-0001 error may occur when the consumer application is started. However, if this parameter is specified, the amount of time required by the startup of the application is prolonged.在应用程序中对某个服务消费者接口单独设置等待地址推送时间
  3. Restart the application.
    After you specify the spring.hsf.max-wait-address-time parameter and restart the application, the startup of the application remains slow. In this case, you can analyze the thread stack on the application and the log files in the $USER_HOME/log/configclient/config-client.log and $USER_HOME/log/hsf directories. To analyze the thread stack, run the jstack <Application JVM process ID> >> threaddump.txt command.