【发布时间】:2018-07-05 08:38:35
【问题描述】:
我一直在尝试测试我要在 App Engine 上设置的项目。由于机密性,我无法指定我的确切代码,但它是在教程之间定制的:Scalable Video Transcoding (Github) 和 Using Cloud Pub/Sub with Python (Github)
本质上,它运行一个带有 Flask 的 App Engine 服务来处理通过 psq 将任务排入队列的传入请求,以及一个运行 psqworker 来执行任务的工作服务。
测试服务本身运行良好。我使用的媒体在工作服务中被转码并返回到我的云存储中。
问题是,在启动一小时后,无论我是否将任何任务排队,每个工作实例都会开始上升到 99-100% 的 CPU 使用率。当我通过 SSH 连接到一个实例时,原因是 psqworker。这对 App Engine 来说真的很糟糕,因为它想要扩展和添加更多实例(这反过来又在启动一个小时后做同样的事情)。我试图查看 Stackdriver 日志,但找不到任何明显的原因。
我也不确定为什么 Ruby 也在 CPU 上运行,如屏幕截图所示。它旨在成为基于 Google 的 python 图像的自定义灵活运行时。
我在我的 Windows 机器上本地运行服务,没有出现 CPU 使用率高峰。
Dockerfile:
# The Google App Engine python runtime is Debian Jessie with Python installed
# and various os-level packages to allow installation of popular Python
# libraries. The source is on github at:
# https://github.com/GoogleCloudPlatform/python-docker
FROM gcr.io/google_appengine/python
RUN apt-get -y update && apt-get install -y libav-tools
# Create a virtualenv for dependencies. This isolates these packages from
# system-level packages.
RUN virtualenv /env -p python3.6
# Setting these environment variables are the same as running
# source /env/bin/activate.
ENV VIRTUAL_ENV /env
ENV PATH /env/bin:$PATH
# Copy the application's requirements.txt and run pip to install all
# dependencies into the virtualenv.
ADD requirements.txt /app/requirements.txt
RUN pip install -r /app/requirements.txt
# # Add the application source code.
ADD . /app
CMD mkdir /tmp/audio
# CMD honcho start -f /app/procfile transcoder
CMD honcho start -f /app/procfile worker monitor
【问题讨论】:
标签: python google-app-engine google-cloud-pubsub app-engine-flexible