CLIENT_CONFIGURE.md 4.6 KB
Newer Older
W
wangguibao 已提交
1 2
# Client side configuration

W
wangguibao 已提交
3 4 5
Paddle Serving C++ client SDK的配置文件格式用protobuf定义,全部在configure/proto/sdk_configure.proto中。如果要增加配置字段,需要先在该protobuf文件中增加相应字段,才能被Serving SDK读取和解析。

Paddle Serving主配置文件为conf/predictors.prototxt。其中一个示例如下:
W
wangguibao 已提交
6

W
wangguibao 已提交
7
## 1. Sample conf
W
wangguibao 已提交
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69

```shell
default_variant_conf {
  tag: "default"
  connection_conf {
    connect_timeout_ms: 2000
    rpc_timeout_ms: 20000
    connect_retry_count: 2
    max_connection_per_host: 100
    hedge_request_timeout_ms: -1
    hedge_fetch_retry_count: 2
    connection_type: "pooled"
  }
  naming_conf {
    cluster_filter_strategy: "Default"
    load_balance_strategy: "la"
  }
  rpc_parameter {
    compress_type: 0
    package_size: 20
    protocol: "baidu_std"
    max_channel_per_request: 3
  }
}
predictors {
  name: "ximage"
  service_name: "baidu.paddle_serving.predictor.image_classification.ImageClassifyService"
  endpoint_router: "WeightedRandomRender"
  weighted_random_render_conf {
    variant_weight_list: "50|50"
  }
  variants {
    tag: "var1"
    naming_conf {
      cluster: "list://127.0.0.1:8010"
    }
  }
  variants {
    tag: "var2"
    naming_conf {
      cluster: "list://127.0.0.1:8011"
    }
  }
}

predictors {
  name: "echo_service"
  service_name: "baidu.paddle_serving.predictor.echo_service.BuiltinTestEchoService"
  endpoint_router: "WeightedRandomRender"
  weighted_random_render_conf {
    variant_weight_list: "50"
  }
  variants {
    tag: "var1"
    naming_conf {
      cluster: "list://127.0.0.1:8010,127.0.0.1:8011"
    }
  }
}

```

W
wangguibao 已提交
70
## 2. 名词解释
W
wangguibao 已提交
71 72
- 预测服务 (Predictor):对一个Paddle预测服务的封装
- 端点(Endpoit):对一个预测需求的逻辑抽象,通常包含一到多个服务变体,以方便多版本模型管理;
W
wangguibao 已提交
73
- 变体(Variant):一套同质化的Paddle Serving集群服务,每个实例起一个Paddle Serving进程;
W
wangguibao 已提交
74

W
wangguibao 已提交
75
## 3. 配置项解释
W
wangguibao 已提交
76

W
wangguibao 已提交
77
### 3.1 default_variant_conf
W
wangguibao 已提交
78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114

```shell
default_variant_conf {
  tag: "default"
  connection_conf {
    connect_timeout_ms: 2000
    rpc_timeout_ms: 20000
    connect_retry_count: 2
    max_connection_per_host: 100
    hedge_request_timeout_ms: -1
    hedge_fetch_retry_count: 2
    connection_type: "pooled"
  }
  naming_conf {
    cluster_filter_strategy: "Default"  # Not used for now
    load_balance_strategy: "la"
  }
  rpc_parameter {
    compress_type: 0 
    package_size: 20
    protocol: "baidu_std"
    max_channel_per_request: 3
  }
}
```
其中:

connection_type: Maybe single/short/pooled, see [BRPC DOC: connection_type](https://github.com/apache/incubator-brpc/blob/master/docs/cn/client.md#%E8%BF%9E%E6%8E%A5%E6%96%B9%E5%BC%8F)

cluster_filter_strategy: 暂时未用

load_balance_strategy: Maybe rr/wrr/random/la/c_murmurhash/c_md5, see [BRPC DOC: load_balance](https://github.com/apache/incubator-brpc/blob/master/docs/cn/client.md#%E8%B4%9F%E8%BD%BD%E5%9D%87%E8%A1%A1)

compress_type: 0-None, 1-Snappy, 2-gzip, 3-zlib, 4-lz4, see [BRPC DOC: compress_type](https://github.com/apache/incubator-brpc/blob/master/docs/cn/client.md#%E5%8E%8B%E7%BC%A9)

protocol: Maybe baidu_std/http/h2/h2:grpc/thrift/memcache/redis... see [BRPC DOC: protocol](https://github.com/apache/incubator-brpc/blob/master/docs/cn/client.md#%E5%8D%8F%E8%AE%AE) 

W
wangguibao 已提交
115
### 3.2 Predictors
W
wangguibao 已提交
116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164

可以为客户端配置多个predictor,每个predictor代表一个要访问的预测服务

```shell
predictors {
  name: "ximage"
  service_name: "baidu.paddle_serving.predictor.image_classification.ImageClassifyService"
  endpoint_router: "WeightedRandomRender"
  weighted_random_render_conf {
    variant_weight_list: "50|50"
  }
  variants {
    tag: "var1"
    naming_conf {
    cluster: "list://127.0.0.1:8010, 127.0.0.1:8011"
    }
  }
  variants {
    tag: "var2"
    naming_conf {
      cluster: "list://127.0.0.1:8011"
    }
  }
}

predictors {
  name: "echo_service"
  service_name: "baidu.paddle_serving.predictor.echo_service.BuiltinTestEchoService"
  endpoint_router: "WeightedRandomRender"
  weighted_random_render_conf {
    variant_weight_list: "50"
  }
  variants {
    tag: "var1"
    naming_conf {
      cluster: "list://127.0.0.1:8010"
    }
  }
}
```
其中:

service_name: 写sdk-cpp/proto/xx.proto的package name

endpoint_router: 目前只支持WeightedRandomRender

variant_weight_list: 与接下来的variants列表共用,用于表示variants之间相对权重;通过修改此数值可以调整variants调度的比重

cluster: Cluster支持的格式见 [BRPC DOC: naming service](https://github.com/apache/incubator-brpc/blob/master/docs/cn/client.md#%E5%91%BD%E5%90%8D%E6%9C%8D%E5%8A%A1)