Prepare and test your skills
Prepare and test your skills
Integrating applications with data and storage services means connecting application code to the right Google Cloud datastore through secure, low-latency paths. Traffic flows from the application to datastores such as Cloud SQL (opens in a new tab), Firestore, Cloud Storage (opens in a new tab), Spanner (opens in a new tab), and Memorystore for Redis through authenticated and encrypted connections. Caching, replication, and resilient connection patterns protect performance and availability when downstream storage slows or fails.
Cloud Storage is low-cost object storage that holds any amount of data as buckets containing objects. Access to buckets and objects is controlled by Identity and Access Management (IAM) and access control lists (ACLs), and IAM is recommended in most cases because it grants permissions at bucket and project levels. Granular control uses IAM roles for users, groups, or service accounts, IAM policies with conditions, and principal access boundary policies that limit what a principal can reach.
Data is encrypted by default with Google-owned keys, with customer-managed encryption keys (CMEKs) in Cloud Key Management Service (Cloud KMS) or customer-supplied keys for more control. Sensitive Data Protection can discover, classify, and de-identify sensitive data loaded through buckets. Data residency is controlled by bucket location, because data is stored or replicated only inside the specified regions. Regional buckets replicate synchronously across zones in one region, while dual-region and multi-region buckets replicate asynchronously across regions for higher availability.
Exam tip: Use IAM, not ACLs, for Cloud Storage bucket and project-level access; regional buckets replicate synchronously across zones, while dual-region and multi-region buckets replicate asynchronously across regions.
Database choice constrains consistency, availability, and scalability, so different services often use different database types. Relational databases provide transactions, strong consistency, referential integrity, and sophisticated queries across tables, but they are typically hard to scale and need careful high-availability management. Non-relational (NoSQL) databases often sacrifice some relational features for higher availability and easier scalability, often choosing availability over consistency.
Spanner is a strongly consistent, highly available, and globally distributed database with SQL support that combines relational querying with global scale:
| Option | Consistency model | Availability and scale tradeoff |
|---|---|---|
| Relational database | Strong consistency with transactions | Hard to scale, needs careful high-availability management |
| NoSQL database | Often eventually consistent | Higher availability and easier scalability |
| Spanner | Strongly consistent with SQL support | Highly available and globally distributed |
Choose a relational database when transactions and strong consistency are required, choose NoSQL when the model can be eventually consistent and needs scale, and use both strategically when services have different needs.
Memorystore for Redis is a fully managed in-memory cache that provides low-latency access and high throughput for heavily accessed data. The cache sits between the application and slower disk-based storage, so requests flow from the application to the cache first and reach the downstream database only on a cache miss. This placement reduces storage latency, reduces load on downstream databases, and helps consumers scale further. Memorystore for Redis supports high availability with cross-zone replication and automatic failover, and cached data can continue to serve traffic during overload or outage even if results are incomplete or stale.
High availability also depends on where data is replicated. AlloyDB for PostgreSQL clusters provide high availability by default with a primary instance using redundant nodes in two zones plus cross-region replication for regional outages. BigQuery datasets store data synchronously in two zones in the specified region. Place compute and data in the same region when latency matters, and choose dual-region, multi-region, or cross-region replication when the workload must survive a regional outage. Resilient connections protect datastore links with circuit breaker that stops traffic to a failing service, exponential backoff that retries with increasing delays, and graceful degradation that returns limited or cached results.
Secure connectivity for relational databases means applications reach Cloud SQL and AlloyDB for PostgreSQL through verified identities and encrypted paths. Traffic flows from the application to a local proxy or connector, and from that proxy to the database instance over an authorized encrypted tunnel. The Cloud SQL Auth Proxy is a client-side proxy that must authenticate as a Cloud SQL IAM identity, and a dedicated service account is recommended for production. The proxy must run continuously with the same uptime as the application, because if the proxy stops all existing connections drop and no new connections can be created.
IAM permissions determine whether the proxy identity can open connections. The proxy service account must have a role that includes cloudsql.instances.connect, using Cloud SQL Client for connectivity, Cloud SQL Editor for broader management, or Cloud SQL Admin for full administration. Private paths and encryption protect data in transit through TLS upgrades, mutual TLS with client certificates, Serverless VPC Access for Cloud Run, and Private Service Connect or private services access for another VPC. Additional controls include VPC Service Controls perimeters, Shared VPC networking, and Cloud VPN or Cloud Interconnect links. For login, built-in authentication uses database usernames and passwords that require rotation, while IAM authentication uses Google identities with short-lived tokens and centralizes control in IAM.
Programmatic access for Firestore in Datastore mode uses client libraries and the Datastore Data API with GQL for daily reads and writes, while managed export and import uses the console, Google Cloud CLI, and Datastore Admin API. Export output flows from Firestore in Datastore mode to a Cloud Storage bucket in LevelDB log format, and import reverses that path from bucket objects back into the database. Exports use eventually consistent reads, do not contain indexes, and imports reuse exported entity IDs and overwrite matching entities.
Authorization is split between two identities on different sides of the trust boundary. The caller user account or service account starts the operation and needs datastore.databases.export or datastore.databases.import. The Firestore service agent named service-PROJECT_NUMBER@gcp-sa-firestore.iam.gserviceaccount.com reads and writes export files in the bucket, including cross-project buckets. Reliable setup follows an ordered sequence: first enable billing, then create the bucket in the same location as the database, then grant caller IAM, then grant service-agent bucket access. Operational limits allow 50 concurrent exports and imports per project and 20 requests per minute.
The handover pattern is an architecture where workloads in a private environment or another cloud upload data to shared storage for Google Cloud workloads to consume. Data flows from the private environment to Cloud Storage buckets or Pub/Sub topics, and then from that shared storage to workloads in an application Virtual Private Cloud (VPC) for processing and frontend use. Frontend applications are exposed through Cloud Load Balancing or API Gateway, so virtual machine instances are not directly reachable from the internet. Private connectivity with VPN, Cloud Interconnect, or Cross-Cloud Interconnect is preferred for sustained or sensitive transfers, while public paths may fit temporary or low-volume use.
Cloud Storage bucket location types control replication for resilience and speed:
| Bucket type | Replication behavior | Choose when |
|---|---|---|
| Regional bucket | Replicated synchronously across zones in the region | Low-cost, zone-redundant durability is needed |
| Dual-region bucket | Stored in two locations with turbo replication for 15-minute recovery point objective | Higher availability across two regions is needed |
| Multi-region bucket | Stored in at least two locations | Broad geographic availability is needed |
For block and file needs, Google Cloud Hyperdisk provisions IOPS and throughput separately, Filestore regional instances replicate synchronously across three zones, and regional Persistent Disk volumes replicate synchronously across two zones.
Fine-grained access is enforced with IAM roles at bucket, project, folder, or organization level, and applications authenticate with service accounts rather than shared user credentials. Group-based access stays correct during join, move, and leave events because membership changes update access without rewriting policies. Least privilege is maintained with the IAM recommender, conditional role bindings, group membership expiration, and organization policy constraints that limit where resources can be created.
VPC Service Controls restricts access and reduces exfiltration risk by creating a service perimeter at the project or VPC network level that defines the virtual boundaries from which a service can be accessed. The perimeter can extend to hybrid environments over VPN or Interconnect and can restrict Cloud SQL import and export so data stays in chosen locations. Residency is controlled with Pub/Sub message storage policies and regional bucket locations. Encryption is automatic at rest and in transit, with CMEK options using keys in Cloud KMS, Cloud HSM, or Cloud External Key Manager outside Google infrastructure.
Cloud SQL is a fully managed relational service with MySQL, PostgreSQL, and SQL Server engines for online transaction processing, with Enterprise Plus adding 99.99% availability, intelligent caching, 35 days of log retention, and advanced disaster recovery. Spanner uses GoogleSQL with query statements that return rows, Data Definition Language statements that create tables and roles, Data Manipulation Language statements that insert and update rows, Data Access Control statements that grant privileges, and Transaction Control statements that manage transactions. Spanner applies strong consistency so a read after a committed write sees current data, and commit timestamps support incremental backup.
NoSQL operations with Firestore in Datastore mode use kinds containing entities with properties and keys, where all queries are served by previously built indexes so performance scales with result size. Datastore does not support joins, inequality filtering on multiple properties, or subquery filtering. Backup and recovery move data from the live database to Cloud Storage and back during restore, with Cloud SQL point-in-time recovery to a fresh instance, Spanner Backup and Restore retaining backups up to 1 year with lower recovery time than Avro export, and Spanner and BigQuery point-in-time recovery covering up to 7 days. Loading into BigQuery follows an ordered sequence: first extract source data to Avro, ORC, Parquet, or CSV files, then copy files to a bucket with Storage Transfer Service or Google Cloud CLI, then load bucket data into BigQuery tables with APPEND for incremental loads or truncate to replace data.
Pub/Sub is an asynchronous and scalable messaging service that decouples publishers from subscribers, typically with latency around 100 milliseconds. A Pub/Sub data flow moves data from publishers to a topic and then from the topic to subscriptions that feed subscribers. Each subscription receives its own copy of each message, so publishers and subscribers scale separately. Pub/Sub provides at-least-once delivery with best-effort ordering and uses per-message parallelism by leasing individual messages and tracking acknowledgment.
A subscription defines how messages travel using push delivery where Pub/Sub sends HTTP POST requests to an endpoint, pull delivery where subscribers request messages over StreamingPull, or export delivery that stores messages directly to BigQuery without Dataflow. Published messages must contain data, attributes, or an ordering key, are limited to 10 MB, and larger payloads are handled by storing the object in Cloud Storage and publishing only the URL. Reliability depends on the acknowledgment lifecycle: first Pub/Sub leases a message and starts the deadline, then the subscriber processes it and can extend the lease, then the subscriber acknowledges on success or negatively acknowledges for immediate redelivery, then Pub/Sub discards or redelivers it. A dead-letter topic stores messages that exhaust retry attempts, ordering keys preserve publish order when enabled on the subscription, and idempotent subscribers tolerate duplicates.
Publish-subscribe shapes describe how work is shared. Fan-in sends many publishers through one topic and subscription to one subscriber, load-balanced sharing sends one topic and subscription to many subscribers where each receives a different subset, and fan-out sends one topic to many subscriptions where every subscription receives the same messages. Cloud Tasks manages asynchronous execution outside the user request path by queuing tasks and delivering them to handlers at a controlled rate. App Engine provides a default push queue, supports up to 100 queues with configurable rate and target, uses a token bucket to control dequeue rate, and treats HTTP-target tasks as regular HTTP traffic while legacy and App Engine tasks wait at lower priority during heavy traffic.
Continue with this study guide: Integrating applications with data and storage services
Consuming Google Cloud APIs means enabling services in a project, choosing how code calls them, and authenticating with the correct identity. Each Cloud API runs as a network service on subdomains of googleapis.com and accepts only secure requests using Transport Layer Security (TLS). A project is the isolation boundary for quota and billing, so activation, limits, and charges are tracked per project.
Enabling Google Cloud services means changing an API from disabled to enabled inside one project so applications in that project can consume it. The Service Usage API (opens in a new tab) is the control system that manages this lifecycle, and both the console and gcloud send enable requests to it. Activation requires the serviceusage.services.enable permission, which is included in the Owner role and Service Usage Admin role. The access flow runs from administrator to user to project: the administrator grants the role, and the user then enables the service for that project.
Enabling a service does not grant permission to use it. After activation the caller still needs service-specific roles, such as Compute Network Admin, Dataflow Admin and Worker, Pub/Sub Admin, Storage Admin, Secret Manager Accessor, or Logs Viewer. Activation can also create the Compute Engine default service account, which may receive broad Editor access depending on organization policy. Production workloads should use a dedicated service account with minimum roles and control automatic grants with the iam.automaticIamGrantsForDefaultServiceAccounts constraint.
Exam tip: Enabling an API does not grant permission to use it — serviceusage.services.enable only turns the service on, and Compute Engine, Pub/Sub, or Dataflow still require their own roles.
Quota management and billing explain how an enabled service consumes limited capacity and how use is paid for. Each project owns resources such as API keys, service accounts, virtual machines, buckets, and datasets, and usage telemetry is grouped by project. When an application calls an API, the project that owns the credentials is the client project and the project that owns the target resource is the resource project. Current limits can be checked on the Quotas and System Limits page, where the value shows default quota unless adjusted, and a quota adjustment changes that value subject to review.
A project needs an active billing account linked to it before chargeable APIs can be used, and disabling unused APIs reduces misuse and accidental charges. API dependencies exist when one solution cannot run unless several related APIs are enabled together in the same project. Dataflow depends on Compute Engine, Pub/Sub, Cloud Storage, BigQuery, Logging, and Resource Manager, while other bundles include Cloud Deploy with Cloud Build and Google Kubernetes Engine, and Eventarc with Artifact Registry and Cloud Run. The two interactive activation methods fit different workflows: the console uses an enable-flow link for guided setup, while gcloud uses gcloud services enable with full endpoint names for repeatable scripting.
API communication interfaces are the different ways application code reaches a Cloud API endpoint. The Cloud Client Libraries (opens in a new tab) are the recommended option where available because they provide idiomatic methods, handle authentication and TLS, and often use remote procedure call efficiency under the hood. They are available for Go, Java, Node.js, Python, Ruby, Rust, PHP, C#, and C++ through familiar package managers. Google APIs Explorer is a no-code browser tool for trying live APIs, where trial traffic flows from the Explorer to the live endpoint to confirm request structure before implementing code.
Other interfaces reach the same backends with different trade-offs:
| Option | Interface reached | Language and code fit |
|---|---|---|
| Cloud Client Libraries | REST, plus RPC under the hood for some APIs | Idiomatic, consistent style across languages |
| Google API Client Libraries | REST only, gRPC is not supported | Auto-generated and less idiomatic |
| Custom REST code | JSON over HTTP | Works wherever HTTP is available; developer manages auth and TLS |
| Custom gRPC code | Protobuf over HTTP2 to RPC interface | Generated code with up to 10x throughput per CPU versus JSON REST |
All Cloud APIs expose a JSON/REST interface, but only gRPC-enabled APIs expose an RPC interface.
Optimization of data transfer reduces network overhead, latency, and quota use. Each HTTP request carries connection and authentication costs, so batching multiple smaller calls into fewer larger calls lowers latency and consumes less rate quota. Restricting return data with field masks keeps responses small, while pagination returns large datasets in pages controlled by tokens where the client requests one page and uses the returned token for the next page. Connectivity choices include Cloud Interconnect for private production availability, Cross-Cloud Interconnect for another cloud, and CDN Interconnect for large third-party transfers. Autoscaling then matches capacity to load through managed instance groups, Google Kubernetes Engine node pools, Cloud Run scale-to-zero, and Bigtable node adjustments.
Resilience and performance keep applications responsive when dependencies fail. Circuit breaker stops sending requests to a failing service, exponential backoff retries after increasingly longer waits, and graceful degradation returns a limited but useful response. Caching stores reusable answers close to the requester so later requests do not travel to the backend:
Cloud Load Balancing distributes traffic only to backends with available capacity, and health checks ensure traffic flows only to responsive backends.
Using service accounts to make Cloud API calls means running code under a managed machine identity limited by IAM roles plus access scopes. A service account is the identity an application uses to call APIs, and both configurations must allow access before OAuth requests from gcloud and client libraries can reach the resource. An IAM role is set on the service account and defines which APIs and resources it can access, while an access scope is set on the virtual machine instance for its lifetime and defines which OAuth scopes local tools can request.
The best practice is to set the full cloud-platform scope on the virtual machine and enforce least privilege with fine-grained IAM roles. A broad scope plus roles/storage.objectViewer can only read objects, while a narrow read-only scope plus a broad admin role still cannot write from client libraries because the scope blocks it. Secure credential management prefers short-lived credentials that expire after 1 hour over user-managed service account keys that remain valid until deleted, with up to 10 keys per account. Service account impersonation avoids distributing keys by letting a source principal with Token Creator mint short-lived tokens for a target account.
Application Default Credentials (ADC) is a standard discovery strategy that lets the same code run locally and on Google Cloud. ADC discovers credentials in a fixed search order and uses the first credentials it finds:
GOOGLE_APPLICATION_CREDENTIALS environment variable pointing to a credential JSON filegcloud auth application-default loginProduction ADC depends on the attached service account, where traffic flows from the application to the metadata server and the server returns short-lived credentials for that account.
Continue with this study guide: Consuming Google Cloud APIs
Troubleshooting and observability in Google Cloud means joining metrics, logs, traces, and profiles into one diagnostic story. Metrics show numeric behavior over time, logs show event context, and traces show latency across services. Shared identifiers such as trace IDs and service labels let the three signals be investigated together in Monitoring, Logging, and Trace.
Cloud Trace is a distributed tracing system that collects latency data and shows it in near real time in the console. A trace follows one request across microservices, and each trace is made of spans where each span records one operation inside that request. Trace visualization shows the path as a Gantt chart in Trace Explorer, where each span shows start time, duration, attributes, and metadata. Traffic flows from an upstream service through its sidecar proxy to a downstream service, and Cloud Service Mesh builds a topology graph from that proxy telemetry.
Manual instrumentation starts a span, adds attributes, and ends the span around important operations, creating a trace ID for the whole request and a span ID for each operation. Context travels in the W3C traceparent header, so first the upstream service sends the trace ID outbound, then the downstream service creates spans under the same ID, and only then does the console join them into one waterfall view. Sampling controls what fraction produces traces, and if any service fails to propagate context the chain breaks into disconnected fragments. Cloud Run automatic tracing generates outer-request traces without code changes at most 0.1 requests per second per instance, while custom correlated spans incur standard ingestion charges.
Exam tip: A complete end-to-end trace requires every service to propagate trace context downstream; a sampling rate of 0.5 means only 50% of remote procedure calls are traced.
Structured logging with Cloud Logging means writing logs as structured JSON with consistent severity and metadata. Log data flows from the application to Cloud Logging, where entries are stored as JSON objects with named fields instead of plain text. Each entry carries a severity field for filtering, a resource object identifying origin such as a Kubernetes container, and an httpRequest object capturing method, URL, status, and latency. When tracing is enabled, the same entry also carries trace, spanId, and traceSampled, so a log line points directly to its distributed trace.
Context propagation carries request identity across services so signals for the same work can be joined. An upstream service passes trace context downstream while each service adds labels such as service name and version, and Observability Analytics can query log views and trace views with SQL to join logs to spans on the shared trace identifier. Log and metric instrumentation aligns business goals to technical signals, where revenue or engagement maps to success rate, latency, and error rate quantified as service-level objectives such as 99.9% successful calls or 95th percentile latency below 300 ms. Application health is tracked with latency, traffic, error rate, and saturation, while Cloud Profiler identifies bottlenecks within function blocks.
Monitoring and alerting in Cloud Monitoring turn behavior into dashboards and timely alerts compared against reliability targets. Dashboards visualize health from infrastructure and application metrics, and alerting policies notify operators when thresholds or service-level objectives are at risk. The four golden signals are latency, traffic, error rate, and saturation of CPU, memory, GPU, or TPU, and the 99th percentile is often more informative than the average because averages hide poor experiences. Alerting policies compare a metric to a threshold, such as filtering logging.googleapis.com/log_entry_count by severity ERROR, or alert on burn rate when protecting an objective rather than firing on every spike.
Trace and profiler analysis use complementary signals to find why an application is slow. Cloud Trace shows where time is spent across services, while Cloud Profiler shows which function blocks consume the most resources. In the waterfall view, a gap before a child span means the thread waited for a TCP connection, a gap after a child span means the application struggled to parse a large payload, and multiple short child spans suggest retries. The logging pipeline depends on three controls: the Logging API must be enabled, the node service account must have permission to write logs, and no exclusion filter may drop entries. Application containers should write to stdout or stderr for the agent to forward.
Managing application issues with Error Reporting means moving each defect from detection to fix through grouped analysis. Error events flow from applications to Cloud Logging and then to Error Reporting, or directly from client libraries to the Error Reporting API. An error group collects recurring events that share error name, message, and stack-trace pattern, so occurrence counts grow rather than creating new groups. The dashboard lists groups with health, recurrence, and impact, and viewing requires the Error Reporting Viewer role. From recent samples, View Logs opens Logs Explorer filtered by error group ID, but only entries stored in a log bucket carry that field.
Error Reporting mechanisms use two paths. Direct reporting sends events through language libraries and is required when the bucket uses customer-managed encryption keys or custom events are needed. Automatic inference reads qualifying log entries without added code when the app runs on an integrated service with a non-CMEK bucket and correctly formatted logs. Complete exception data determines grouping quality, and one error including all stack-trace frames must be contained in the same log entry. AI-assisted observability (opens in a new tab) learns baselines and flags deviations before outages, while generative summarization in Logging condenses complex entries and natural-language querying translates plain language into filters. Predictive alerts evaluate sustained conditions over 5 minutes, and governed response requires human validation before AI-generated actions apply, with all actions recorded in audit logs and availability preserved by circuit breakers and zonal redundancy.
Continue with this study guide: Troubleshooting and observability
cloudsql.instances.connect permission, must run continuously, and traffic flows from the application to the proxy and then to the database over an encrypted tunnel.GOOGLE_APPLICATION_CREDENTIALS file first, then the local file from gcloud auth application-default login, then the attached service account from the metadata server.Use Identity and Access Management for Cloud Storage bucket and project-level access in most cases because it grants permissions at bucket and project levels. Granular control uses IAM roles for users, groups, or service accounts, IAM policies with conditions, and principal access boundary policies that limit what a principal can reach.
Traffic flows from the application to the local proxy and then to the database instance over an authorized encrypted tunnel. The proxy must authenticate as a Cloud SQL IAM identity and must run continuously with the same uptime as the application because if the proxy stops all existing connections drop and no new connections can be created. The proxy service account must have a role that includes cloudsql.instances.connect, using Cloud SQL Client for connectivity, Cloud SQL Editor for broader management, or Cloud SQL Admin for full administration.
Pub/Sub provides at-least-once delivery with best-effort ordering and preserves order only for messages sharing an ordering key when ordering is enabled. Published messages are limited to 10 MB, so larger payloads are handled by storing the object in Cloud Storage and publishing only the URL. Each subscription receives its own copy of each message, and Pub/Sub discards the message after acknowledgment or redelivers it when acknowledgment does not occur.
Last updated