Damandroid
Damandroid

Reputation: 984

How to configure a GCP App Engine properly

I am struggling to understand the difference and benefits of a few terms which I use while I setup my App Engine instance:

  1. I am wondering how does server handle more than one request? Does it need to create a new instance of my server code for every request, sounds unlikely but I want to clarify. OR does it create a copy of my function handling the request? A typical function of mine looks like the following:

    app.get("/", limiter,  async function(req , res){
      try {
        my code 
      } catch (err){
        console.log(err);
        res.status(400).send('Something went wrong')
      }
    })
    
  2. What is the relation of a flex environment vs standard environment?

  3. When does a new instance is required?

My app.yaml looks like the following:

runtime: nodejs12
env: standard

manual_scaling:
  instances: 1 // Is this a bad idea in production?
resources:
  cpu: 1
  memory_gb: 0.5
  disk_size_gb: 10

Please I need help in understanding this so I can setup my instance properly.

Upvotes: 0

Views: 77

Answers (1)

Codo
Codo

Reputation: 79033

  1. Neither a new server nor a new function instance is needed. Instead, the same function (async function(req , res) in your case) is called several times concurrently. Each call will have a separate request and response instance (req and res in your case).

  2. Standard and Flexible are two different App Engine offerings from Google with different features and different pricing. Standard is more dynamic (quicker start-up, quicker deployment, scales down to 0 instances). Flexible offers more options (any programming language, support for web sockets etc.). For more details, see Choosing an App Engine environment .

  3. Unless you explicitly specify the number of instances, Google App Engine monitors request latency and probably CPU load and will increase and decrease the number of running instances depending on the actual load (possibly within the limits you have set). If a single instance is sufficient to handle the load of your application, you can fix the instance count at 1. That's a valid setting.

Upvotes: 1

Related Questions