What I learnt today about Google Cloud Platform
Tags: googlecloudplatform
Published: 2019-05-28 09:29:11

---
title: What I learnt today about Google Cloud Platform
published: true
description: 
tags: Google Cloud Platform
---


### Billing

In GCP, virtual machines are billed in one-second intervals. 

The unit per minute cost of a virtual server is based on the characteristics of the server, such as the number of virtual servers, the amount of memory, and the region where you run the virtual machine, influence the cost. Time of day is not a factor nor is the type of application you run on the virtual machine.

You want to estimate the cost of GCP resources you will be using Compute Engine and Kubernetes Engine services  to have information on the virtual machines you will be using. 

The following commands will stop a virtual machine named web-server-1?

~~~
gcloud compute instances stop web-server-1
~~~

`gcloud compute instances`, to indicate you are working with virtual machines, followed by the `stop` command and the name of the VM. 


Your management team is considering 3 different cloud providers. You have been asked to summarize billing and cost information to help the management team compare cost structures between clouds. Which of the following would you mention about the cost of virtual machines in GCP?

VMs are billed in one-second increments, cost varies with the number of CPUs and amount of memory in a machine type, you can create custom machine types, preemptible VMs cost up to 80 percent less than standard VMs, and Google offers discounts for sustained usage.


### Cloud Memorystore  

Cloud Memorystore is the only GCP designed to cache data in memory. Cloud SQL is a relational database service and might be a good option for the backend database. Cloud Spanner is a global relational database and is a good option when you need a globally consistent database. Cloud Datastore is a document database suitable for product catalogs, user profiles, and other semistructured data.

Cloud Memorystore Use Case : Your department is deploying an application that has a database backend. You are concerned about the read load on the database server and want to have data available in memory to reduce the time to respond to queries and to reduce the load on the database server.

### Dataproc

Dataproc is designed to execute workflows in both batch and streaming modes, which makes option A correct. Bigquery is a data warehouse service. Datastore is a document database. AutoML is a machine learning service.

### IAM

Owner, Editor, and Viewer are the three primitive privileges in Google Cloud Platform.

`Identities` are abstractions of users. They can also represent characteristics of processes that run on behalf of a human user or a virtual machine in the GCP. Identities are not related to virtual machine IDs. Roles are collections of privileges that can be granted to identities.

Organization, folders, and projects are the components used to manage an organizational hierarchy. Buckets, directories, and subdirectories are used to organize storage.

### Network

`subnet` is not a parameter to `gcloud` to create a firewall. `source-ranges` is for specifying sources of network traffic the rule applies to.


### gcloud command

Assuming there is a MySQL database running Cloud SQL called ace_exam_mysql to connect to a MySQL database running in Cloud SQL. The command is

~~~
gcloud sql connect ace_exam_mysql --user = root.
~~~

The correct command starts with `gcloud sql` not `gcloud connect`. The term sql is needed to identify the GCP service. A password is not needed on the command line; the user will be prompted for it.

### Stackdriver Logging

To view admin activity, system events, and data access on an App Engine project, Stackdriver Logging service you would use to view audit logs

###  Cloud Function

You want to create a cloud function to transform audio files into different formats. The audio files will be uploaded into Cloud Storage. You want to start transformations as soon as the files finish uploading. Which trigger would you specify in the cloud function to cause it to execute after the file is uploaded?

AnS: `google.storage.object.finalize`

### Deployment 

What parameters of a deployment can be set in the Create Deployment page in Cloud Console?

You can specify container image, cluster name, and application name along with the labels, initial command, and namespace. 

### Monitoring

You have just created a virtual machine, and you'd like to monitor the VM and have an email sent to you whenever the CPU average utilization exceeds 75 percent for five minutes. What do you need to do to the VM to have this happen?

```
Install the monitoring agent on the virtual machine
```

### Security

You are running applications that manage personal information for clients, and you want to take advantage of enhanced security features available to virtual machines in GCP. What option would you enable when creating a VM to get these enhanced security features?

```
Shielded VM is a set of enhanced security mechanisms, including Secure Book, Virtual Trusted Platform Module (vTPM), and Integrity monitoring. Integrity monitoring and secure boot are included with Shield VM and are not enabled separately.
```

### 4 things about Cloud Storage

- Cloud Storage buckets can have retention periods.
- Cloud Storage does not provide block-level access to data within files stored in buckets.
- Cloud Storage is designed for high durability.
- Lifecycle configurations cannot be used to change storage class from regional to multiregional.(Once a bucket is created as regional or multiregional, it cannot be changed to the other) 

### App Engine

You are running a production application in App Engine. You would like to upgrade the application, but you want to minimize the risk of disrupting the service. The best approach is create a new version of the service and route a small subset of traffic to that version and monitor for errors or other issues.  Take advantage of App Engine versions and the ability to split traffic. If there is a problem, you can detect it while exposing a small number of users to the new version. 

### Preemptible virtual machine

Preemptible virtual machines may be shut down at any time, but they will be shut down if they run over 24 hours.


### BigQuery

To get an estimate of the volume of data scanned by BigQuery from the command line, type

~~~
bq --location=[LOCATION] query --use_legacy_sql=false --dry_run [SQL_QUERY]
~~~

The correct bq command structure, which includes `location` and the `--dry_run` option. This option calculates an estimate without actually running the query.

You have received a large data set from an Internet of Things (IoT) system. You want to use BigQuery to analyze the data. What command-line command would you use to make data available for analysis in BigQuery?

~~~
bq load --autodetect --source_format=[FORMAT] [DATASET].[TABLE] [PATH_TO_SOURCE]
~~~

The autodetect and source_format parameters and path to source are correctly specified in all options. 

A client asks for recommendations for deploying a data warehouse in GCP. The client wants to minimize the amount of time spent on systems administration. Most of the analysts using the data warehouse know Microsoft Excel, SQL, and Python. They want the data warehouse infrastructure to grow as needed without having a database administrator modifying database configurations. What GCP services would I recommend?

BigQuery is a data warehouse and analytic database managed service that minimizes administration overhead. There is no need to configure storage; that is managed by Google. BigQuery uses SQL as a query language. Cloud Storage is an object storage system and not suitable for data warehouses. Datastore is an object store and not suitable for analyzing with SQL. Bigtable is not appropriate for large, analytic queries like those found in data warehouse. Bigtable does not support SQL.

### Stackdriver

What Stackdriver service is best for identifying bottlenecks in your application code?

- Cloud Trace is a distributed tracing application that provides details on how long different parts of code run 

- Monitoring is used to notify DevOps engineers when resources are not functioning as expected. 

- Logging is for collecting, storing, and viewing log data, and although log entries might help diagnose bottlenecks, it is not specifically designed for that.

- Debug is used to generate snapshot and inject logpoints.