Cloud Functions is a serverless, managed compute service for running code in response to events that occur in the cloud. Events such as writing a message to a Cloud Pub/Sub topic or uploading a file to Cloud Storage can trigger the execution of a Cloud Function. Cloud Functions also respond to events in HTTP, Firebase, and Stackdriver Logging.
For each supported service, Cloud Functions respond to specific events. In Cloud Storage, a script can execute in response to uploading, deleting, and archiving files. HTTP events include:
1. GET,
2. POST,
3. PUT,
4. DELETE,
5. OPTIONS operations.
Cloud Functions is written using JavaScript, Python 3, and Go.
Cloud Functions is a good option when you need to execute code in response to events that can occur at any time, such as uploading a file or calling a webhook. They are also useful when ingesting data using Cloud Pub/Sub, such as in an IoT ingestion pipeline.
The four main compute infrastructure options are summarized in:

Availability, Reliability, and Scalability of Infrastructure
When we design systems, we need to consider three nonfunctional requirements: availability, reliability, and scalability.
1. Availability: defined as the ability of a user to access a resource at a specific time. Availability is usually measured as the percentage of time that a system is operational.
Availability is a function of reliability, which is defined as the probability that a system will meet service-level objectives for some duration of time. Reliability is often measured as the mean time between failures.
2. Scalability: the ability of a system to handle increases in workload by adding resources to the system as needed. This implies that as workload increases, resources will be available to process that workload. It also implies that as workload decreases, the amount of allocated resources will decreases to a level sufficient to meet the workload plus some marginal extra capacity.
Making Compute Resources Available, Reliable, and Scalable
Highly available and scalable compute resources typically employ clusters of machines or VMs with load balancers and autoscalers to distribute workload and adjust the size of the cluster to meet demand.
Compute Engine

When using Compute Engine, you are responsible for ensuring high availability and scalability. This is done with managed instance groups (MIGs). MIGs are defined using a template. Templates include specifications for the machine type, boot disk image or container image, labels, and other instance properties. All members of a MIG are identical.
When an instance in a MIG fails, it is replaced with an identically configured VM. In addition, there may be times when an instance is running but the application is not functioning correctly - for example, if a fatal error occurs. In those cases, application-specific health checks can be used to detect the problem and replace the instance.
Load balancers direct traffic only to responsive instances, and they use health checks to determine which instances are available to accept traffic. Load balancers are either global or regional, and some are designed for internal traffic only whereas others work with external traffic as well.
The global load balancers are HTTP(S) Load Balancing, SSL Proxy, and TCP Proxy. The regional load balancers are Network TCP/UDP, Internal TCP/UDP, and Internal HTTP(S). Global load balancers can be used to distribute workloads across regions, further increasing the availability and reliability of applications.
Instance groups can be either zonal or regional. In zona instance groups, all instances are created in the same zone. Regional instance groups place instances in multiple zones in the same region. The latter provides higher availability because the MIG could withstand a zone-level failure and the applications would continue to be available.
Autoscalers add and remove instances according to workload. When using autoscaling, you create a policy that specifics the criteria for adjusting the size of the group. Criteria include CPU utilization and other metrics collected by:
1. Stackdriver,
2. Load-balancing capacity,
3. The number of messages in a queue.
Note that when you use Compute Engine, you have the greatest level of control over your instances, but you are also responsible for configuring managed instance groups, load balancers, and autoscalers.
Kubernetes Engine
Kubernetes is designed to support high availability, and scalability for containers and applications running in a cluster. Kubernetes deploys containers in an abstraction known as a pod. When pods fail, they are replaced much like failed instances in a managed instance group. Nodes in Kubernetes Engine belong to a pool, and with the autorepair feature turned on, failed nodes will be reprovisioned automatically.
There are other ways Kubernetes Engine ensures high availability and reliability. When using Kubernetes Engine, you can specify whether the endpoint for accessing the cluster is zonal or regional. In the latter case, you can access the cluster even if there is a failure in a zone. Also, you can specify a high availability cluster configuration that replicates master and worker nodes across multiple zones.
Load Balancers

Load balancing refers to efficiently distributing incoming network traffic across a group of backend servers, also known as a server farm or server pool.
Modern high-traffic websites must serve hundreds of thousands, if not millions, of concurrent requests from users or clients and return the correct text, images, video, or application data, all in a fast and reliable manner. To cost-effectively scale to meet these high volumes, modern computing best practice generally requires adding more servers.
A load balancer acts as the "traffic cop" sitting in front of your servers and routing client requests across all servers capable of fulfilling those requests in a manner that maximizes speed and capacity utilization and ensures that no one server is overworked, which could degrade performance. If a single server goes down, the load balancer redircts traffic to the remaining online servers. When a newer server is added to the server group, the load balancer automatically starts to send requests to it.
In this manner, a load balancer performs the following functions:
1. Distributes client requests or network load efficiently across multiple servers.
2. Ensures high availability and reliability by sending requests only to servers that are online.
3. Provides the flexibility to add or subtract servers as demand dictates.
Comments
Post a Comment