提交 9f44d825 编写于 作者: B barrierye

add name resolver config and deflaut load balancing config

上级 f6d93151
......@@ -401,12 +401,10 @@ class MultiLangClient(object):
def connect(self, endpoints):
# https://github.com/tensorflow/serving/issues/1382
options = [('grpc.max_receive_message_length', 512 * 1024 * 1024),
('grpc.max_send_message_length', 512 * 1024 * 1024)]
('grpc.max_send_message_length', 512 * 1024 * 1024),
('grpc.lb_policy_name', 'round_robin')]
# TODO
if len(endpoints) > 1:
print("Warn: grpc can only set a endpoint")
g_endpoint = endpoints[0]
g_endpoint = 'ipv4:{}'.format(','.join(endpoints))
self.channel_ = grpc.insecure_channel(g_endpoint, options=options)
self.stub_ = multi_lang_general_model_service_pb2_grpc.MultiLangGeneralModelServiceStub(
self.channel_)
......
......@@ -440,13 +440,12 @@ class Server(object):
os.system(command)
class MultiLangServerService(multi_lang_general_model_service_pb2_grpc.
MultiLangGeneralModelServiceServier):
def __init__(self, model_config_path, endpoints, rpc_timeout_ms):
class MultiLangServerService(
multi_lang_general_model_service_pb2_grpc.MultiLangGeneralModelService):
def __init__(self, model_config_path, endpoints):
from paddle_serving_client import Client
self._parse_model_config(model_config_path)
self.bclient_ = Client()
self.bclient_.set_rpc_timeout_ms(rpc_timeout_ms)
self.bclient_.load_client_config(
"{}/serving_server_conf.prototxt".format(model_config_path))
self.bclient_.connect(endpoints)
......@@ -538,6 +537,7 @@ class MultiLangServerService(multi_lang_general_model_service_pb2_grpc.
return resp
def inference(self, request, context):
print("get inference")
feed_dict, fetch_names, is_python = self._unpack_request(request)
data, tag = self.bclient_.predict(
feed=feed_dict, fetch=fetch_names, need_variant_tag=True)
......@@ -548,12 +548,8 @@ class MultiLangServer(object):
def __init__(self):
self.bserver_ = Server()
self.worker_num_ = 4
self.body_size_ = 512 * 1024 * 1024
self.concurrency_ = 100
self.rpc_timeout_ms_ = 20000
def set_rpc_timeout_ms(self, rpc_timeout_ms):
self.rpc_timeout_ms_ = rpc_timeout_ms
self.body_size_ = 64 * 1024 * 1024
self.concurrency_ = 100000
def set_max_concurrency(self, concurrency):
self.concurrency_ = concurrency
......@@ -636,8 +632,8 @@ class MultiLangServer(object):
maximum_concurrent_rpcs=self.concurrency_)
multi_lang_general_model_service_pb2_grpc.add_MultiLangGeneralModelServiceServicer_to_server(
MultiLangServerService(self.model_config_path_,
["0.0.0.0:{}".format(self.port_list_[0])],
self.rpc_timeout_ms_), server)
["0.0.0.0:{}".format(self.port_list_[0])]),
server)
server.add_insecure_port('[::]:{}'.format(self.gport_))
server.start()
p_bserver.join()
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册