配置总览

如果是通过 pairecmd 生成的项目,conf 目录下已经有相应的配置。如果查看 pairec 源码的话,recconf/recconf.go 定义了对应的数据结构。

{
  "RunMode": "product",
  "Region": "cn-beijing",
  "ListenConf": {
    "HttpAddr": "",
    "HttpPort": 8080
  },
  "FilterConfs": [
    {
      "Name": "UserExposureFilter",
      "FilterType": "User2ItemExposureFilter",
      "MaxItems": 8,
      "TimeInterval": 3600,
      "DaoConf": {
        "AdapterType": "hologres",
        "HologresName": "holo-pai",
        "HologresTableName": "t_exposure_history"
      }
    },
    {
      "Name": "AdjustCountFilter",
      "FilterType": "AdjustCountFilter",
      "RetainNum": 400
    }
  ],
  "RecallConfs": [
    {
      "Name": "HomepageEtrecRecall",
      "RecallType": "UserCustomRecall",
      "RecallCount": 1000,
      "DaoConf": {
        "AdapterType": "hologres",
        "HologresName": "holo-pai",
        "HologresTableName": "ydrecom.recom_homepage_etrec_online"
      }
    }
  ],
  "SortNames": {
    "default": [
      "ItemRankScoreSort",
      "MixSort"
    ],
    "homepage": [
      "ItemRankScoreSort",
      "HomepageMixSort"
    ]
  },
  "FilterNames": {
    "default": [
      "UniqueFilter",
      "UserExposureFilter",
      "AdjustCountFilter"
    ],
    "homepage": [
      "UniqueFilter",
      "HomepageUserExposureFilter",
      "HomepageHotUserFilter",
      "HomepageUserStatusFilter",
      "HomepageUserAttentionFilter",
      "HomepagePriorityAdjustCountFilter"
    ]
  },
  "AlgoConfs": [
    {
      "Name": "pai_fm",
      "Type": "EAS",
      "EasConf": {
        "Processor": "ALINK_FM",
        "ResponseFuncName": "alinkFMResponseFunc",
        "Url": "http://1857464601594004.vpc.cn-hangzhou.pai-eas.aliyuncs.com/api/predict/xxxx",
        "Auth": "xxx"
      }
    },
    {
      "Name": "pai_room3_mt_v2",
      "Type": "EAS",
      "EasConf": {
        "Processor": "TensorFlow",
        "ResponseFuncName": "tfMutValResponseFunc",
        "Url": "http://1857464601594004.vpc.cn-hangzhou.pai-eas.aliyuncs.com/api/predict/xxx",
        "Auth": "xxxx"
      }
    },
    {
      "Name": "homepage_fm",
      "Type": "EAS",
      "EasConf": {
        "Processor": "ALINK_FM",
        "ResponseFuncName": "alinkFMResponseFunc",
        "Url": "http://1857464601594004.vpc.cn-hangzhou.pai-eas.aliyuncs.com/api/predict/xxxx",
        "Auth": "xxxx"
      }
    },
    {
      "Name": "pai_homepage_tf",
      "Type": "EAS",
      "EasConf": {
        "Processor": "TensorFlow",
        "ResponseFuncName": "tfMutValResponseFunc",
        "Url": "http://1857464601594004.vpc.cn-hangzhou.pai-eas.aliyuncs.com/api/predict/xxxx",
        "Auth": "xxxx"
      }
    }
  ],
  "HologresConfs": {
    "holo-pai": {
      "DSN": "postgres://ACCESS_ID:ACCESS_KEY@xxxx:80/pai_live?sslmode=disable&connect_timeout=1"
    }
  },
  "KafkaConfs": {
    "kafka": {
      "BootstrapServers": "172.16.228.104:9092,172.16.228.103:9092,172.16.228.102:9092",
      "Topic": "pairec_log"
    }
  },
  "RedisConfs": {
    "redis-cache": {
      "Host": "xxx.redis.rds.aliyuncs.com",
      "Port": 6379,
      "Password": "xxx",
      "ConnectTimeout": 1000,
      "ReadTimeout": 100
    }
  },
  "SceneConfs": {
    "live_feed": {
      "default": {
        "RecallNames": [
          "LiveRoomRecall"
        ]
      }
    },
    "homepage": {
      "default": {
        "RecallNames": [
          "HomepageEtrecRecall",
          "HomepageDssmRecall",
          "HomepageBaseRecall",
          "HomepageLiveBaseRecall"
        ]
      }
    }
  },
  "LogConf": {
    "RetensionDays": 3,
    "DiskSize": 20,
    "LogLevel": "INFO"
  },
  "RankConf": {
    "live_feed": {
      "RankAlgoList": [
        "pai_room3_mt_v2"
      ],
      "RankScore": "${pai_room3_mt_v2_probs_ctr} * (${pai_room3_mt_v2_probs_view} + ${pai_room3_mt_v2_y_view_time} + 0.5 * ${pai_room3_mt_v2_probs_on_wheat} + 0.5 * ${pai_room3_mt_v2_y_on_wheat_time} + 0.25 * ${pai_room3_mt_v2_y_gift} + 0.25 * ${pai_room3_mt_v2_probs_add_friend} + 0.1)"
    },
    "homepage": {
      "RankAlgoList": [
        "homepage_fm"
      ],
      "RankScore": "${homepage_fm}"
    }
  },
  "FeatureConfs": {
    "live_feed": {
      "AsynLoadFeature": true,
      "FeatureLoadConfs": [
        {
          "FeatureDaoConf": {
            "AdapterType": "hologres",
            "HologresName": "holo-pai",
            "FeatureKey": "user:uid",
            "UserFeatureKeyName": "uid",
            "HologresTableName": "recom_user_features_processed_holo_online",
            "UserSelectFields": "rids,rids_count,sex,alladdfriendnum,allpayrosenum,getgiftnum7d,friendnum7d,talknum7d,start_age,end_age,start_height,end_height,lowest_education,lowest_salary,height,wealth,age,living_condition,education,headstatus,marriage,professionid,provinceid,role,salary,socialtag,facevalue",
            "FeatureStore": "user"
          },
          "Features": []
        },
        {
          "FeatureDaoConf": {
            "AdapterType": "hologres",
            "HologresName": "holo-pai",
            "ItemFeatureKeyName": "uid",
            "FeatureKey": "item:pair_id",
            "HologresTableName": "recom_user_features_processed_holo_online",
            "ItemSelectFields": "uid, rids_count as rids2_count,sex as guestsex,alladdfriendnum as alladdfriendnum2,allpayrosenum as allpayrosenum2, getgiftnum7d as getgiftnum7d2,friendnum7d as friendnum7d2,talknum7d as talknum7d2,start_age as start_age2,end_age as end_age2,start_height as start_height2,end_height as end_height2,lowest_education as lowest_education2,lowest_salary as lowest_salary2,height as height2,wealth as wealth2,age as age2,living_condition as living_condition2,education as education2,headstatus as headstatus2,marriage as marriage2,professionid as professionid2,provinceid as provinceid2,role as role2,salary as salary2,socialtag as socialtag2,facevalue as facevalue2",
            "FeatureStore": "item"
          },
          "Features": []
        },
        {
          "FeatureDaoConf": {
            "AdapterType": "hologres",
            "HologresName": "holo-pai",
            "ItemFeatureKeyName": "cupid_id",
            "FeatureKey": "item:matchmaker_id",
            "HologresTableName": "recom_red_features_processed_holo_online",
            "ItemSelectFields": "cupid_id, cupid_id as redid,sex as redsex,role as role1,good_num as good_num1,mid_num as mid_num1,bad_num as bad_num1,total_access as total_access1,duration as duration1,jubaohongniangshu as jubaohongniangshu1,jubaohongniangzongshu as jubaohongniangzongshu1",
            "FeatureStore": "item"
          },
          "Features": []
        }
      ]
    },
    "homepage": {
      "AsynLoadFeature": true,
      "FeatureLoadConfs": [
        {
          "FeatureDaoConf": {
            "AdapterType": "hologres",
            "HologresName": "holo-pai",
            "FeatureKey": "user:uid",
            "UserFeatureKeyName": "uid",
            "HologresTableName": "ydrecom.user_30_7_3d_logcount_features",
            "UserSelectFields": "like_uv_7d as u_like_uv_7d,browse_uv_7d as u_browse_uv_7d,total_talk_pv_7d as u_total_talk_pv_7d,talk_pv_7d as u_talk_pv_7d,talk_rfpv_7d as u_talk_rfpv_7d,talk_uv_7d as u_talk_uv_7d,ef_depth_7d as u_ef_depth_7d,ef_depth_uv_7d as u_ef_depth_uv_7d,click_pv_7d as u_click_pv_7d,action_pv_7d as u_action_pv_7d,ef_depth_avg_7d as u_ef_depth_avg_7d",
            "FeatureStore": "user"
          },
          "Features": []
        },
        {
          "FeatureDaoConf": {
            "AdapterType": "hologres",
            "HologresName": "holo-pai",
            "ItemFeatureKeyName": "uid",
            "FeatureKey": "item:id",
            "HologresTableName": "ydrecom.user_30_7_3d_logcount_features",
            "ItemSelectFields": "uid, like_uv_7d as r_like_uv_7d,browse_uv_7d as r_browse_uv_7d,total_talk_pv_7d as r_total_talk_pv_7d,talk_pv_7d as r_talk_pv_7d,talk_rfpv_7d as r_talk_rfpv_7d,talk_uv_7d as r_talk_uv_7d,ef_depth_7d as r_ef_depth_7d,ef_depth_uv_7d as r_ef_depth_uv_7d,click_pv_7d as r_click_pv_7d,action_pv_7d as r_action_pv_7d,ef_depth_avg_7d as r_ef_depth_avg_7d",
            "FeatureStore": "item"
          },
          "Features": []
        },
        {
          "FeatureDaoConf": {
            "AdapterType": "hologres",
            "HologresName": "holo-pai",
            "ItemFeatureKeyName": "uid",
            "FeatureKey": "item:id",
            "HologresTableName": "ydrecom.members",
            "ItemSelectFields": "uid, sex AS r_sex,age AS r_age,create_at AS r_create_at,province_id AS r_province_id,rose_count AS r_rose_count,city AS r_city,role AS r_role,status AS r_status,head_status AS r_head_status,face_value AS r_face_value,marriage AS r_marriage,education AS r_education,salary AS r_salary,living_condition AS r_living_condition,profession_id AS r_profession_id,height AS r_height,start_age AS r_start_age,end_age AS r_end_age,location_id AS r_location_id,start_height AS r_start_height,end_height AS r_end_height,lowest_education AS r_lowest_education,lowest_salary AS r_lowest_salary,longitude AS r_longitude,latitude AS r_latitude,social_tag AS r_social_tag,active_at AS r_active_at,vip AS r_vip,hometown_id AS r_hometown_id,living_status AS r_living_status",
            "FeatureStore": "item"
          },
          "Features": []
        }
      ]
    }
  }
}
  • RunMode 是运行模式,取值为日常(daily),预发(prepub),正式(product)。

  • ListenConf 主要是 http server 启动相关的。HttpPort 配置监听的端口号