Data is arguably the most important component of any website or application. If you are the owner of a website or an app, you must ensure that you are able to provide your users with adequate data security, accessibility, and availability within a dynamically changing environment.
One of the ways to do this is to use multiple servers working in sync with each other for data storage and maintenance as opposed to a single server. Using only one server is inevitably prone to system failure and complete data loss. Having replica sets of your data on multiple databases not only protects you from major system failures and their consequences but also makes the data more available and improves system productivity and performance. Furthermore, it allows you to perform analysis without any degradation.
Clustering on CloudSigma PaaS with PostgreSQL
The clustering feature on the CloudSigma PaaS enables users to create replica sets of their data. PostgreSQL is one of those clustering solutions. With the help of PostgreSQL, you can perform primary-secondary asynchronous replication based on pre-designed templates. One database container is deployed for each role: one primary container and one secondary container.
The primary server is running an active instance of the database. It is responsible for accepting all read-write operations. The secondary server runs a copy or replica of the active database. It is responsible for handling the read-only operations. In case something interrupts, corrupts, or causes the primary database to fail, the secondary server will take on the primary role as it is operating in a separate container. In this manner, writes are retained and database availability is not compromised at any point.
By default, each database container has from 2 reserved to 32 dynamic cloudlets for vertical scaling (4 GB of RAM and 12.8 GHz of CPU). These are allocated dynamically depending on the incoming load. However, it is possible for you to modify the resource allocation limit as per your wishes as well. You can learn more about the details of data replication with PostgreSQL in their official documentation.
Now that you know how it works, let’s see how you can start. You can install Database Clusters in two ways. You can either install it:
- As a Marketplace application, or
- By using the embedded Auto-Clustering feature on the PaaS Dashboard.
We will discuss how to install the feature using either of the ways in this tutorial as well as how to set up your cluster.
Installing the PostgreSQL Cluster from the Marketplace
CloudSigma’s PaaS Marketplace is your go-to for finding any and all applications or packages you need to install with just one click. First, go to the Marketplace and you will be able to find the PostgreSQL Primary-Secondary Cluster package with ease in the given options:
Clicking on Install will open the installation window. Here, you can change the database Version, name of the Environment, and Display Name as needed:
Auto-Clustering Mode in PostgreSQL
To enable auto-clustering on the CloudSigma PaaS, all you need to do is flip a switch. Click on New Environment to open the Topology Wizard. After that, select the software stack (for example, PostgreSQL 14.1), and switch the Auto-Clustering option to On:
You can also change the resource allocation limits at this point if needed.
Cluster Topology
This is what the database cluster topology will look like for your primary and secondary databases:
Once the installation is complete, you will receive a pop-up confirmation message on your PaaS containing the URL for the primary node along with the credentials you can use to access it. This information will also be sent to your registered email:
Remember, if you installed the cluster using the auto-clustering feature, you will receive the credentials on your email only.
Ensuring Database Replication: Testing PostgreSQL
Now that we have launched our clusters, let’s run a test to ensure that our data was replicated to the secondary server successfully. To do this, we will create a new instance in the primary container and then check whether it shows up in the secondary container. Let’s begin:
- Create a New Database
- Hover over the PostgreSQL Primary node and click on the Open in Browser option. This will launch the phpPgAdmin web interface:
2. Next, locate and click on PostgreSQL under Servers on the left side of the page.
3. Use the credentials from the confirmation message for your cluster installation or your email to log into your server:
4. After that, click on Create database:
5. In the following window, enter the name of the database in the Name field. In our example, we named our DB instance CloudSigma. Next, click Create:
- Check for Replication of the DB Instance
Now that our database has been created in the primary container, we will check if it was replicated on the secondary node:
- Hover over the Secondary node. Then, click on the Open in Browser option to launch the phpPgAdmin web interface once again:
2. Click on PostgreSQL and use the same credentials that you used for the primary node to log in:
Once you are logged in, you should be able to see a replicated instance of the database you created in the primary node. In the above example, you can see that the CloudSigma database is present in the secondary server. This means that our test was successful and we have set up our PostgreSQL environment with primary-secondary asynchronous replication.
This is just the tip of the iceberg- you can achieve a lot more with the CloudSigma PaaS Platform Dashboard. You can learn more about our PaaS service right here. Give CloudSigma PaaS a try with our 7-day free trial or contact us if you want us to provide you with more details and a platform demo.
- 5 Tips to Achieve Optimal Cloud Computing Cost Efficiency - October 31, 2022
- CloudSigma Empowers Blockchain Infrastructure Provider with a Green, Reliable, and Cost-Efficient Cloud Platform - October 27, 2022
- Whitech Launches New Egypt Cloud Computing Offering, Powered by HPE and CloudSigma - October 17, 2022
- Key Aspects of Protecting your Data in the Cloud - September 20, 2022
- How to Configure MongoDB Replication and Automated Failover - September 19, 2022