Appengine deployments are extraodinarily slow today?

▼魔方 西西 提交于 2019-12-06 10:37:48

Set the environment variable CLOUDSDK_APP_USE_GSUTIL=1 and try again; this uses a less-reliable but faster codepath for file upload (there are plans to speed up the default codepath).

We have the same issue, it's very slow. Guess we have solved it.

First, we traced the gcloud logs and we found many files had been uploaded again, these files all are no modified. So we try to trace the source code of gcloud and we found the issue is caused by "Google Cloud Storage JSON API".

When it queried the List of Bucket, it returned 1000 items but we have 1325 items so I guess we find the issue.

Then, we look for the api reference, and we find a parameter - maxResults, so we try to modify the source code(cloud_storage.py), and we find it has No Effect when its value is over 1000.

Finally, we find another parameter - nextPageToken, and we query list until the "nextPageToken" is None, now it got all items from "Google Cloud Storage" and the exists files not be uploaded again.

def ListBucket(bucket_ref, client):
  request = STORAGE_MESSAGES.StorageObjectsListRequest(bucket=bucket_ref.bucket)

  items = set()
  try:
    response = client.objects.List(request)
    for item in response.items:
      items.add(item.name)
    while response.nextPageToken:
      request = STORAGE_MESSAGES.StorageObjectsListRequest(bucket=bucket_ref.bucket,pageToken=response.nextPageToken)
      response = client.objects.List(request)
      for item in response.items:
        items.add(item.name)
  except api_exceptions.HttpError as e:
    raise UploadError('Error uploading files: {e}'.format(e=e))

  return items
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!