By: Sergiu Onet | Updated: 2023-07-10 | Comments | Related: > Google Cloud
Problem
We need to deploy our apps in Google Cloud Platform (GCP), however, we have many deployment platforms and are unsure which one to choose. It would be easier to decide if we had an overall view of the app deployment options to see what platform is best for our application.
Solution
Read along to learn about the available deployment options in GCP and how to choose the appropriate one for your apps.
Compute Engine
Google's IaaS service, Compute Engine, is a great choice to host your app if you want complete control over the OS and have all the flexibility you want. Compute Engine should satisfy your requirements if you need to migrate existing systems, have a specific licensing, OS, or kernel requirement, or your app is not containerized.
If you set up Managed instance groups, you can create VMs based on a template with custom configuration, automatically install software or dependencies at startup using Startup Script, auto-heal not responding instances, auto-scale to handle workload increase, and set up multiple zones for the VMs if you need high availability.
Google Cloud Marketplace is a place where you have pre-configured images with preinstalled solutions for various categories like blogs, CMS, web stack, and many more. It's a fast way to install a pre-configured image with many dependencies.
The billing for Compute Engine is based on the resources you provision for the VMs and there are committed and sustained use discounts.
Google Kubernetes Engine (GKE)
For containerized and portable applications, you can use GKE. We won't get into details regarding Kubernetes and containerization, but let's have a general view of this topic.
GKE is a managed service for Kubernetes for managing, scaling, and deploying containerized apps. At a high level, it consists of a cluster made of a collection of Compute Engine VMs called nodes. Pods are instances of a running process in the cluster, and a pod contains one or more containers. Inside a container, you have the application code and dependencies.
You control node configuration and can interact with the cluster, and Kubernetes handles the container scaling and connectivity. There is also a Container Registry inside GCP to store your container images.
Containerizing an app has some advantages. Let's start with portability. All that's required for the app to run is packaged together as a single unit and can run anywhere without having to bother about dependencies. Containers are considered lightweight, have faster startup times, and scale easily and quickly. They are isolated and run separately from each other, so this helps to isolate a faulty container.
GKE billing is also resource-based. You pay for the VMs inside the cluster.
Cloud Run
Cloud Run is the right choice if you use containerized apps but don't want to configure or manage the Kubernetes cluster and want a fully-managed infrastructure and a serverless platform.
To use Cloud Run, just put the code or container inside, and Cloud Run takes care of the hosting and scaling of the app. The apps you put inside must be stateless, and the images must be stored in Container Registry. It supports many languages like Go, Python, Java, Node.js, .NET, and Ruby, scales up to 1000 concurrent requests/container instances, and is a regional service that replicates across zones.
Billing for Cloud Run is a pay-as-you-go model, per request.
Anthos
Anthos is a platform made for deployments in multi-cloud and hybrid environments. You can bring GKE or Cloud Run deployments in Anthos and benefit from running your workloads in other clouds like AWS, Azure, or even on-premises, managing all these different environments from a single tool. You can set up security policies, orchestrate your clusters, integrate CI/CD, and monitor all your deployments across all these environments, all from a single place. To learn more about Anthos, see this link.
App Engine
App Engine is a fully managed, serverless platform that handles infrastructure deployment, networking, and scaling beside the scenes. It supports Node.js, Java, Ruby, C#, Go, Python, or PHP for your web app. You can have one App Engine application per project; an application can have one or more services; a service can have multiple versions, and a version can have multiple instances.
It supports versioning and rollback to another version if needed. You can do canary testing or A/B testing by splitting traffic between your app's versions, and you can choose between two environments, standard and flexible. Here is a comparison between App engine standard and flexible, where you can select which is best for your needs. Monitoring, logging, and error reporting integrate with App Engine so that you can debug and analyze your code in real-time. App Engine can be used for websites, mobile apps, and gaming backends, and it also supports REST APIs.
App Engine's billing is similar to Cloud Run, a pay-as-you-go model.
Cloud Functions
Cloud Functions is a fully managed event-driven serverless function that is good for responding with an action to events or triggers that happen in GCP. It's suitable for loosely coupled microservices, lightweight data transformation, and automation, and it uses an open-source framework that can run on multiple environments like on-premises.
You only pay for the triggered requests and execution time per 100 ms increments. If the function is idle, you are not charged.
Cloud Storage
It's worth mentioning this option because it's a good choice for static websites where content doesn't change much. An example is HTML, CSS, or JavaScript content. You cannot store dynamic content like server-side scripts. You create a bucket in Cloud Storage, put your site's content in, and you're almost good to go. Here are the steps to host a static website in Cloud Storage.
Cloud Endpoints
Cloud Endpoints provides an API management solution where we can create, maintain, and secure our APIs. It's integrated with Cloud Logging, Monitoring, and Trace for monitoring and insights. It provides user authentication, API keys generation for API calls validation, low latency, and easy integration. See more about Cloud Endpoints using this link.
Choosing between these platforms can be difficult. We can even use them together. To make your life easier, let's review a few factors your decision should depend on:
- Abstraction level – If you want to have control and configure the infrastructure, go for Compute Engine or GKE. If you want to focus on the code and do not care about scaling or infrastructure provisioning, go for App Engine, Cloud Run, or Cloud Functions.
- Technical requirements – If you have specific technical needs like a particular OS, kernel, GPUs, licensing, or lift-and-shift migrations, Compute Engine or GKE should be the answer. If you need to prioritize the code development and deploy quickly, use a managed or serverless platform like App Engine, Cloud Run, or Cloud Functions.
- Billing model – A usage billing model applies to App Engine, Cloud Run, and Cloud Functions. Here we pay for the requests that occur, a pay-as-you-go model. If there is no activity for your code, you are not billed. A resource usage model applies to Compute Engine and GKE, where you are billed for the created and running instances, even if the usage is low or nonexistent.
- Team members – If your team has mostly developers, you will probably want a serverless solution like App Engine, Cloud Run, or Cloud Functions, where the focus is on the code, not the infrastructure management and operations. For larger teams or if you already have preferred tools and can split operations between team members, GKE or Compute Engine is the right choice.
Next Steps
- Check this tip regarding security best practices in Google Cloud - Best-Practices-With-Google-Cloud-Security
About the author
This author pledges the content of this article is based on professional experience and not AI generated.
View all my tips
Article Last Updated: 2023-07-10