[[["易于理解","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-08-20。"],[[["\u003cp\u003eTraffic migration in the flexible environment allows you to immediately switch request routing from one or more versions of your application to a single new version.\u003c/p\u003e\n"],["\u003cp\u003eTo prevent latency spikes, provision sufficient instances of the new version using the App Engine Admin API before migrating traffic, and set \u003ccode\u003eminTotalInstances\u003c/code\u003e accordingly.\u003c/p\u003e\n"],["\u003cp\u003eTraffic can be migrated using the Google Cloud console, the \u003ccode\u003egcloud app services set-traffic\u003c/code\u003e command, or programmatically through the Admin API.\u003c/p\u003e\n"],["\u003cp\u003eGradual traffic migration is an option through the use of the \u003ccode\u003emigrate\u003c/code\u003e flag or the enabling of warmup requests, and can be configured from the console or through the \u003ccode\u003egcloud\u003c/code\u003e command.\u003c/p\u003e\n"],["\u003cp\u003eEnsure your user account has the necessary privileges to configure traffic before you begin migrating traffic to a new version.\u003c/p\u003e\n"]]],[],null,["# Migrating traffic\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\nTraffic migration switches the request routing between the versions within a\nservice of your application, moving traffic from one or more versions to a\nsingle new version.\n\nTraffic is migrated immediately between your versions in the\nflexible environment. Unlike versions in the standard environment,\n[gradual traffic migration](/appengine/docs/standard/migrating-traffic)\nis not supported in the flexible environment.\n\nIf you immediately migrate traffic to a new version without any running\ninstances then your app will have a spike in latency while instances are being\ncreated. You can avoid a spike in latency by using the\n[App Engine Admin API](/appengine/docs/admin-api) to provision\nsufficient instances of the new app's version before you migrate traffic to it.\n\nSet [`minTotalInstances`](/appengine/docs/admin-api/reference/rest/v1/apps.services.versions#automaticscaling)\nfor the new version to the number needed to handle expected traffic. After\nmigration is complete, you can reset this field so that autoscaling occurs\nif traffic drops.\n\nYou can split traffic between versions of your app, increasing the amount of\ntraffic a version receives in stages.\n\n\nFor information about splitting traffic between two or more versions of your\napp, see [Traffic Splitting](/appengine/docs/flexible/splitting-traffic).\n\nBefore you begin\n----------------\n\nBefore you can configure traffic to a version, ensure that your user account\nincludes the [required privileges](/appengine/docs/flexible/access-control#basic_roles).\n\nMigrating traffic to a new version\n----------------------------------\n\n### Console\n\nTo migrate traffic in the Google Cloud console, go to the Versions page:\n\n[Go to Versions](https://console.cloud.google.com/appengine/versions)\n\n1. Select the version to which you want to migrate 100% of the traffic.\n2. Click **Migrate traffic**.\n3. Optional: When warmup requests are enabled your traffic is migrated gradually. To migrate traffic immediately, select the option under the **Show advanced options** section.\n\n### gcloud\n\nAfter installing the [Google Cloud CLI](/sdk/docs), you run the [`gcloud\napp services set-traffic`](/sdk/gcloud/reference/app/services/set-traffic)\ncommand to migrate 100% of traffic to a single version. For example:\n\n- To migrate traffic immediately: \n\n ```bash\n gcloud app services set-traffic [MY_SERVICE] --splits [MY_VERSION]=1\n ```\n- To gradually migrate traffic, you include the optional `--migrate` flag: \n\n ```bash\n gcloud app services set-traffic [MY_SERVICE] --splits [MY_VERSION]=1 --migrate\n ```\n\n### API\n\nTo programmatically migrate traffic, you can use the Admin API,\nsee [Migrating and Splitting\nTraffic](/appengine/docs/admin-api/migrating-splitting-traffic) for details."]]