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
- 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>
- Configure the parameter that specifies the global default time period for address synchronization. Sample code:
- (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.
- 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.