Is there possibility to host multiple applications with Google App Engine?

前端 未结 5 1454
清歌不尽
清歌不尽 2020-12-23 09:23

Do I need to create for each new Google App Engine app new project? Or is there other way to have multiple apps in one project?

EDIT: removed \"extra question\"

相关标签:
5条回答
  • 2020-12-23 09:55

    I think it is a good idea to have a picture (worth a thousand words) presenting Google App Engine services hierarchy.

    Picture taken from An Overview of App Engine page.

    So you have an application under your Google Cloud project. An application can have one or more services. Services are loosely coupled and are developed and maintained independently. For many people it might be confusing as they may call a service an application. Google changed naming convention to use microservices nomenclature.

    A service can have different versions (e.g. v1.0.1, v1.0.2, v2.0.0 etc.) and a version can have multiple instances that handle newtwork traffic.

    Obviously there are limitations for number of services, versions and instances and they depend on region and free / paid version as specified in An Overview of App Engine.

    0 讨论(0)
  • 2020-12-23 09:57

    Now getting back to this later I see that the proper approach is to use App Engine Services (previously known as Modules). Services can each have their own versions etc.

    EDIT: Updated depricated name Modules to Services

    0 讨论(0)
  • 2020-12-23 10:05

    This is easily done with services. When you deploy to App Engine define your app.yaml file with a line like: service: my-second-app

    Complete app.yaml file for another Node.js service:

    service: my-second-app
    runtime: nodejs
    env: flex
    automatic_scaling:
       min_num_instances: 1
    

    When you deploy, do it from the directory containing your app.yaml file:

    gcloud app deploy
    

    Or if you want to define your configuration in a yaml file just for your seond app:

    gcloud app deploy my-second-app.yaml
    

    The new service will be deployed along side your default service and will get it's own URL like:

    https://my-second-app-dot-my-project-name.appspot.com
    
    0 讨论(0)
  • 2020-12-23 10:17

    You can have an unlimited number of "apps" running with the same projectId. For example, you can have different client apps load when a user hits different URLs on your server: /mainApp, /setup, /admin, etc.

    These apps will have access to the same Datastore, so you have to be careful to separate them, for example, by using namespaces or different entity kinds - if you do need to separate them. In the example above, "Setup" and "Admin" may be different apps that access the same data.

    Note that having multiple apps in the same project is a good idea only if these apps are closely related. Otherwise, it becomes very inconvenient, even if you use different App Engine modules to run each app's server-side code.

    0 讨论(0)
  • 2020-12-23 10:19

    Every time you upload something on App Engine you have to define a version name and you can upload up to 25 different versions for the same application ID.

    Every version has a direct URL that looks like this:

    http://version.application-id.appspot.com
    

    or if want HTTPS

    https://version-dot-application-id.appspot.com
    

    If you omit the version from the URL you are getting the default version that you have chosen from the dashboard.

    So in theory you can have up to 25 different application running under the same project, but they will share the same datastore.


    Another option is to use the App Engine Modules.

    0 讨论(0)
提交回复
热议问题