Google Compute Engine High Availability and Best Practices: Instance Groups
Google Compute Engine High Availability and Best Practices: Instance Groups
Load Balancing
GCP provides managed load balancing that helps you manage high loads of traffic, to avoid
overwhelming VM instances. The load balancer service provides:
Forwarding rules—deploy applications across multiple regions using regionally
managed instance groups. You can configure forwarding rules to distribute traffic to
all virtual machines in that region. Each forwarding rule can use a single external IP
address, through which users can access your application.
Global load balancing—deploy instances in multiple regions using global load
balancing. HTTP/HTTPS load balancing traffic allows you to run your application near
to the geographical location of your users—for example, if you have users in Europe,
you can route them to VM instances of the application running in a European Google
Cloud region.
Redundancy—achieve redundancy by load balancing between regions. If one region
is not available, traffic is automatically routed to another region, while your service
can still be accessed using the same external IP address.
Autoscaling—automatically add or remove instances when load increases or
decreases, and load balance between instances in a managed instance group.
Startup and Shutdown Scripts
Google Compute Engine provides start-up and shutdown scripts that are executed when an
instance starts or stops. These scripts can automate tasks such as installing software,
updating, backing up, and generating logs. Importantly, the scripts run in any event an
instance is shut down—even unintentionally.
These scripts are an effective way to create a bootstrap procedure for your instances and
shut them down cleanly. Instead of using a custom image to configure the instance, you can
use a startup script. After each restart, the startup script runs and can be used to install or
update software, and ensure the appropriate services are running.
The shutdown script can perform important actions like closing connections, saving state of
transactions and backing up data.