Configure hot reloading for the PAI-Rec engine
Flexible configurations are required to make sure that the PAI-Rec engine runs as expected. You used to package and compile the configuration files along with the code to generate an image. Then, you deployed the image on Elastic Algorithm Service (EAS). If you want to update the configurations, you must recompile the configuration files and code to generate a new image and deploy the image. Frequent deployment may affect online services. The hot reloading feature supported by PAI-Rec allows the PAI-Rec engine to dynamically reload the latest configurations without republishing the service.
Prerequisites
-
You are familiar with the configurations of the PAI-Rec engine. For more information, see Engine configuration.
Run the PAI-Rec engine
Run the following command to test the PAI-Rec engine before you deploy the engine on EAS:
PAIREC_ENVIRONMENT=prepub ./pairec-demo --config=conf/config.json.production -alsologtostderr
Run the following command to configure the hot reloading feature:
PAIREC_ENVIRONMENT=daily CONFIG_NAME=pairec_config ABTEST_HOST=http://xxxx/api/predict/pairec_experiment ABTEST_TOKEN=xxx ./pairec-demo --alsologtostderr
You do not need to specify configuration files. You need to only set the following environment variables:
-
PAIREC_ENVIRONMENT: the running environment. Valid values: daily, prepub, and product. The specified environment must be the same as the environment specified in the PAI-Rec engine configurations.
-
CONFIG_NAME: the configuration name, which must be the same as the environment specified in the PAI-Rec engine configurations.
Deploy the PAI-Rec engine on EAS
For more information about how to deploy the engine, see Deploy the PAI-Rec engine. You need to modify the following JSON file based on your configurations:
{
"containers":[
{
"image":"mybigpai-registry-vpc.cn-beijing.cr.aliyuncs.com/mybigpai/pairec_base:1.0.0",
"env":
[
{
"name":"PAIREC_ENVIRONMENT",
"value":"product"
},
{
"name":"CONFIG_NAME",
"value":"pairec_config"
},
{
"name":"ABTEST_HOST",
"value":"xxx"
},
{
"name":"ABTEST_TOKEN",
"value":"xxx"
}
],
"command":"/usr/bin/rec_entrypoint.sh",
"port":8000
}
],
"dockerAuth":"xxxx",
"metadata":{
"cpu":4,
"instance":1,
"memory":8000,
"resource":"xxxx"
},
"name":"pairec_eas_test"
}