Website hosting

Last reviewed 2023-02-28 UTC

This article discusses how to host a website on Google Cloud. Google Cloud provides a robust, flexible, reliable, and scalable platform for serving websites. Google built Google Cloud by using the same infrastructure that Google uses to serve content from sites such as, YouTube, and Gmail. You can host your website's content by using the type and design of infrastructure that best suits your needs.

You might find this article useful if you are:

  • Knowledgeable about how to create a website and have deployed and run some web-hosting infrastructure before.
  • Evaluating whether and how to migrate your site to Google Cloud.

If you want to build a simple website, consider using Google Sites, a structured wiki- and web page–creation tool. For more information, visit Sites help.

Choosing an option

If you're new to using Google Cloud, it's a reasonable approach to start by using the kind of technology you're already familiar with. For example, if you currently use hardware servers or virtual machines (VMs) to host your site, perhaps with another cloud provider or on your own hardware, Compute Engine provides a familiar paradigm for you. If you already use a platform-as-a-service (PaaS) offering, such as Heroku or Engine Yard, App Engine might be the best place to start. If you prefer serverless computing, Cloud Run probably is a good option for you.

After you become more familiar with Google Cloud, you can explore the richness of products and services that Google Cloud provides. For example, if you started by using Compute Engine, you might augment your site's capabilities by using Google Kubernetes Engine (GKE) or migrate some or all of the functionality to App Engine and Cloud Run.

The following table summarizes your hosting options on Google Cloud:

Option Product Data storage Load balancing Scalability Logging and monitoring
Static website

Cloud Storage

Firebase Hosting

Cloud Storage bucket

HTTP(S) optional


Cloud Logging

Cloud Monitoring

Virtual machines Compute Engine

Cloud SQL, Cloud Storage, Firestore, and Bigtable, or you can use another external storage provider.

Hard-disk-based persistent disks, called standard persistent disks, and solid-state persistent disks (SSD).


TCP Proxy

SSL Proxy

IPv6 termination




Automatically with managed instance groups

Cloud Logging

Cloud Monitoring

Monitoring console

Containers GKE Similar to Compute Engine but interacts with persistent disks differently



Cluster autoscaler

Cloud Logging

Cloud Monitoring

Monitoring console

Managed platform

App Engine

Google Cloud services such as Cloud SQL, Firestore, Cloud Storage, and accessible third-party databases


Managed by Google

Managed by Google

Cloud Logging

Cloud Monitoring

Monitoring console


Cloud Run

Google Cloud services such as Cloud SQL, Firestore, Cloud Storage, and accessible third-party databases


Managed by Google

Managed by Google

Cloud Logging

Cloud Monitoring

Monitoring console

This article can help you to understand the main technologies that you can use for web hosting on Google Cloud and give you a glimpse of how the technologies work. The article provides links to complete documentation, tutorials, and solutions articles that can help you build a deeper understanding, when you're ready.

Understanding costs

Because there are so many variables and each implementation is different, it's beyond the scope of this article to provide specific advice about costs. To understand Google's principles about how pricing works on Google Cloud, see the pricing page. To understand pricing for individual services, see the product pricing section. You can also use the pricing calculator to estimate what your Google Cloud usage might look like. You can provide details about the services you want to use and then see a pricing estimate.

Setting up domain name services

Usually, you will want to register a domain name for your site. You can use a public domain name registrar, such as Google Domains, to register a unique name for your site. If you want complete control of your own domain name system (DNS), you can use Cloud DNS to serve as your DNS provider. The Cloud DNS documentation includes a quickstart to get you going.

If you have an existing DNS provider that you want to use, you generally need to create a couple of records with that provider. For a domain name such as, you create an A record with your DNS provider. For the sub-domain, you create a CNAME record for www to point it to the domain. The A record maps a hostname to an IP address. The CNAME record creates an alias for the A record.

If your domain name registrar is also your DNS provider, that's probably all you need to do. If you use separate providers for registration and DNS, make sure that your domain name registrar has the correct name servers associated with your domain.

After making your DNS changes, the record updates can take some time to propagate depending on your time-to-live (TTL) values in your zone. If this is a new hostname, the changes go into effect quickly because the DNS resolvers don't have cached previous values and can contact the DNS provider to get the necessary information to route requests.

Hosting a static website

The simplest way to serve website content over HTTP(S) is to host static web pages. Static web pages are served unchanged, as they were written, usually by using HTML. Using a static website is a good option if your site's pages rarely change after they have been published, such as blog posts or pages that are part of a small-business website. You can do a lot with static web pages, but if you need your site to have robust interactions with users through server-side code, you should consider the other options discussed in this article.

Hosting a static website with Cloud Storage

To host a static site in Cloud Storage, you need to create a Cloud Storage bucket, upload the content, and test your new site. You can serve your data directly from, or you can verify that you own your domain and use your domain name.

You can create your static web pages however you choose. For example, you could hand-author pages by using HTML and CSS. You can use a static-site generator, such as Jekyll, Ghost, or Hugo, to create the content. With static-site generators, you create a static website by authoring in markdown, and providing templates and tools. Site generators generally provide a local web server that you can use to preview your content.

After your static site is working, you can update the static pages by using any process you like. That process can be as straightforward as hand-copying an updated page to the bucket. You might choose to use a more automated approach, such as storing your content on GitHub and then using a webhook to run a script that updates the bucket. An even more advanced system might use a continuous-integration/continuous-delivery (CI/CD) tool, such as Jenkins, to update the content in the bucket. Jenkins has a Cloud Storage plugin that provides a Google Cloud Storage Uploader post-build step to publish build artifacts to Cloud Storage.

If you have a web app that needs to serve static content or user-uploaded static media, using Cloud Storage can be a cost-effective and efficient way to host and serve this content, while reducing the amount of dynamic requests to your web app.

Additionally, Cloud Storage can directly accept user-submitted content. This feature lets users upload large media files directly and securely without proxying through your servers.

To get the best performance from your static website, see Best practices for Cloud Storage.

For more information, see the following pages:

Hosting a static website with Firebase Hosting

Firebase Hosting provides fast and secure static hosting for your web app. With Firebase Hosting, you can deploy web apps and static content to a global content-delivery network (CDN) by using a single command.

Here are some benefits you get when you use Firebase Hosting:

  • Zero-configuration SSL is built into Firebase Hosting. Provisions SSL certificates on custom domains for free.
  • All of your content is served over HTTPS.
  • Your content is delivered to your users from CDN edges around the world.
  • Using the Firebase CLI, you can get your app up and running in seconds. Use command-line tools to add deployment targets into your build process.
  • You get release management features, such as atomic deployment of new assets, full versioning, and one-click rollbacks.
  • Hosting offers a configuration useful for single-page apps and other sites that are more app-like.
  • Hosting is built to be used seamlessly with other Firebase features.

For more information, see the following pages:

Using virtual machines with Compute Engine

For infrastructure as a service (IaaS) use cases, Google Cloud provides Compute Engine. Compute Engine provides a robust computing infrastructure, but you must choose and configure the platform components that you want to use. With Compute Engine, it's your responsibility to configure, administer, and monitor the systems. Google ensures that resources are available, reliable, and ready for you to use, but it's up to you to provision and manage them. The advantage, here, is that you have complete control of the systems and unlimited flexibility.

Use Compute Engine to design and deploy nearly any website-hosting system you want. You can use VMs, called instances, to build your app, much like you would if you had your own hardware infrastructure. Compute Engine offers a variety of machine types to customize your configuration to meet your needs and your budget. You can choose which operating systems, development stacks, languages, frameworks, services, and other software technologies you prefer.

Setting up automatically with Google Cloud Marketplace

The easiest way to deploy a complete web-hosting stack is by using Google Cloud Marketplace. With just a few clicks, you can deploy any of over 100 fully realized solutions with Google Click to Deploy or Bitnami.

Cloud Marketplace

For example, you can set up a LAMP stack or WordPress with Cloud Marketplace. The system deploys a complete, working software stack in just a few minutes on a single instance. Before you deploy, Cloud Marketplace shows you cost estimates for running the site, gives you clear information about which versions of the software components it installs for you, and lets you customize your configuration by changing component instance names, choosing the machine type, and choosing a disk size. After you deploy, you have complete control over the Compute Engine instances, their configurations, and the software.

Setting up manually

You can also create your infrastructure on Compute Engine manually, either building your configuration from scratch or building on a Google Cloud Marketplace deployment. For example, you might want to use a version of a software component not offered by Cloud Marketplace, or perhaps you prefer to install and configure everything on your own.

Providing a complete framework and best practices for setting up a website is beyond the scope of this article. But from a high-level view, the technical side of setting up a web-hosting infrastructure on Compute Engine requires that you:

  • Understand the requirements. If you're building a new website, make sure you understand the components you need, such as instances, storage needs, and networking infrastructure. If you're migrating your app from an existing solution, you probably already understand these requirements, but you need think through how your existing setup maps to Google Cloud services.
  • Plan the design. Think through your architecture and write down your design. Be as explicit as you can.
  • Create the components. The components that you might usually think of as physical assets, such as computers and network switches, are provided through services in Compute Engine. For example, if you want a computer, you have to create a Compute Engine instance. If you want a persistent hard disk drive, you create that, too. Infrastructure as code tools, such as Terraform, makes this an easy and repeatable process.
  • Configure and customize. After you have the components you want, you need to configure them, install and configure software, and write and deploy any customization code that you require. You can replicate the configuration by running shell scripts, which helps to speed future deployments. Terraform helps here, too, by providing declarative, flexible configuration templates for automatic deployment of resources. You can also take advantage of IT automation tools such as Puppet and Chef.
  • Deploy the assets. Presumably, you have web pages and images.
  • Test. Verify that everything works as you expect.
  • Deploy to production. Open up your site for the world to see and use.

To help you to get started and understand what it's like to set up Compute Engine instances manually, try one or more of the following tutorials:

Storing data with Compute Engine

Most websites need some kind of storage. You might need storage for a variety of reasons, such as saving files that your users upload, and of course the assets that your site uses.

Google Cloud provides a variety of managed storage services, including:

  • A SQL database in Cloud SQL, which is a fully managed relational database service for MySQL, PostgreSQL, and SQL Server.
  • Two options for NoSQL data storage: Firestore and Bigtable.
  • Memorystore, which is a fully managed in-memory data store service for Redis and Memcached Redis and Memcached.
  • Consistent, scalable, large-capacity object storage in Cloud Storage. Cloud Storage comes in several classes:
    • Standard provides maximum availability.
    • Nearline provides a low-cost choice ideal for data accessed less than once a month.
    • Coldline provides a low-cost choice ideal for data accessed less than once a quarter.
    • Archive provides the lowest-cost choice for archiving, backup, and disaster recovery.
  • Persistent disks on Compute Engine for use as primary storage for your instances. Compute Engine offers both hard-disk-based persistent disks, called standard persistent disks, and solid-state persistent disks (SSD). You can also choose to set up your preferred storage technology on Compute Engine by using persistent disks. For example, you can set up PostgreSQL as your SQL database or MongoDB as your NoSQL storage. To understand the full range and benefits of storage services on Google Cloud, see Choosing a storage option.

Load balancing with Compute Engine

For any website that operates at scale, using load-balancing technologies to distribute the workload among servers is often a requirement. You have a variety of options when architecting your load-balanced web servers on Compute Engine, including:

Load balancing deployment is flexible, and you can use Compute Engine with your existing solutions. For example, HTTP(S) load balancing using Nginx is one possible solution that you could use in place of the Compute Engine load balancer.

Content distribution with Compute Engine

Because response time is a fundamental metric for any website, using a CDN to lower latency and increase performance is often a requirement, especially for a site with global web traffic.

Cloud CDN uses Google's globally distributed edge points of presence to deliver content from cache locations closest to users. Cloud CDN works with HTTP(S) load balancing. To serve content out of Compute Engine, Cloud Storage, or both from a single IP address, enable Cloud CDN for an HTTP(S) load balancer.

Autoscaling with Compute Engine

You can set up your architecture to add and remove servers as demand varies. This approach can help to ensure that your site performs well under peak load, while keeping costs under control during more-typical demand periods. Compute Engine provides an autoscaler that you can use for this purpose.

Autoscaling is a feature of managed instance groups. A managed instance group is a pool of homogeneous virtual machine instances, created from a common instance template. An autoscaler adds or remove instances in a managed instance group. Although Compute Engine has both managed and unmanaged instance groups, you can only use managed instance groups with an autoscaler. For more information, see autoscaling on Compute Engine.

For an in-depth look at what it takes to build a scalable and resilient web-app solution, see Building scalable and resilient web apps.

Logging and monitoring with Compute Engine

Google Cloud includes features that you can use to keep tabs on what's happening with your website.

Cloud Logging collects and stores logs from apps and services on Google Cloud. You can view or export logs and integrate third-party logs by using a logging agent.


Cloud Monitoring provides dashboards and alerts for your site. You configure Monitoring with the G