Python 2.7 已达到支持终止期限,并将于 2026 年 1 月 31 日
弃用。弃用后,您将无法部署 Python 2.7 应用,即使您的组织之前曾使用组织政策重新启用旧版运行时的部署也是如此。现有的 Python 2.7 应用在
弃用日期之后将继续运行并接收流量。我们建议您
迁移到最新支持的 Python 版本。
使用 API Explorer 设置自动扩缩参数
使用集合让一切井井有条
根据您的偏好保存内容并对其进行分类。
如果您使用 gcloud CLI 工具部署应用(例如 gcloud app deploy
),则可以在 app.yaml
配置文件中设置下列自动扩缩参数:
min_instances
max_instances
target_throughput_utilization
target_cpu_utilization
您还可以使用 API Explorer 界面来设置自动扩缩参数:
打开 API Explorer 页面。
在右侧面板中的“试用此 API”标签下,找到名称文本框,然后按以下格式输入应用名称字符串:
apps/<YOUR-PROJECT-ID>/services/default/versions/<YOUR-VERSION-ID>
将 YOUR-PROJECT-ID
替换为您的应用的项目 ID,并将 <YOUR-VERSION-ID>
替换为您要将请求发送到的应用的版本。字符串的其余部分保持不变。
在 updateMask 文本框中,使用下表中的 updateMask
名称来输入要设置的参数的完整 .json
对象路径名称:
updateMask 名称 |
automatic_scaling.standard_scheduler_settings.max_instances |
automatic_scaling.standard_scheduler_settings.min_instances |
automatic_scaling.standard_scheduler_settings.target_cpu_utilization |
automatic_scaling.standard_scheduler_settings.target_throughput_utilization |
如果要在一个请求中设置多个参数,请为每个参数提供掩码名称,并以逗号分隔。例如,要设置最小和最大实例数以及 CPU 利用率,请使用以下 updateMask:
automatic_scaling.standard_scheduler_settings.max_instances,
automatic_scaling.standard_scheduler_settings.min_instances,
automatic_scaling.standard_scheduler_settings.target_cpu_utilization
在请求正文框中,点击添加请求正文参数。
选择 automaticScaling。
点击提示气泡(+
图标),然后选择 standardSchedulerSettings。
点击提示气泡,然后选择所需的自动扩缩调度器参数并提供所需的值。
要再提供一个自动扩缩调度器参数,请再次点击提示气泡,选择参数并提供参数值。
以下示例展示了如何填写请求正文:
{
"automaticScaling": {
"standardSchedulerSettings": {
"maxInstances": 100,
"minInstances": 1,
"targetCpuUtilization": 0.75
}
}
}
点击执行。第一次运行时,系统可能会提示您为 API Explorer 授权。如果出现提示,请按照提示为 API Explorer 授权。
打开项目的“App Engine 版本”页面,然后点击“配置”列中的查看,确认已应用了正确的设置。您应该会看到刚刚设置的值。
如未另行说明,那么本页面中的内容已根据知识共享署名 4.0 许可获得了许可,并且代码示例已根据 Apache 2.0 许可获得了许可。有关详情,请参阅 Google 开发者网站政策。Java 是 Oracle 和/或其关联公司的注册商标。
最后更新时间 (UTC):2025-09-04。
[[["易于理解","easyToUnderstand","thumb-up"],["解决了我的问题","solvedMyProblem","thumb-up"],["其他","otherUp","thumb-up"]],[["很难理解","hardToUnderstand","thumb-down"],["信息或示例代码不正确","incorrectInformationOrSampleCode","thumb-down"],["没有我需要的信息/示例","missingTheInformationSamplesINeed","thumb-down"],["翻译问题","translationIssue","thumb-down"],["其他","otherDown","thumb-down"]],["最后更新时间 (UTC):2025-09-04。"],[[["\u003cp\u003eYou can configure autoscaling parameters for your application using the \u003ccode\u003egcloud app deploy\u003c/code\u003e command and specifying values in the \u003ccode\u003eapp.yaml\u003c/code\u003e file for \u003ccode\u003emin_instances\u003c/code\u003e, \u003ccode\u003emax_instances\u003c/code\u003e, \u003ccode\u003etarget_throughput_utilization\u003c/code\u003e, and \u003ccode\u003etarget_cpu_utilization\u003c/code\u003e.\u003c/p\u003e\n"],["\u003cp\u003eThe API explorer user interface allows for the configuration of autoscaling parameters by specifying the \u003ccode\u003eupdateMask\u003c/code\u003e names such as \u003ccode\u003eautomatic_scaling.standard_scheduler_settings.max_instances\u003c/code\u003e and corresponding values in the request body.\u003c/p\u003e\n"],["\u003cp\u003eTo update multiple parameters using the API explorer, you must include each parameter's \u003ccode\u003eupdateMask\u003c/code\u003e name separated by commas within the \u003ccode\u003eupdateMask\u003c/code\u003e field.\u003c/p\u003e\n"],["\u003cp\u003eAfter setting your parameters through the API explorer, you can confirm the new values have been correctly applied by viewing the \u003cem\u003eConfig\u003c/em\u003e column on the App Engine versions page for your project.\u003c/p\u003e\n"]]],[],null,["# Setting Autoscaling Parameters with the API Explorer\n\nIf you use the gcloud CLI tooling to deploy your app, such as\n`gcloud app deploy`,\n\nyou can set the following autoscaling parameters in the\n`app.yaml` configuration file:\n\n- `min_instances`\n- `max_instances`\n- `target_throughput_utilization`\n- `target_cpu_utilization`\n\nYou can also use the API explorer user interface to set an [autoscaling parameter](/appengine/docs/legacy/standard/python/config/appref#scaling_elements):\n\n1. Open the [API explorer\n page](/appengine/docs/admin-api/reference/rest/v1/apps.services.versions/patch).\n\n2. In the right panel under the label *Try This API* , locate the **name**\n text box and enter the application name string in the following format:\n\n apps/\u003cYOUR-PROJECT-ID\u003e/services/default/versions/\u003cYOUR-VERSION-ID\u003e\n\n Replace `YOUR-PROJECT-ID` with your application's project ID, and\n `\u003cYOUR-VERSION-ID\u003e` with the version of the app you are sending the request\n to. Use the rest of the string as shown.\n3. In the **updateMask** text box, enter the full `.json` object path name of the\n parameter you are setting, using `updateMask` names from the table below:\n\n If you are setting more than one parameter in one request, supply the mask\n name for each parameter, separated by a comma. For example, if you are\n setting the min and max instances, and the CPU utilization, use the\n following updateMask: \n\n automatic_scaling.standard_scheduler_settings.max_instances,\n automatic_scaling.standard_scheduler_settings.min_instances,\n automatic_scaling.standard_scheduler_settings.target_cpu_utilization\n\n4. In the **Request body** box, click **Add request body parameters** .\n\n5. Select **automaticScaling**.\n\n6. Click the hint bubble (the `+` icon), then select **standardSchedulerSettings**.\n\n7. Click the hint bubble, then select the desired auto scaling scheduler\n parameter and supply the desired value.\n\n8. To supply another auto scaling scheduler parameter, click the hint bubble\n again, select the parameter, and supply its value.\n\n The following example shows a sample filled out request body: \n\n {\n \"automaticScaling\": {\n \"standardSchedulerSettings\": {\n \"maxInstances\": 100,\n \"minInstances\": 1,\n \"targetCpuUtilization\": 0.75\n }\n }\n }\n\n9. Click **Execute**. You may be prompted to authorize API Explorer the first\n time you run this. If you are prompted, authorize API Explorer by following the\n prompts.\n\n10. Confirm that the correct settings have been applied by opening the\n [App Engine\n versions page](https://console.cloud.google.com/appengine/versions) for your project, and clicking **View** in the\n *Config* column. You should see the values you just set."]]