Over a million developers have joined DZone.
{{announcement.body}}
{{announcement.title}}

HTTP/3 Premium CDN Setup for Magento Cloud Hosting

DZone 's Guide to

HTTP/3 Premium CDN Setup for Magento Cloud Hosting

Make your website or application run faster and smoother with a distributed CDN offering from Jelastic.

· Cloud Zone ·
Free Resource

Heart shaped rope

This may not tie your application together, but a good CDN will

Jelastic HTTP/3 Premium CDN (content delivery network) add-on leverages a highly interconnected global network, featuring massive bandwidth capacity, advanced caching and acceleration strategies, fast-routing IP Anycast technology for powerful and lightning-fast performance over the globe.

This CDN network spans the globe with 130+ Super PoPs (points of presence) located on 6 continents. Jelastic customers get premium traffic for the same price across all continents and countries with no surprising bills based on geographic locations.

You may also enjoy:  5 Reasons to Implement a Content Delivery Network (CDN)

Attaching a CDN network to a website is a simple process while using Jelastic PaaS. In this tutorial, you’ll see how to do that with a Premium CDN service to ensure extremely fast content distribution among your clients worldwide. The demo instruction is based on Magento Hosting package where this e-сommerce platform can be automatically installed in one click and hosted within Jelastic PaaS.

CDN Add-On Installation

1. Log in to Jelastic dashboard, open Marketplace, find the HTTP/3 Premium CDN Add-On and click Install.

HTTP/3 Premium CDN from marketplace

2. In the opened window, choose the environment (Magento, in our case) where CDN should be enabled, the preferred nodes layer and press Install.

HTTP/3 Premium CDN installation

Note: Pricing may vary depending on country and chosen service providers.

3. When the installation is finished, you will get a success popup window with the CDN URL in the following format:

 ${env.envName}-${sufix}.cdn.edgeport.net 

where ${sufix} is a code name of your Jelastic hosting provider automatically generated for the environment hostname upon add-on installation.

During the first hour or so, you may experience a 404 error as it takes time for a new environment to be propagated across the CDN network.

Environment Configuration

Environment Configuration

Currently, only the LiteSpeed Web Server supports the HTTP/3 protocol. For the NGINX web server, this modern protocol is still in development. So in order to provide the highest possible performance for CDN integrated into the user’s environment, in this tutorial we’ll cover Magento cloud hosting based on the LiteSpeed Web Server.

In order to make Magento static assets downloadable from CDN and to get the environment ready for production, do the following steps:

1. Install Magento with LiteSpeed Web Server.

2. Attach a public IP address to allow the LiteSpeed Web Server responding via HTTP/3 high-speed protocol excluding Shared Load Balancer from the traffic chain.

3. Bind your custom domain via a record. Let’s take magento.customdomain.com as an example.

4. Install the Let’s Encrypt SSL add-on with your custom external domain. If your environment was using a built-in SSL you can turn it OFF via a dashboard.

5. Finally, we will make the static content of the website downloadable from PoPs by changing the base URL to the generated CDN one. In the case of Magento, do the following:

  • Open Magento admin panel using link and credentials from the email received after installation
  • Click on STORES > Configuration > Web > Base URLs (Secure)

HTTP/3 Premium CDN Magento base urls

  • Change the protocol for Secure Base URL field and replace the domain name you chose before environment installation with your custom domain name assigned via A record, e.g. magento.customdomain.com
  • Fill in the Base URLs (Secure) for Static View Files and for User Media Files fields with CDN URL which was issued for the environment respectively:https://{env.envName}-${sufix}.cdn.edgeport.net/pub/static/ and https://{env.envName}-${sufix}.cdn.edgeport.net/pub/media/
  • Permit access to the Magento admin panel via HTTPS

HTTP/3 Premium CDN magento https

  • To push all of the traffic via HTTPS only repeat the same steps for STORES > Configuration > Web > Base URLs section.

  • Finally, press Save Config to apply changes.

6. The billing job triggers every night, so the next day you can check the billing history.

HTTP/3 Premium CDN billing history

Bind Custom Domain to CDN

Once you’ve attached CDN service, it automatically generates a dedicated domain for your environment ${env.envName}-${sufix}.cdn.edgeport.net as it was described earlier. You can also bind a custom domain (e.g. cdn.magento.customdomain.com) via add-on settings. Let’s see how to do this.

1. Press the Add-Ons button of the application server instance.

HTTP/3 Premium CDN add-ons

2. Find CDN Add-On and press Configure.

HTTP/3 Premium CDN configuration

3. Fill in the Custom CNAME field. You can specify multiple domains separating them by space or semicolon (;). Then follow the instructions on how to bind custom domain via CNAME record.

HTTP/3 Premium CDN bind custom domain

Once you’ve applied this, the static website content will be available via your custom domain.

High Availability Method

Within the above-mentioned add-on settings, you can also choose an appropriate method to ensure high-availability mode.

  • Round Robin (RR) – even distribution of requests among available nodes.
  • Primary Failover (PF) – all requests are sent to the first node, and if it becomes unavailable the requests are redirected to the next, and so on.

HTTP/3 Premium CDN high availability

During horizontal scaling of the nodes in the application server layer, the platform automatically updates the records of available nodes inside CDN service. It eliminates the necessity to perform any manual actions during scaling events.

Purge, Purge All, and Uninstall

For cache cleaning of the static assets at PoPs, we can use Purge or Purge All actions. Once the assets are deleted, the CDN begins downloading their fresh copies from an origin server.

HTTP/3 Premium CDN purging

Purge deletes specific assets within the specified path.

HTTP/3 Premium CDN purge

Meanwhile, Purge All deletes all static assets at the PoPs, just asking the user to confirm cache clearance. The cache renewal process is much faster compared to the first static assets propagation after Add-On installation.

Link Multiple Environments For Extra High-Availability

For multi-environment solutions such as geo-distributed applications, the high availability is quite important for dynamic content as well as for static. So if you have the application which consists of two environments that are fully synchronized, you can ensure its extra high availability with respect to the static assets cached at PoPs. It is implemented as a possibility to link several environments to the same CDN endpoint. In other words, CDN will be caching the static assets from several origins which are fully synced. Follow the steps below to make the required settings:

1. Find the Premium CDN add-on for the second environment and initiate installation.

HTTP/3 Premium CDN install add-on

Choose Link to an existing environment option and pick the environment with previously installed CDN add-on and click on the Install button.

HTTP/3 Premium CDN link environment

2. Once deployed, a successful installation window appears with the CDN URL which actually refers to the same endpoint the existing environment does.

HTTP/3 Premium CDN installed successfully

Thus the HA mode is achieved with duplicated origins:

  • magento.jelastic.cloud

  • magento1.jelastic.cloud

So, if one goes down the other will be serving CDN’s requests for static assets caching at the single endpoint: magento-demo.cdn.edgeport.net.

3. The last step is to configure the second environment the same way so please repeat all of the configuration steps described above.

Congratulations! You’ve successfully integrated CDN onto your web sites that will make them lightning fast by loading data from the nearest geographic location. Explore the benefits at one of globally-available Jelastic service providers with Premium CDN Add-On support or contact your current Jelastic service provider to enable this functionality.

Further Reading

Application Delivery Network vs. Content Delivery Network

Why Is it Necessary to Incorporate a CDN Into Any Website?

Topics:
cloud cdn ,magento 2 ,magento cloud ,cdn optimization ,magento application development ,cloud

Published at DZone with permission of

Opinions expressed by DZone contributors are their own.

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}