Now it’s time to build the actual resources that we’ll be using for our website. This will not be an article which dives into great depth in the overall architecture of a cloud environment, but you can find that information given here. We’ll be building out a Load Balancer to accept and route the traffic to two web servers, both of which communicate with a High-availability (HA) database pair.
It’s important that you first consider where most of your visitors may be located. While CDN’s can be employed to speed up the loading of assets via cached objects on edge servers, there still needs to be an origin point. You’ll typically want to create your origin nearest to the place where most of your visitors will be located.
If you would rather have your server’s authorization handled by SSH Keys instead of password, be sure that you generate an ssh key. You’ll then be able to use the SSH Public key during the server creation section.
*Currently only RSA key types are supported.
The first thing we’ll do is create the first server which our site will run on, anticipating that this master server will stay up, but that in times of varying workloads, additional servers behind the load balancer will be created and deleted. In most cases, you’ll see these referred to as the web server or simply the node.
You may notice that in our architecture diagram we planned to build two servers. Since these servers are managing a shared workload and thus will be almost identical, we’re going to wait to build the second web server so that we can simply clone it after much of the installation and configuration is done.
Now we’ll build a load balancer to act as a traffic manager across multiple servers, as well as a “fixed” target for any DNS records we create for our sites (this frees you up to create and delete cloud servers much more quickly and with less disruption, even if you don’t ever plan to have multiple cloud servers sharing a workload).
At the end of this guide series, all of our traffic will be conducted over HTTPS using an SSL certificate to comply with modern website standards. However, for right now we’re setting everything to HTTP so that we can built our basic web server, test the configuration, and prepare for the requirements to provision a certificate from Let’s Encrypt.
Once your Load Balancer is ready, grab its IPv4 address and go back to your registrar. Each registrar is a bit different but what you need to do is create the following two records, replacing “circledemo.com” with your domain.
We’ll now be creating the database that we’ll use for our website. In this particular tutorial we’ll be creating a database in the same region as we built our Load Balancer and Server.
We’ll choose MySQL version 8.0, and will be creating a High Availability (HA) Database pair with 2GB of RAM on each. This automatically sets up a pair of databases with master-slave replication and failover capabilities, so that if anything happens to cause the master database to stop functioning, then the replica database is immediately promoted and takes over duties without you having to intervene.
Now we should have the essential pieces in place to begin configuring the server and the database using what is commonly known as a LAMP (Linux, Apache, MySQL, PHP) stack.