htafoya
htafoya

Reputation: 19273

How to achieve Google App engine redundancy with NodeJs

I have a NodeJs project on app engine (GAE) .

Whenever there is an unexpected crash in a service call the NodeJs has to restart (I believe this is normal) , however, this leaves the whole server unaivailable for a couple of seconds which may affect other users.

I was thinking on creating two instances of the server so that if one instance fails, the other can still attend the requests.

However, I’m not certain this will bring more work, as the node js project does some initialization procedures and has some cron tasks scheduled. If I create more instances will chron tasks be duplicated?

Or which is the best way to manage redundancy on this kind of environment?

Upvotes: 1

Views: 174

Answers (1)

Alex
Alex

Reputation: 5276

To always have 2 instances running, you do this in app.yaml set

automatic_scaling:
  min_instances: 2

https://cloud.google.com/appengine/docs/standard/python/config/appref#scaling_elements

Chron tasks will not be duplicated.

This is the way to have this type of redundancy, but it comes at the cost of having to always pay for 2 instances

But, what's going on when you actually get an "unexpected crash in a service call". That doesn't sound normal.

Upvotes: 1

Related Questions