arrow_back

Deploy Go Apps on Google Cloud Serverless Platforms

Join Sign in

Deploy Go Apps on Google Cloud Serverless Platforms

1 hour 10 minutes 1 Credit

GSP702

Google Cloud self-paced labs logo

Overview

Go is an open source programming language by Google that makes it easy to build fast, reliable, and efficient software at scale. In this lab you explore the basics of Go by deploying a simple Go app to Cloud Run, Cloud Functions, and App Engine. You then use the Go app to access data in BigQuery and Firestore.

What you'll do

In this lab, you perform the following:

  • Set up your Firestore Database and import data

  • Get an introduction to the power of Cloud Build

  • Explore data in BigQuery and Firestore

  • Deploy a Go app to App Engine, Cloud Run, and Cloud Functions

  • Examine the Go app code

  • Test the app on the each of the platforms

What is Go?

Go (golang) is a general-purpose language designed with systems programming in mind. It is strongly typed and garbage-collected and has first class support for concurrent programming. Programs are constructed from packages, whose properties allow efficient management of dependencies.

Unlike Python and Javascript, Go is compiled not interpreted. Go source code is compiled into machine code before execution. As a result, Go is typically faster and more efficient than interpreted languages and requires no installed runtime like Node, Python, or JDK to execute.

Serverless Platforms

Serverless computing enables developers to focus on writing code without worrying about infrastructure. It offers a variety of benefits over traditional computing, including zero server management, no up-front provisioning, auto-scaling, and paying only for the resources used. These advantages make serverless ideal for use cases like stateless HTTP applications, web, mobile, IoT backends, batch and stream data processing, chatbots, and more.

Go is perfect for cloud applications because of its efficiency, portability, and how easy it is to learn. This lab shows you how to use Cloud Build to deploy a Go app to the Cloud Run, Cloud Functions, and App Engine, all Google serverless platforms:

  • Cloud Run
  • Cloud Functions
  • App Engine

Cloud Build

Cloud Build is a service that executes your builds on Google Cloud infrastructure. Cloud Build can import source code from Cloud Storage, Cloud Source Repositories, GitHub, or Bitbucket, execute a build to your specifications, and produce artifacts such as Docker containers.

Cloud Build executes your build as a series of build steps, where each build step is run in a Docker container. A build step can do anything that a container can do irrespective of the environment. For more information, see Cloud Build documentation.

Cloud Run

Cloud Run is a fully managed compute platform that automatically scales your stateless containers. Cloud Run is serverless; it abstracts away all infrastructure management, so you can focus on what matters most—building great applications.

Architecture

When you deploy your sample Go app, Google Cloud Data Drive, to Cloud Run, the data flow architecture looks like this:

9dd43a1b95d95ae3.png

Cloud Functions

Cloud Functions is Google Cloud's event-driven serverless compute platform. Because Go compiles to a machine code binary, has no dependent frameworks to start, and does not require an interpreter, Go cold start time is between 80 and 1400ms. This means that the applications and services can remain dormant without costing anything, and then startup and start cold serving traffic in 1400ms or less. After this initial start, the function serves traffic instantly. This factor alone makes Go an ideal language for a Cloud Functions deployment.

Architecture

When you deploy your sample Go app, Google Cloud Data Drive, to Cloud Functions, the data flow architecture looks like this:

266205f591e04324.png

App Engine

The App Engine standard environment is based on container instances running on Google's infrastructure. Containers are preconfigured with one of several available runtimes.

Architecture

When you deploy your sample Go app, Google Cloud Data Drive, to App Engine, the data flow architecture looks like this:

fd42d221ad13c088.png

Google Cloud Data Drive source code

In this lab you deploy a simple app called Google Cloud Data Drive. Google developed and open sourced this app to extract data from Google Cloud quickly. The Google Cloud Data Drive app is one of a series of tools that demonstrates effective usage patterns for using Cloud API's and services.

The Google Cloud Data Drive Go app exposes a simple composable URL path to retrieve data in JSON format from supported Google Cloud data platforms. The application currently supports BigQuery and Firestore, but has a modular design that can support any number of data sources.

The source code for Google Cloud Data Drive is open sourced and can be found at Google Cloud DIY-Tools repository on GitHub. If you'd like to see additional data platforms, submit a GitHub issue.

These HTTP URL patterns are used to get data from Google Cloud running Google Cloud Data Drive.

  • Firestore :

[SERVICE_URL]/fs/[PROJECT_ID]/[COLLECTION]/[DOCUMENT]

  • BigQuery:

[SERVICE_URL]/bq/[PROJECT_ID]/[DATASET]/[TABLE]

Where:

Parameter

Description

[SERVICE URL]

The base URL for the application from App Engine, Cloud Run, or Cloud Functions. For App Engine this will look like https://[PROJECT ID].appspot.com/.

[PROJECT ID]

The Project ID of the Firestore Collection or BigQuery Dataset you want to access. You find the Project ID in the left panel of your lab.

[COLLECTION]

The Firestore Collection ID (symbols/product)

[DOCUMENT]

The Firestore document you would like to return (symbol)

[DATASET]

The BigQuery Dataset name (publicviews)

[TABLE]

The BigQuery Table name (ca_zip_codes)

Setup and requirements

Qwiklabs setup

Before you click the Start Lab button

Read these instructions. Labs are timed and you cannot pause them. The timer, which starts when you click Start Lab, shows how long Google Cloud resources will be made available to you.

This hands-on lab lets you do the lab activities yourself in a real cloud environment, not in a simulation or demo environment. It does so by giving you new, temporary credentials that you use to sign in and access Google Cloud for the duration of the lab.

To complete this lab, you need:

  • Access to a standard internet browser (Chrome browser recommended).
Note: Use an Incognito or private browser window to run this lab. This prevents any conflicts between your personal account and the Student account, which may cause extra charges incurred to your personal account.
  • Time to complete the lab---remember, once you start, you cannot pause a lab.
Note: If you already have your own personal Google Cloud account or project, do not use it for this lab to avoid extra charges to your account.

Cloud Console

How to start your lab and sign in to the Google Cloud Console

  1. Click the Start Lab button. If you need to pay for the lab, a pop-up opens for you to select your payment method. On the left is the Lab Details panel with the following:

    • The Open Google Console button
    • Time remaining
    • The temporary credentials that you must use for this lab
    • Other information, if needed, to step through this lab
  2. Click Open Google Console. The lab spins up resources, and then opens another tab that shows the Sign in page.

    Tip: Arrange the tabs in separate windows, side-by-side.

    Note: If you see the Choose an account dialog, click Use Another Account.
  3. If necessary, copy the Username from the Lab Details panel and paste it into the Sign in dialog. Click Next.

  4. Copy the Password from the Lab Details panel and paste it into the Welcome dialog. Click Next.

    Important: You must use the credentials from the left panel. Do not use your Google Cloud Skills Boost credentials. Note: Using your own Google Cloud account for this lab may incur extra charges.
  5. Click through the subsequent pages:

    • Accept the terms and conditions.
    • Do not add recovery options or two-factor authentication (because this is a temporary account).
    • Do not sign up for free trials.

After a few moments, the Cloud Console opens in this tab.

Note: You can view the menu with a list of Google Cloud Products and Services by clicking the Navigation menu at the top-left. Navigation menu icon

Activate Cloud Shell

Cloud Shell is a virtual machine that is loaded with development tools. It offers a persistent 5GB home directory and runs on the Google Cloud. Cloud Shell provides command-line access to your Google Cloud resources.

  1. Click Activate Cloud Shell Activate Cloud Shell icon at the top of the Google Cloud console.

  2. Click Continue.

It takes a few moments to provision and connect to the environment. When you are connected, you are already authenticated, and the project is set to your PROJECT_ID. The output contains a line that declares the PROJECT_ID for this session:

Your Cloud Platform project in this session is set to YOUR_PROJECT_ID

gcloud is the command-line tool for Google Cloud. It comes pre-installed on Cloud Shell and supports tab-completion.

  1. (Optional) You can list the active account name with this command:

gcloud auth list

Output:

ACTIVE: * ACCOUNT: student-01-xxxxxxxxxxxx@qwiklabs.net To set the active account, run: $ gcloud config set account `ACCOUNT`
  1. (Optional) You can list the project ID with this command:

gcloud config list project

Output:

[core] project = <project_ID>

Example output:

[core] project = qwiklabs-gcp-44776a13dea667a6 Note: For full documentation of gcloud, in Google Cloud, refer to the gcloud CLI overview guide.

Setup your environment

  1. In Cloud Shell, enter the following command to create an environment variable to store the Project ID to use later in this lab:

export PROJECT_ID=$(gcloud info --format="value(config.project)")
  1. Get the sample code for this lab by cloning the sample repository:

git clone https://github.com/GoogleCloudPlatform/DIY-Tools.git

Prepare your Databases

This lab uses sample data in BigQuery and Firestore to test your Go app.

BigQuery Database

BigQuery is a serverless, future proof data warehouse with numerous features for machine learning, data partitioning, and segmentation. This lets you analyze gigabytes to petabytes of data using ANSI SQL at blazing-fast speeds, and with zero operational overhead.

The BigQuery dataset is a view of California zip codes and was created for you when the lab started.

Firestore Database

Firestore, is a serverless document database, with super fast document lookup and real-time eventing features. It is also capable of a 99.999% SLA. To use data in Firestore to test your app, you must initialize Firestore in native mode and then import the sample data.

Create a new Firestore native mode database instance.

  1. In the Cloud Console, click Navigation menu > Firestore > Data to open Firestore in the Console.

3b657f6cf3326847.png

  1. Click Select Native Mode to set the Firestore mode to Native.
  2. In Select a location, scroll down and select us-east1 (South Carolina) to set where to store your data.
  3. Click Create Database.

Wait for the Firestore Database instance to initialize. This process also initializes App Engine in the same region, which allows you to deploy the application to App Engine without first creating an App Engine instance.

  1. When your database is ready, return to Cloud Shell and launch a Firestore import job that provides sample Firestore data for the lab:

gcloud firestore import gs://$PROJECT_ID-firestore/prd-back

This import job loads a Cloud Firestore backup of a collection called symbols into the $PROJECT_ID-firestore storage bucket.

This import job takes up to 5 minutes to complete. Start the next section while you wait.

Check Firestore Database Deployment

Configure permissions for Cloud Build

Cloud Build is a service that executes your builds on Google Cloud infrastructure. By default, Cloud Build does not have sufficient permissions to deploy applications to App Engine, Cloud Run, or Cloud Functions services. You must enable these services before you can use Cloud Build to deploy the Google Cloud Data Drive app.

  1. In the Console, click Navigation menu > Cloud Build > Settings.
  2. Set the Status for Cloud Functions to Enable.

19faf6d28f95e171.png

  1. When prompted, click Grant access to All Service Accounts.
  2. In addition to Cloud Functions, set the Status for Cloud Run and App Engine to Enable.
Check Cloud Build Permissions

Deploy to Cloud Run

Google Cloud Run is very similar to App Engine standard environment, except that Cloud Run allows you to bring your own container (BYOC). For the Google Cloud Data Drive app, you supply a Dockerfile that creates a Docker container, and then deploy that container to Cloud Run.

Review the Dockerfile

Go is an excellent language to write apps for deployment on container platforms. The only item included in the container is the Go compiled binary. In the below example you can see we use a base container called distroless/static. This base container is built from scratch and contains only public certificate roots and timezone file information. The Go binary is injected and registered as a start command (see the last line of the Dockerfile below). There are no additional frameworks included or needed. This type of container construction creates the smallest container and security footprint possible and makes the container extremely portable to GKE, Anthos, and on premise hosting solutions.

Have a look at the Dockerfile code that builds the container below:

# Use the official Golang image to create a build artifact. # This is based on Debian and sets the GOPATH to /go. # https://hub.docker.com/_/golang FROM golang:1.13 as builder # Create and change to the app directory. WORKDIR /app # Retrieve application dependencies. # This allows the container build to reuse cached dependencies. COPY go.* ./ RUN go mod download # Copy local code to the container image. COPY . ./ WORKDIR /app/cmd/webserver # Build the binary. RUN GO111MODULE=on CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -mod=readonly -v -o gcp-data-drive # Use the Google Distroless image for a minimal container. FROM gcr.io/distroless/static # Copy the binary to the production image from the builder stage. COPY --from=builder /app/cmd/webserver/gcp-data-drive /gcp-data-drive # Run the web service on container startup. CMD ["/gcp-data-drive"]

Click here to view the Dockerfile on GitHub.

Review the Cloud Build YAML config file

The Cloud Build YAML file, DIY-Tools/gcp-data-drive/cloudbuild_run.yaml, shown below contains the Cloud Build step definitions that deploy your application to Cloud Run. You use this file to deploy the application to Cloud Run.

The first step executes the git command to clone the source repository that contains the application. This step is parameterized to allow you to easily switch between application branches.

The second step executes the gcloud builds submit command to use Cloud Build to create a container containing the compiled application using the steps contained in the Dockerfile. The container is then saved to gcr.io

The third step deploys the application container image from gcr.io to Cloud Run in the us-central1 region.

You could build the container yourself and manually deploy this app using gcloud run deploy, but Cloud Build allows you to offload this to Google infrastructure. The Google Cloud Build system is a core component of an automated CI/CD system because it allows you to listen to commit events with tag filters.These features come together to create an automated pipeline from developers committed to lifecycle deployment in a consistent and reliable way.

steps: - name: 'gcr.io/cloud-builders/git' args: ['clone','--single-branch','--branch', '${_GIT_SOURCE_BRANCH}','${_GIT_SOURCE_URL}'] - name: 'gcr.io/cloud-builders/gcloud'and I args: ['builds','submit', '--tag','gcr.io/$PROJECT_ID/gcp-data-drive'] dir: 'DIY-Tools/gcp-data-drive' - name: 'gcr.io/cloud-builders/gcloud' args: ['run','deploy','gcp-data-drive', '--image','gcr.io/$PROJECT_ID/gcp-data-drive', '--platform','managed', '--region','us-central1', '--allow-unauthenticated'] dir: 'DIY-Tools/gcp-data-drive'

Click here to view the steps in cloudbuild_run.yaml on GitHub.

Check the import process

Look in Cloud Shell to see if the import process loading the data into Filestore has finished. When it completes, continue to the next section to deploy the Google Cloud Data Drive app.

Deploy the Google Cloud Data Drive app

  1. In Cloud Shell, change to the directory for the application that you cloned from GitHub.

cd ~/DIY-Tools/gcp-data-drive
  1. Deploy the Google Cloud Data Drive app to Cloud Run with Cloud Build:

gcloud builds submit --config cloudbuild_run.yaml \ --project $PROJECT_ID --no-source \ --substitutions=_GIT_SOURCE_BRANCH="master",_GIT_SOURCE_URL="https://github.com/GoogleCloudPlatform/DIY-Tools"

The deployment takes a few minutes and you may see some red text in the console. These are not failure logs.

  1. Store the Cloud Run service URL in an environment variable:

export CLOUD_RUN_SERVICE_URL=$(gcloud run services --platform managed describe gcp-data-drive --region us-central1 --format="value(status.url)")
  1. Use curl to call the application to query data from the Firestore symbols collection in your project:

curl $CLOUD_RUN_SERVICE_URL/fs/$PROJECT_ID/symbols/product/symbol If you get an authentication error, wait a minute and retry the previous curl command.

This responds with the contents of a JSON file containing the values from the symbols collection in your project, which looks similar to this: 443061c6423391f3.png

  1. Use curl to call the application to query data from the BigQuery publicviews.ca_zip_codes table in your lab project:

curl $CLOUD_RUN_SERVICE_URL/bq/$PROJECT_ID/publicviews/ca_zip_codes

This responds with the contents of a JSON file containing the results of the BigQuery SQL statement SELECT * FROM publicviews.ca_zip_codes;, which looks similar to this:

7d2cc3dce8351b81.png

Go is a great language for use on Cloud Run mainly because of its portability and compile size. Even though Go is a statically typed compiled language, you can effectively access different data platforms in a modular way. Look at the details of the application container for this Go App.

Check Cloud Run application Deployment

Take a closer look at the container

  1. In the Cloud Console, click Navigation menu > Cloud Run.
  2. Click gcp-data-drive in the services list.

307f81d542207cce.png

  1. Click the Revisions tab.

248bbf62aa4a6a57.png

  1. In the right panel, in the Container tab, click the Image URL.

The Container pane includes the URL for the Container image to examine the image in the Container Registry. ImageURL1.png

The Container Registry opens in a new browser tab at the Image details window.

ImageDetails2.png

As you can see from the virtual size, the container is small as it only contains the Go binary, which gives it the smallest security attack service possible. Go containers also make great Anthos services because they are small and easily portable across CPU and OS types. This makes them easily transferable from Cloud to on premise platforms, and vice versa.

Deploy to Cloud Functions

Cloud Functions is Google Cloud's event-driven serverless compute platform. When you combine Go and Cloud Functions, you get the best serverless has to offer in terms of fast spin up times and infinite scale so your application can have the best event driven response times possible.

Have a look at the source code and see how to reuse the Google Cloud Data Drive source code in a Cloud Function.

Review the main function

At the start of the main function in DIY-Tools/gcp-data-drive/cmd/webserver/main.go, you tell the web server to send all HTTP requests to the gcpdatadrive.GetJSONData Go function.

func main() { // Register the initial HTTP handler. http.HandleFunc("/", gcpdatadrive.GetJSONData) port := os.Getenv("PORT") ...

Click here to view the main function in main.go on GitHub.

In a Cloud Function, the main.go is not used, instead the Cloud Function runtime is configured to send HTTP requests directly to the gcpdatadrive.GetJSONData Go function that is defined in the DIY-Tools/gcp-data-drive/gcpdatadrive.go file.

You can see how this is done by looking at how the Google Cloud Data Drive application is deployed to Cloud Functions using Cloud Build with cloudbuild_gcf.yaml:

a4961f3ba3ab2bb9.png Click here to view cloudbuild_gcf.yaml on GitHub.

These Cloud Build steps are also similar to those used to deploy the application to Cloud Run, but in this case, you deploy the application to Cloud Functions using the gcloud functions deploy command. Note that the Cloud Functions --entrypoint parameter is used to specify the GetJSONData function and not the main function in the main Go package that is used when it is deployed to App Engine or Cloud Run.

Deploy the Google Cloud Data Drive app

  1. Still in DIY-Tools/gcp-data-drive, deploy to Cloud Functions with Cloud Build:

gcloud builds submit --config cloudbuild_gcf.yaml \ --project $PROJECT_ID --no-source \ --substitutions=_GIT_SOURCE_BRANCH="master",_GIT_SOURCE_URL="https://github.com/GoogleCloudPlatform/DIY-Tools"
  1. Enter the following command to allow unauthorized access to the Google Cloud Data Drive Cloud Function:

gcloud alpha functions add-iam-policy-binding gcp-data-drive --member=allUsers --role=roles/cloudfunctions.invoker
  1. Store the Cloud Functions HTTP Trigger URL in an environment variable:

export CF_TRIGGER_URL=$(gcloud functions describe gcp-data-drive --format="value(httpsTrigger.url)")
  1. Use curl to call the application to query data from the Firestore symbols collection in your project:

curl $CF_TRIGGER_URL/fs/$PROJECT_ID/symbols/product/symbol

This responds with the contents of a JSON file containing the values from the symbols collection in your project .

  1. Use curl to call the application to query data from the BigQuery publicviews.ca_zip_codes table in your lab project:

curl $CF_TRIGGER_URL/bq/$PROJECT_ID/publicviews/ca_zip_codes

This responds with the contents of a JSON file containing the results of the BigQuery SQL statement SELECT * FROM publicviews.ca_zip_codes;.

Check Cloud Functions application Deployment

Additional Cloud Functions Triggers

Cloud Functions has an event driven architecture. The app you deployed uses an HTTP request as an event. Explore the code of another Go app that takes in a different event type. The function is triggered on a Firestore write event.

The Go source code below is adapted from this example.

package mygopackage import ( "context" "fmt" "log" "time" "cloud.google.com/go/functions/metadata" ) // FirestoreEvent is the payload of a Firestore event. type FirestoreEvent struct { OldValue FirestoreValue `json:"oldValue"` Value FirestoreValue `json:"value"` UpdateMask struct { FieldPaths []string `json:"fieldPaths"` } `json:"updateMask"` } // FirestoreValue holds Firestore fields. type FirestoreValue struct { CreateTime time.Time `json:"createTime"` Fields interface{} `json:"fields"` Name string `json:"name"` UpdateTime time.Time `json:"updateTime"` } // DoSomeThingOnWrite is triggered by // a change to a Firestore document. func DoSomeThingOnWrite(ctx context.Context, e FirestoreEvent) error { meta, err := metadata.FromContext(ctx) if err != nil { return fmt.Errorf("metadata.FromContext: %v", err) } // The variables e and meta contain // the information from the event // so now we can Go do some logic // work with the data. In this case // we are simply writing it to the log. log.Printf("Function triggered by change to: %v", meta.Resource) log.Printf("Old value: %+v", e.OldValue) log.Printf("New value: %+v", e.Value) return nil }

Click here to view the example source code on GitHub.

This example contains code that can be used to deploy Cloud Functions that handle Firestore events, instead of the HTTP request trigger used in the lab sample application. You register this function with a Cloud Firestore event trigger using DoSomeThingOnWrite as the Cloud Functions entrypoint.

Cloud Functions currently support the following event triggers.

5512666380344a54.png

The example above is a simple case, but you can imagine the potential. Simple Go Cloud Functions do tasks that used to come with the burden of managing an operating system. For example, you can use a function like this to run Data Loss Prevention (DLP) to sanitize data when a customer writes something to Cloud Firestore via a mobile app. The Cloud Function could rewrite a summary report to Firestore for web consumption based on a pub/sub event. Any number of small processes that are event based are good candidates for Go Cloud Functions. Best of all, there are zero servers to patch.

Deploy to App Engine

App Engine is well suited for running Go applications. App Engine is a serverless compute platform that is fully managed to scale up and down as workloads fluctuate. Go applications are compiled to a single binary executable file during deployment. Go cold startup times for applications are often between 80 and 1400 in milliseconds and when running, App Engine can horizontally scale to meet the most demanding global scale workloads in seconds.

Review the Cloud Build YAML config file

The Cloud Build YAML file, DIY-Tools/gcp-data-drive/cloudbuild_appengine.yaml, shown below contains the Cloud Build step definitions that deploy your application to App Engine. You use this file to deploy the application to App Engine.

The first step executes the git command to clone the source repository that contains the application. This step is parameterized to allow you to easily switch between application branches.

The second step executes the gcloud app deploy command to deploy the application to App Engine.

As with the other examples, you could manually deploy this app using gcloud app deploy, but Cloud Build allows you to offload this to Google infrastructure, for example if you want to create a serverless CI/CD pipeline.

steps: - name: 'gcr.io/cloud-builders/git' args: ['clone','--single-branch','--branch', '${_GIT_SOURCE_BRANCH}','${_GIT_SOURCE_URL}'] - name: 'gcr.io/cloud-builders/gcloud' args: ['app','deploy','app.yaml','--project','$PROJECT_ID'] dir: 'DIY-Tools/gcp-data-drive/cmd/webserver'

Click here to view cloudbuild_appengine.yaml on GitHub.

Deploy the Google Cloud Data Drive app

  1. Still in DIY-Tools/gcp-data-drive, deploy the Go webserver app to App Engine using Cloud Build:

gcloud builds submit --config cloudbuild_appengine.yaml \ --project $PROJECT_ID --no-source \ --substitutions=_GIT_SOURCE_BRANCH="master",_GIT_SOURCE_URL="https://github.com/GoogleCloudPlatform/DIY-Tools"

Deployment takes a few minutes to complete.

  1. Store the App Engine URL in an environment variable to use in the command to call the app:
The App Engine URL is the target url in the output. export TARGET_URL=https://$(gcloud app describe --format="value(defaultHostname)")
  1. Use curl to call the application running on App Engine to query data from Firestore:

curl $TARGET_URL/fs/$PROJECT_ID/symbols/product/symbol

This responds with the contents of a JSON file containing three values from the symbols collection in your project.

  1. Use curl to call the app running on App Engine to query data from BigQuery:

curl $TARGET_URL/bq/$PROJECT_ID/publicviews/ca_zip_codes

This responds with the contents of a JSON file containing the results of the BigQuery SQL statement SELECT * FROM publicviews.ca_zip_codes;.

Increase the load

Increase the load to see what happens.

  1. Use the nano editor to create a simple shell script to put some load on the application:

nano loadgen.sh
  1. Type or paste the following script into the editor:

#!/bin/bash for ((i=1;i<=1000;i++)); do curl $TARGET_URL/bq/$PROJECT_ID/publicviews/ca_zip_codes > /dev/null & done
  1. Press Ctrl+X, Y, and then Enter to save the new file.

  2. Make the script executable.

chmod +x loadgen.sh
  1. Run the load test:

./loadgen.sh
  1. In the Console, click Navigation menu > App Engine > Instances.

The Instances window opens and shows a summary of requests/second and a list of instances spawned when you ran the load test in Cloud Shell. Notice how App Engine automatically created additional app instances and distributed the incoming HTTP traffic.

1c3ba2dc0bbbd96c.png

It may take 3 to 5 minutes for the Summary graph to show data. Don't forget to refresh the Instances window!
  1. In Cloud Shell, press Ctrl+C to end the load test if it is still running.
Check App Engine application Deployment

Congratulations!

In this self-paced lab, you explored how to use the Go programming language to deploy to the all Google Cloud serverless compute platforms. The following are key takeaways:

  • The Go programming language has awesome profitability and efficiency features that make it an excellent fit for modern cloud and on prem applications.
  • The same Go code base can be deployed to all Google Cloud serverless, container based, and Anthos compute platforms without modification.
  • Cloud Build (also serverless) is a key part of a cloud based CI/CD pipeline to provide consistency in delivering to your application lifecycles.
  • Cloud Run, Cloud Functions, and App Engine are simple serverless platforms that operate at Google scale and are easy to deploy to.
  • Google Cloud Data Drive is an open source data extraction library that I can use in my existing Google Cloud environment.

Go_badge.png

Finish your Quest

This self-paced lab is part of the Qwiklabs Getting Started with Go on Google Cloud Quest. A Quest is a series of related labs that form a learning path. Completing this Quest earns you the badge above, to recognize your achievement. You can make your badge (or badges) public and link to them in your online resume or social media account. Enroll in this Quest and get immediate completion credit if you've taken this lab. See other available Qwiklabs Quests.

Take your next lab

Go Code to Work with Google Cloud Data Sources

Next steps/learn more

Google Cloud training and certification

...helps you make the most of Google Cloud technologies. Our classes include technical skills and best practices to help you get up to speed quickly and continue your learning journey. We offer fundamental to advanced level training, with on-demand, live, and virtual options to suit your busy schedule. Certifications help you validate and prove your skill and expertise in Google Cloud technologies.

Manual Last Updated July 21, 2022
Lab Last Tested July 21, 2022

Copyright 2022 Google LLC All rights reserved. Google and the Google logo are trademarks of Google LLC. All other company and product names may be trademarks of the respective companies with which they are associated.