Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/python-3.x/19.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 3.x google.cloud.exceptions.ServiceUnavailable:503并优化google数据存储put_multi()速度_Python 3.x_Google App Engine_Google Cloud Datastore - Fatal编程技术网

Python 3.x google.cloud.exceptions.ServiceUnavailable:503并优化google数据存储put_multi()速度

Python 3.x google.cloud.exceptions.ServiceUnavailable:503并优化google数据存储put_multi()速度,python-3.x,google-app-engine,google-cloud-datastore,Python 3.x,Google App Engine,Google Cloud Datastore,我正在尝试使用Python和datastoreemulator将150k+行/实体插入数据存储 def add_rows(self, val_dicts): # val_dicts is a list of dictionaries for updating the entities with self.client.transaction(): entities = [Entity(self.client.key(self.k

我正在尝试使用
Python
datastoreemulator
将150k+行/
实体
插入
数据存储

    def add_rows(self, val_dicts):
        # val_dicts is a list of dictionaries for updating the entities

        with self.client.transaction():

            entities = [Entity(self.client.key(self.kind)) for i in range(len(val_dicts))]

            for entity, update_dict in zip(entities, val_dicts):
                entity.update(update_dict)

            self.client.put_multi(entities)
问题是
put\u multi()
插入
实体花费了大量时间。我想知道如何在
数据存储
中提高插入
实体
的效率

更新。等待
put\u multi()
要完成,出现了一个错误

self.client.put_multi(entities)
../../.local/lib/python3.5/site-packages/google/cloud/datastore/batch.py:293: in __exit__
self.commit()
../../.local/lib/python3.5/site-packages/google/cloud/datastore/transaction.py:220: in commit
super(Transaction, self).commit()
../../.local/lib/python3.5/site-packages/google/cloud/datastore/batch.py:265: in commit
self._commit()
../../.local/lib/python3.5/site-packages/google/cloud/datastore/batch.py:242: in _commit
self.project, self._commit_request, self._id)
../../.local/lib/python3.5/site-packages/google/cloud/datastore/_http.py:627: in commit
response = self._datastore_api.commit(project, request)
../../.local/lib/python3.5/site-packages/google/cloud/datastore/_http.py:356: in commit
return self._stub.Commit(request_pb)
/usr/lib/python3.5/contextlib.py:77: in __exit__
self.gen.throw(type, value, traceback)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

@contextlib.contextmanager
def _grpc_catch_rendezvous():
    """Re-map gRPC exceptions that happen in context.

    .. _code.proto: https://github.com/googleapis/googleapis/blob/\
                    master/google/rpc/code.proto

    Remaps gRPC exceptions to the classes defined in
    :mod:`~google.cloud.exceptions` (according to the description
    in `code.proto`_).
    """
    try:
        yield
    except exceptions.GrpcRendezvous as exc:
        error_code = exc.code()
        error_class = _GRPC_ERROR_MAPPING.get(error_code)
        if error_class is None:
            raise
        else:
>               raise error_class(exc.details())
E               google.cloud.exceptions.ServiceUnavailable: 503 {"created":"@1488386955.558948202","description":"Secure read failed","file":"src/core/lib/security/transport/secure_endpoint.c","file_line":157,"grpc_status":14,"referenced_errors":[{"created":"@1488386955.558925887","description":"EOF","file":"src/core/lib/iomgr/tcp_posix.c","file_line":235}]}

../../.local/lib/python3.5/site-packages/google/cloud/datastore/_http.py:260: ServiceUnavailable

如何解决这个问题呢

您在一次PUT中发送多少实体?你可能达到极限了吗@SaiPullabhotla我将150000个
实体
发送到
put\u multi
。也许您应该尝试以500个或更少的批量发送它们,看看这是否解决了问题(同时检查您可能达到的其他限制,具体取决于实体的大小)。@SaiPullabhotla关于
put\u multi
的大小限制的任何参考资料,这批货绝对值得一试,干杯