Architecture: Magento deployment

This article describes an architecture for deploying Magento on Google Cloud. It describes deployments on three Google Cloud computing options: Compute Engine, Google Kubernetes Engine (GKE), and the App Engine flexible environment.

Magento is a software platform that's designed for running commerce workloads. It's available in two versions, Magento Open Source and Magento Commerce. The open source version supports basic Magento functionality. The Magento Commerce version contains features to support higher scale workloads, such as using multiple backend databases and message queueing. This solution describes a typical Magento Commerce architecture and a few ways you can deploy it on Google Cloud.

Magento component architecture

The Magento platform consists of several core and optional components:

  • A web server capable of supporting PHP-based applications, such as Apache or nginx.
  • The database server MySQL.
  • Optional components for Magento Open Source and Magento Commerce:

    • A page caching mechanism, such as Redis or Varnish.
    • A session storage mechanism, such as Redis or memcached.
  • Optional components for Magento Commerce only:

The following diagram shows a sample high-level architecture for a Magento Open Source deployment.

A web server separately communicating with a page cache and a database server

The architecture consists of a web server that communicates with a database server as well as a cache for session and page information.

The following diagram shows a sample high-level architecture for a Magento Commerce deployment.

A web server separately communicating with a page cache and a database server, plus a search component communicating with a message queue

It contains the same elements as the open source deployments (web server, session and page cache and a database server), but also a search server and a message queue.

Choosing a cloud architecture for Magento

Magento supports multiple deployment configurations using Google Cloud. Depending on your deployment and management needs, you can deploy the core Magento platform on the App Engine flexible environment, GKE, or Compute Engine:

  • For standard Magento deployments without plugins or Magento Marketplace extensions, the App Engine flexible environment is a good choice.
  • For deployments with plugins or Magento Marketplace extensions, you can deploy using either GKE or Compute Engine.

For more information on which computing option to choose, see Choosing a computing option.

Deploying Magento using the App Engine flexible environment

The following diagram shows a sample Magento deployment using the App Engine flexible environment with split database functionality.

Magento runs on multiple instances of App Engine, which are in a separate subnet from the other components

In this architecture, the components are deployed as follows:

  • The web application is deployed on the App Engine flexible environment.
  • Cloud Load Balancing directs incoming requests to the App Engine web application. App Engine automatically provisions Cloud Load Balancing as part of the application deployment process.
  • The cache, search, and messaging components are deployed on Compute Engine.
  • The database component is hosted on a Compute Engine instance.

To deploy Magento using the App Engine flexible environment, you need to package the core Magento web application into a Docker container. Next, you configure your app to use a custom runtime. For more information on the requirements for custom runtimes, see Building custom runtimes.

When you use the App Engine flexible environment, you create two Virtual private cloud (VPC) subnets in your project:

  • The first subnet contains the web application running in App Engine. You must configure the App Engine flexible environment deployment to use the first subnet. This configuration is described in Configuring your app with app.yaml.
  • The second subnet contains the cache, search, and messaging components running on Compute Engine. You can deploy the cache, search, and messaging components using Compute Engine VMs with internal-only IP addresses and firewall rules that allow access only from the App Engine flexible environment deployment. This configuration adds a layer of security between the application and backend components.

You can configure your Magento deployment for high availability by following these steps:

  • Deploy the cache, search, and messaging components across multiple zones in the same region as the App Engine flexible environment web application. The App Engine flexible environment deployment is multi-zone within a single region by default.
  • Configure your Compute Engine instance to use a failover replica in another zone within the same region.

Deploying Magento using GKE

The following diagram shows a sample Magento deployment using GKE with split database functionality.

Magento runs on multiple instances of GKE that are each in separate zones but all in 1 subnet

In this architecture, the components are deployed as follows:

  • The web application and cache components are deployed on GKE.
  • Cloud Load Balancing directs incoming requests to the GKE web application services and pods.
  • The search and messaging components are deployed on Compute Engine.
  • The database component is hosted on a Compute Engine.

To deploy Magento using GKE, you package the core Magento web application and cache components into individual Docker containers. Next, you create Kubernetes manifests that describe the pods and services to be deployed. You can use Cloud Build to automate the building and packaging of the associated Docker containers.

In this architecture, you create two VPC subnets in your project:

  • The first subnet contains the web application and cache components running in GKE.
  • The second subnet contains the search and messaging components running in Compute Engine. You can deploy the search and messaging components using Compute Engine VMs with internal-only IP addresses and firewall rules that allow access only from the GKE deployment. This configuration adds a layer of security between the application and backend components.

You can configure your Magento deployment for high availability by following these steps:

  • Deploy the GKE cluster across multiple zones within a single region. For more information, see the overview of multi-zone GKE clusters.
  • Optionally, configure the cluster to use the GKE cluster autoscaler. The autoscaler automatically resizes clusters based on saturated or underutilized resources.
  • Deploy the search and messaging components across multiple zones, within the same region as the Kubernetes Engine cluster.
  • Configure your Compute Engine instance to use a failover replica in another zone within the same region.

Deploying Magento using Compute Engine

The following diagram shows a sample Magento deployment using Compute Engine with split database functionality.

Magento runs on multiple instances of Compute Engine that are each in separate zones but all in 1 subnet

In this architecture, the components are deployed as follows:

  • The cache, search, and messaging components are all deployed using Compute Engine.
  • Cloud Load Balancing directs incoming requests to the web application Compute Engine VMs.
  • The database component is hosted on a Compute Engine instance.

To deploy Magento using Compute Engine, refer to the Magento installation guide. When you use this approach, you create two VPC subnets:

  • The first subnet contains the web application and cache components.
  • The second subnet contains the search and messaging components. You can deploy the search and messaging components in a subnet using Compute Engine VMs with internal-only IP addresses and firewall rules that allow access only from the Compute Engine web application deployment. This configuration adds a layer of security between the application and backend components.

You can configure your Magento deployment for high availability by following these steps:

  • Deploy the web application Compute Engine cluster across multiple zones within a single region.
  • Deploy the Compute Engine cluster inside a managed instance group to simplify management, and use auto-scaling and load balancing.
  • Deploy the cache, search, and messaging components across multiple zones, within the same region as the web application Compute Engine VMs.
  • Configure your Compute Engine instance to use a failover replica in another zone within the same region.

What's next

  • For a comparison of the options for running your application on GCP, see Choosing a computing option.
  • Try out other Google Cloud Platform features for yourself. Have a look at our tutorials.
Was this page helpful? Let us know how we did:

Send feedback about...

Architectures