Choose between standard and flexible App engine on GCP
Before going to deeper into details of choosing right environment, first of all we should know app engine works
“When we deploy an application then it creates a container and deploy it either on lightweight instance (for standard) and compute instance (for flexible)”
Choose between standard and flexible App engine
Time to scale up or down:
In Standard environment, application runs on lightweight instance on sandbox. So it response quickly and scaling will be quite fast even from zero to thousands in few seconds. Whereas in flexible containers runs inside the Google’s compute engine VM. So it can be customized more (network configuration can be added, you can ssh into instance) but scaling might take more time as compared to standard environment.
Standard environment doesn’t use health check to determine whether or not we should send traffic to instance.Since it allow certain memory and CPU so based on their own algorithm they decide when to spin up a new machine. In case of flexible instance it allows to write custom health check and redirect traffic based on that as well (although that is very careful task)
In standard environment, if there is overload on the server then it drop certain request in order to avoid cascade failure (and spin up new instances). So its recommended that we should use flexible environment for high QPS apps. in Flexible environment to handle overload we should use following best practices:-
*. Limiting the number of concurrent request (Java apps using the Jetty runtime that can configure the Quality of Service Filter to implement drop overload. You can use this feature to set the maximum number of concurrent requests serviced by the apps, and the length of time that requests will be queued using this feature in order to manage more efficiently)
*. Should ensure that health check is not being performed during overload
*. Should have another version running and split traffic gradually
Single Zone failure:
In standard environment, all the instances are hosted on single zone and in case of zone failure, the application starts new instances on another zone in same region and load balancer will route traffic to new zone. In flexible case instances are hosted on regional managed instance group so these are not in one availability zone so in case of one zone failure, health check will work and all load will get distributed to different zone and because of auto scaling it will spin up other machines there.
by the way cost is based on resource consumed in both (standard and flexible ) like CPU, QPS, Memory, Network etc.
In standard environment even you will make changes in machine in order to see what is the changes happned you will get to know after daily cycle. but in flexible environment you can do experiment so see if cost has any impact or not if you are changing resources.
Standard environment allows secure authentication between applications using the X-Appengine-Inbound-Appid request header. But in Flexible environment does not have such a feature. The recommended approach for secure authentication between applications is to use OAuth.