85

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"

Maksim Luzik
  • 5,863
  • 4
  • 36
  • 57
  • Keep it to one question per question.. – Lipis Mar 27 '15 at 14:18
  • For european region you might have to contact the sales/support: https://cloud.google.com/appengine/docs/python/gettingstartedpython27/uploading – Lipis Mar 27 '15 at 14:28
  • 1
    "Side question" asked [here](http://stackoverflow.com/questions/25766488/region-at-google-app-engine) – Lee May 10 '15 at 12:25

5 Answers5

148

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
Art Haedike
  • 1,772
  • 2
  • 16
  • 13
  • Does this enable the separate versioning as well? – Maksim Luzik Jun 27 '17 at 08:42
  • 1
    Have not tried versioning a service yet, but the relevant documentation seems to indicate it is supported: https://cloud.google.com/appengine/docs/admin-api/deploying-apps – Art Haedike Jun 27 '17 at 22:59
  • 2
    Just for clarification: you do not have to create the new service beforehand, it is created on deployment if you just type the new service name in the app.yaml i.e. service: my-second-app . – Johan May 15 '19 at 15:26
  • Interesting but what if I want the second app to use a second database? It looks that gcloud allows only one Firestore db per project for instance. – Jérôme Beau Nov 25 '21 at 13:50
  • 1
    For anybody who is surprised at the `-dot-` in the answer - the OP didn't use that as a shorthand for `.`, that's really how Google does it. See the example URLs here: https://cloud.google.com/appengine/docs/standard/how-requests-are-routed?tab=python#example_urls – Stephen Mar 06 '23 at 22:12
72

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

An Overview of App Engine

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.

Tom
  • 26,212
  • 21
  • 100
  • 111
14

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.

Lipis
  • 21,388
  • 20
  • 94
  • 121
  • 3
    There is no reason to use versions for different apps. It's possible to have any number of apps in the same project, and still have 25 versions of the project. – Andrei Volgin Mar 27 '15 at 14:57
  • 1
    This is not a good idea. Task queues and other things only run on the default version. Non default versions dont even have https. Versions are meant to be used as a dev cycle convenience. – Zig Mandel Mar 27 '15 at 14:58
  • @AndreiVolgin I updated my answer to check on modules, but from what I understood from the question is that the OP wanted to more like experiment as either case this solution that I'm suggesting is not going to fly if you want to use custom domain and valid points about Tasks.. Maybe Maksim can give us more info, on what exactly he wants to achieve. – Lipis Mar 27 '15 at 16:00
  • 1
    @ZigMandel, what do you mean "Non default versions dont even have https"?! Of course they do, indeed the A you're commenting on even shows directly how to get it (with `-dot-` rather than `.` in the URL)...! – Alex Martelli Mar 27 '15 at 23:08
  • 1
    Im sorry, youre right on https. Thou the taskqueue issue remains right? – Zig Mandel Mar 27 '15 at 23:19
  • Thanks @Lipis for you answer, that clarifies a lot. I think your proposal is really great to experiment different apps, but for more "production" like approach is to have routing set up for different closely related apps is better. But at least I got my answer regarding whether or not you can have multiple App Engine projects under one Google Dev Console project. Also thanks for the Modules hint, I will check it out. – Maksim Luzik Mar 30 '15 at 06:38
  • Related: http://stackoverflow.com/questions/9456971/any-issues-using-multiple-gae-app-versions-to-get-multiple-apps-to-share-the-sam – Dan Cornilescu Mar 03 '17 at 04:21
  • You can run a taskque on other services than "default", you just have to specify your service/version in the cron job specification like this: (target = service/version) cron: - description: "Push a tick onto pubsub every 5 mins" url: /publish/fiveminute-tick target: cron-service schedule: every 5 mins – Hallgeir Engen Sep 07 '18 at 07:10
5

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

Maksim Luzik
  • 5,863
  • 4
  • 36
  • 57
4

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.

Andrei Volgin
  • 40,755
  • 6
  • 49
  • 58
  • 1
    Adding to Andrei's answer... If the apps are closely related, you can use DomainRoute (in webapp2) which provides the option to use the same URLs but handling each differently according to the domain/subdomain accessing it. For example, if hosting a content app that shares the same functionality but serves different content based on domain. – Jeff Deskins Mar 27 '15 at 18:14
  • @andrei-volgin, would you please link to the source which documents this? – Eduard Wirch Dec 04 '17 at 07:19