[[["易于理解","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\u003e\u003ccode\u003eREGION_ID\u003c/code\u003e is a Google-assigned code based on the region selected when creating an app, included in App Engine URLs for apps created after February 2020.\u003c/p\u003e\n"],["\u003cp\u003eEach App Engine service version is defined by an \u003ccode\u003eapp.yaml\u003c/code\u003e file, which specifies scaling type, runtime, handlers, and resource settings.\u003c/p\u003e\n"],["\u003cp\u003eApps can be structured with separate directories or repositories for each service, each containing its own \u003ccode\u003eapp.yaml\u003c/code\u003e and associated code.\u003c/p\u003e\n"],["\u003cp\u003eThe \u003ccode\u003edefault\u003c/code\u003e service is a required service in every App Engine application, and the first version of an app must be deployed to it before adding additional services.\u003c/p\u003e\n"],["\u003cp\u003eOptional configuration files like \u003ccode\u003edispatch.yaml\u003c/code\u003e, \u003ccode\u003eindex.yaml\u003c/code\u003e, and \u003ccode\u003ecron.yaml\u003c/code\u003e, which apply to all services in an app, should be placed in the root directory of the \u003ccode\u003edefault\u003c/code\u003e service.\u003c/p\u003e\n"]]],[],null,["# Structuring Web Services in App Engine\n\n### Region ID\n\nThe \u003cvar translate=\"no\"\u003eREGION_ID\u003c/var\u003e is an abbreviated code that Google assigns\nbased on the region you select when you create your app. The code does not\ncorrespond to a country or province, even though some region IDs may appear\nsimilar to commonly used country and province codes. For apps created after\nFebruary 2020, \u003cvar translate=\"no\"\u003eREGION_ID\u003c/var\u003e`.r` is included in\nApp Engine URLs. For existing apps created before this date, the\nregion ID is optional in the URL.\n\nLearn more\n[about region IDs](/appengine/docs/legacy/standard/go111/how-requests-are-routed#region-id). \nOK\n\nUse the following document to understand how to structure the services and\nrelated resources of your app for App Engine.\n\nDirectory structure\n-------------------\n\n\nEach version of your App Engine service is defined in an\n[`app.yaml`](/appengine/docs/legacy/standard/go111/configuring-your-app-with-app-yaml)\nconfiguration file. For simple apps, the minimum requirement for deployment is\nto define the `app.yaml` file. The `app.yaml` file acts as a deployment\ndescriptor and defines the scaling type and the\nruntime, handlers, and other resource\nsettings for a specific\nversion of a service. If you are deploying several versions of a service, you\ncan create multiple YAML files in the same directory to represent the\nconfiguration for each of your versions.\n\n\nFor each service, you can create separate directories in the root of your app\nwhen you are developing locally. If you host your app out of a version control\nsystem (VCS), for example GitHub, you can also structure your app to use\nseparate directories in a repository, or use separate repositories for each\nservice. Each directory or repository should represent a single service and\ncontain that service's `app.yaml` file along with the associated source code.\n\nYou have the option of specifying a unique name for each of your service's\n`app.yaml` file. For example, you can name a configuration file after your\nservice, or use unique names to represent each version of that particular\nservice, like `service1.yaml` or `app.standard.yaml`.\n\nThe other [optional configuration files](#optional_configuration_files) should\nreside in the root directory or repository of the\n[`default` service](#the_default_service) of your app. These optional\nconfiguration files apply app-wide settings that are not specific to a\nparticular service, including the `dispatch.yaml`,\n`index.yaml` and `cron.yaml` files.\n\n### Examples\n\nThe following example demonstrates what an app with three services might look\nlike if you are developing your app locally. The optional `dispatch.yaml` has\nbeen added to that app in the root directory. Also in the root are three\ndirectories for each of the app's services. The subdirectory for `service1`\nincludes the source and configuration files for that service. Similarly, both\n`service2` and `service3` are in separate directories, which contain each\nservice's files, although `service3` includes two versions of the YAML\nconfiguration file:\n\nFor a single\nservice app, that app will only include the\n[`default` service](#the_default_service) and all the files can live in the same\ndirectory, at the root of that\napp. In the following example, the possible structure of a single service\napp is demonstrated and includes the optional `dispatch.yaml` configuration file\nand two configuration files that represent different versions of that service,\n`service1.yaml` and `service2.yaml`:\n\n\nDesign considerations for instance uptime\n-----------------------------------------\n\nHardware or software failures that cause early termination or frequent instance\nrestarts can occur without warning and can take considerable time to resolve.\nYour application should be able to handle such failures.\n\nHere are some good strategies for avoiding downtime due to instance restarts:\n\n- Reduce the amount of time it takes for your instances restart or for new ones to start.\n- For long-running computations, periodically create checkpoints so that you can resume from that state.\n- Your app should be \"stateless\" so that nothing is stored on the instance.\n- Use queues for performing asynchronous task execution.\n- If you configure your instances to manual scaling:\n - Use load balancing across multiple instances.\n - Configure more instances than required to handle normal traffic.\n - Write fall-back logic that uses cached results when a manual scaling instance is unavailable.\n\nLearn more about instances at [How Instances are\nManaged](/appengine/docs/legacy/standard/go111/how-instances-are-managed).\n\nThe `default` service\n---------------------\n\nEvery App Engine application includes a `default` service. You must\ndeploy the initial version of your app to the `default` service before you can\ncreate and deploy additional services to your app.\n\nThe default service can be optionally specified\n\nin the `app.yaml` with the setting\n`service: default`.\n\nRequests sent to your app using your Google Cloud project are sent to the\n`default` service, for example,\n`https://`\u003cvar translate=\"no\"\u003ePROJECT_ID\u003c/var\u003e`.`\u003cvar translate=\"no\"\u003e\u003ca href=\"#appengine-urls\" style=\"border-bottom: 1px dotted #999\" class=\"devsite-dialog-button\" data-modal-dialog-id=\"regional_url\" track-type=\"progressiveHelp\" track-name=\"modalHelp\" track-metadata-goal=\"regionalURL\"\u003eREGION_ID\u003c/a\u003e\u003c/var\u003e`.r.appspot.com`. To learn\nmore about targeting your other services, see [Communicating Between\nServices](/appengine/docs/legacy/standard/go111/communicating-between-services).\n\nOptional configuration files\n----------------------------\n\nThe following configuration files control optional features that apply to all of\nthe services in an individual app. See the following topics for details about\neach of the optional features:\n\n- [`dispatch.yaml`](/appengine/docs/legacy/standard/go111/reference/dispatch-yaml) overrides routing default rules by sending incoming requests to a specific service based on the path or hostname in the URL.\n- [`index.yaml`](/appengine/docs/legacy/standard/go111/configuring-datastore-indexes-with-index-yaml) specifies which indexes your app needs if using Datastore queries.\n- [`cron.yaml`](/appengine/docs/legacy/standard/go111/scheduling-jobs-with-cron-yaml) configures regularly scheduled tasks that operate at defined times or regular intervals.\n\nData and file storage considerations\n------------------------------------\n\nFrom App Engine, you can easily access other Google Cloud\nservices such as [Datastore](/datastore), [Cloud SQL](/sql), and\n[Cloud Storage](/storage).\n\nYou also have the option to use an external or third-party database if that\ndatabase is supported by your language and accessible from your\nApp Engine instance.\nFor details about storing files in Google Cloud or externally, see [Understanding Data and File Storage](/appengine/docs/legacy/standard/go111/storage-options).\n\nYou can also choose how you want to serve your static content. You can serve\nyour app's static content directly from that app in App Engine, host\nyour static content on a Google Cloud option like\nCloud Storage, or use a third-party content delivery network (CDN).\nFor more information about serving static content, see [Serving Static\nFiles](/appengine/docs/legacy/standard/go111/serving-static-files).\n\nWhat's next\n-----------\n\nIf you are working with multiple services and want to deploy them together, see the steps to [deploy multiple services](https://cloud.google.com/appengine/docs/standard/nodejs/testing-and-deploying-your-app#deploying_multiple_services)."]]