1

I have a Google App Engine Java 11 service using the Standard Environment.

I have deployed it specifying in the corresponding app.yaml file manual scaling, setting the number of instances to 1.

Is there a way that I can increase the number of instances for this service without having to upload again all the files in the service?

So I have one instance. Now I want 2 instances. How do I do this?

Have not found a way in either the console or in the gcloud utilities to do this. Also, just calling gcloud app deploy with the modified app.yaml file creates a broken version of the service.

app.yaml:

service: headergrabber
runtime: java11
instance_class: B8

manual_scaling:
  instances: 1
Marco O.
  • 13
  • 4
  • You need to [redeploy](https://stackoverflow.com/questions/51431750/google-cloud-app-engine-edit-1-file) your application whenever you want to make code changes in it. Please provide your original and modified `app.yaml` without including sensitive information such as API keys or password so we can check where the problem is. – Donnald Cucharo Oct 08 '20 at 17:33
  • Don't want to make any code changes. Code is fine. Just want more instances. – Marco O. Oct 08 '20 at 19:35
  • Updated answer. – Donnald Cucharo Oct 09 '20 at 19:45

1 Answers1

1

Use REST API to patch the number of instances of your manual scaling app.

Here's the HTTP request:

PATCH https://appengine.googleapis.com/v1/{name=apps/*/services/*/versions/*}

You will have to pass manualScaling.instances field to update to the number of instance you prefer.

Here's an example with curl using a token that should only be used for local testing. I tested it on my side and it works:

curl -X PATCH -H "Content-Type: application/json" \
-d "{ 'manualScaling': {  'instances': 2 } }" \
-H "Authorization: Bearer $(gcloud auth application-default print-access-token)" \
https://appengine.googleapis.com/v1/apps/PROJECT-ID/services/SERVICE/versions/VERSION?updateMask=manualScaling.instances

Where:

  • PROJECT_ID = Project ID
  • SERVICE = Service Name
  • VERSION = Version Name

You need to login to your account and set the project if you're using Cloud SDK or you can run the command on Cloud Shell.

An alternative is to use a client library so you can write applications that can update your App Engine instance.

Take note that doing this would require App Engine Admin API enabled on your project. This API provides programmatic access to several of the App Engine administrative operations that are found in the Google Cloud Console.

Donnald Cucharo
  • 3,866
  • 1
  • 10
  • 17