Intrigued by the art of cloud architecture? Discover how to design, develop, and manage robust, secure, scalable, and dynamic solutions on Google Cloud as you prepare for the Professional Cloud Architect exam!
Serverless workloads, like those in Cloud Run, often need to access private resources such as databases inside a Virtual Private Cloud (VPC). A Serverless VPC Access connector creates a secure bridge for this traffic, keeping it off the public internet. To further protect sensitive data, VPC Service Controls can be used to set up a security perimeter, preventing unauthorized data movement between services.
Security is managed through Identity and Access Management (IAM), which follows the principle of least privilege. This means each service account is given only the minimum permissions needed for its job. Key roles include the Cloud Run Invoker (to allow a service to be called), the Secret Manager Secret Accessor (to read sensitive data), and the Artifact Registry Writer (to store container images).
Passwords and API keys should be managed securely, not passed in environment variables. Secret Manager stores this sensitive data, and serverless services can securely access it. For encryption control, Customer-Managed Encryption Keys (CMEK) in Cloud Key Management Service (Cloud KMS) allow users to manage the encryption keys for their own data in services like Artifact Registry.
To create flexible, independent systems, developers use event-driven orchestration. Eventarc routes signals (events) between different cloud services. These events, like a new file in storage, are often queued using Pub/Sub. This allows parts of the application to trigger actions asynchronously, meaning the sender doesn't wait for the receiver, which keeps systems reliable and decoupled.
A major benefit of serverless is automatic scaling. Services like Cloud Run can scale up instantly to handle traffic spikes and scale down to zero when there's no demand. Scale-to-zero means the service stops running completely, which maximizes cost-efficiency since you only pay for resources during request processing. Administrators can configure limits to control how high the service scales.
Scaling from zero introduces a performance trade-off: a cold start. This is a brief delay when a new instance must start up to handle the first request. To reduce this latency for performance-critical applications, you can configure a minimum number of instances to keep "warm," ready to serve traffic immediately. This decision balances lower latency against the higher cost of keeping instances running.
Concurrency settings allow a single serverless instance to handle multiple requests at the same time. Increasing the maximum concurrency can reduce the total number of instances needed, lowering costs. It's also important to tune memory allocation and CPU limits to match your application's needs. Setting appropriate execution timeouts ensures functions don't run longer than intended.
Effective optimization requires monitoring your application's behavior. For predictable, steady workloads, Committed Use Discounts (CUDs) can lower costs. Regularly reviewing performance metrics helps ensure that timeouts, memory, and concurrency settings are correctly tuned for your users' experience and your budget.
Google Cloud offers two primary serverless compute services: Cloud Run (for containers) and Cloud Functions (for event-driven functions). Both provide automatic scaling, a pay-per-use model, and reduce operational overhead by having Google manage the underlying infrastructure. The choice between them depends on your workload's trigger, complexity, and execution needs.
Cloud Run runs stateless applications packaged in containers. It supports any programming language or library that fits in a container, making it ideal for web APIs, microservices, and migrating existing containerized workflows. A key feature is its ability to scale to zero. It also supports Cloud Run jobs for batch or scheduled tasks that run to completion and then stop.
Cloud Functions is a Functions-as-a-Service (FaaS) platform designed for small, single-purpose pieces of code. Functions are event-driven, reacting directly to changes in services like Cloud Storage or Pub/Sub. They are best for lightweight tasks such as processing uploads or sending notifications. While supporting popular runtimes, they offer less environmental flexibility than full containers.
Choosing the right service involves evaluating several factors. Use Cloud Run for existing containerized workflows, longer execution durations, and applications needing specific binaries or libraries. Choose Cloud Functions for simpler, event-triggered logic that tightly integrates with other Google Cloud services. Consider language support (Cloud Run supports any language), trigger type (HTTP vs. internal events), and portability (containers are easier to move between clouds).
Prepare and test your skills
Prepare and test your skills
Cloud Run runs stateless containerized applications supporting any programming language and is ideal for web APIs, microservices, and migrating containerized workflows, while Cloud Functions is a Functions-as-a-Service platform for small, event-driven code that reacts to changes in services like Cloud Storage or Pub/Sub.
Use Cloud Run for existing containerized workflows, longer execution durations, and applications needing specific binaries or libraries, while Cloud Functions is better for simpler, event-triggered logic that tightly integrates with other Google Cloud services.
A cold start is a brief delay when a new instance must start up to handle the first request after scaling from zero. To reduce this latency for performance-critical applications, you can configure a minimum number of instances to keep warm, balancing lower latency against higher cost.
Passwords and API keys should be stored in Secret Manager, not passed in environment variables, and serverless services can securely access it. Additionally, Customer-Managed Encryption Keys (CMEK) in Cloud Key Management Service (Cloud KMS) allow users to manage encryption keys for their own data in services like Artifact Registry.
An enterprise is designing a decoupled, event-driven processing pipeline on Google Cloud. When new image files are uploaded to a private Cloud Storage bucket, an Eventarc trigger must capture the event and deliver it directly to a backend processing service. The backend service is hosted at an internal HTTP endpoint within a private Virtual Private Cloud (VPC) network and is addressed using an internal DNS domain name managed by Cloud DNS.
To ensure private network connectivity and follow the principle of least privilege, which combination of networking and Identity and Access Management (IAM) configurations should you implement?