Run your Highly Available and Efficient Calipso CMS Cluster with Jelastic NodeJS Hosting

By February 5, 2015 Concepts, HowTo No Comments
Share on FacebookShare on Google+Tweet about this on TwitterShare on LinkedInEmail this to someone

nodejsSupporting multiple engines, the Jelastic Cloud can be leveraged by developers as a single hosting center for all of their applications, regardless of the programming language they were written in – Java, PHP, Ruby, Python, NodeJS or .NET (will be integrated in the upcoming Jelastic release). Today we’d like to pay attention to one of the Jelastic “newbies”, added a few months ago – NodeJS, and consider the provided NodeJS hosting possibilities, using the example of the Calipso application deployment.

Calipso is a free and open-source content management system (CMS), powered by Node.js. Built with a modular approach, it was designed to be light-weight, flexible and fast, allowing you to easily launch your site. Integrated modules (such as scheduler, feed, taxonomy, etc) give you a set of additional features, and ability to create and add your own modules ensures outstanding extensibility.

To make this guide more interesting for you, we’ve decided to enhance it with such useful solutions as databases replication and Calipso clusterization. The first feature will allow the data inside your database to be automatically replicated to another DB, so its preservation is immediately doubled, performance is increased (due to spreading the load between databases) and data loss becomes almost impossible until at least one DB server in a cluster is running. And Calipso clusterization mode will allow you to use multi-workers technology, which will give your site’s customers the ability to continue working, while the processes they have called for (and other trivial ones) are processed in the background, in such a way, increasing your site’s own performance.

So, let’s get started and discover a simple way of getting such a Calipso cluster instance up and running within Jelastic PaaS, by following the instruction below.

Create an Environment

First of all, you need to create an environment with the appropriate set of nodes for your Calipso cluster. Thus, log in to your Jelastic account using your credentials and proceed with the following:

1. To begin, let’s configure two MongoDB servers with replication set between them. This can be done manually by following the appropriate guide in our documentation, but a much easier way is to use the one-click installation option, available within our Marketplace.

Access it by selecting the same-named button at the top left corner of your dashboard:

env marketplace

2. In the opened tab, find the MongoDB Database Replication package using the input search field above the categories list, hover over it and select the appeared Install button.

env mongo db repl

3. You’ll see a new pop-up frame, where you need to specify the name for your environment (e.g. calipso-cms) and click Install.

env name

Once the package is deployed, you’ll be shown one more window, informing you about the successful completion of installation.

4. As a result, you’ve got a ready-to-use DB cluster with a pair of servers inside and the already configured master-slave replication between them, in just a few clicks.

env db repl created

In most cases, the first database node in the corresponding list is a master and the second one – slave (this can be verified by entering the MongoDB admin panel for one of them – slave server will have the 127.0.0.1:27017: not master and slaveOk=false string at the left panel instead of DBs list).

Note: Depending on the platform you are using, your newly created environment may have the MongoDB Database Replication alias (i.e. alternative name) applied by default. Herewith, its host name will still correspond to the environment name you’ve stated during creation (calipso-cms.jelastic.com in our case).

For more convenience, we’ll change this alias to Calipso Cluster so it won’t distract you from our actual goal. In addition, you can specify the similar aliases for DB nodes within your database cluster in order to clarify which one is master and which is slave.

env alias

5. You still need an application server added to your environment for serving your Calipso app, so click on the Change environment topology icon at the environment panel:

env change topology

6. In the opened topology wizard, navigate to the Node.js engine tab and enable the NodeJS application server. Then state the cloudlet limits for it and click the Apply button at the bottom of the frame.

env wiz

7. Within a minute your environment will be adjusted according to the performed topology changes:

env created

Database Configurations

Now it’s time to create a separate database for your Calipso CMS instance to work with.

1. Click the Open in browser button next to the MongoDB server master node in order to access its admin panel.

db open in browser

2. Log in with the credentials you’ve received via email after the environment’s creation and navigate to the Databases section. Click Create new Database.

db new db

3. In the opened frame, just type the desired database name (calipso in our case) into the appropriate field and select Create.

db name

4. And here it is! Once you’ve clicked on the Create button, a new database with the specified name will have appeared in the left-hand list, being simultaneously and automatically replicated to the second MongoDB server.

db added

Application Deployment

The next stage is deployment of the application itself. The easiest way to deploy a Calipso CMS is to use its source code at GitHub. It will take just three steps:

1. Open the appropriate repository and copy the HTTPS URL at its right panel.

app github

2. Then switch back to the Jelastic dashboard and click on the Add project button next to your NodeJS server. In the opened frame, paste the link you’ve just copied to the URL field and click Add.

app add project

3. In a few minutes your project will be built and deployed.

app deployed

Configuring the Application

And now let’s perform a few configurations in order to get the ability to launch our Calipso CMS.

1. Open the application server’s Configuration Manager by selecting the Config button next to it.

conf config

2. In the opened tab at the panel below, navigate to the webroot > ROOT > conf folder and select the development.json file.

conf development

3. Find the “uri” parameter and substitute its value with the following line, substituting the values in brackets with your master database data:

“mongodb://admin:{password}@{internal_IP}:27017/{DB_name}”

where

  • {password} is the password for MongoDB admin user (you’ve received it via email)
  • {internal_IP} – is the IP of the master database node and can be seen at the dashboard:

conf ip

  • {DB_name} – name of the database you’ve created via DB admin panel (calipso in our case)

4. In the same file, find the “url”: “http://localhost:3000″ string just down the page and insert your environment hostname instead of the default localhost:3000 value.

You should get something like the following:

conf development 2

5. Save the changes and Restart your NodeJS server in order to apply them.

conf restart

Install Calipso CMS

Once your app server is up again, you need to complete the Calipso CMS installation by specifying a few required settings within the embedded wizard.

1. Click the Open in browser button for your environment with Calipso deployed.

install open in browser

2. You’ll see the installation wizard opened in a new browser tab. As you will notice, it requires an installation password:

install installer

Therefore, switch back to the Jelastic dashboard and open NodeJS logs by selecting the appropriate button.

install log

In the appeared tab, open node logs and copy the value inside the quotes at the very end of the output text.

install node log

Paste it to the corresponding field of the Calipso installation wizard and click the Let’s Start button.

3. On the next step of database configuring, substitute the automatically pasted value in the MongoDB URI field with the string of the following format:

{master_DB_node_IP}:27017/{DB_name}

install db connect

Click the Create Database button in order to proceed to the next stage.

4. Pass through the last two wizard steps, specifying the necessary data for creation of the administrator CMS account and define the list of modules you consider to be useful in your work. Click the Save Configuration and Install button.

5. Congratulations! Your Calipso CMS has been successfully installed.

install welcome page

Enable Calipso Cluster

Using the embedded Calipso clustering mechanism allows you to change the amount of web workers. Stating more workers could be aimed for improving your application’s performance, as it gets an ability to create a special processes queue, where incoming requests have a much higher priority and thus are handled in a first row, while all the other trivial system tasks are stored to the background for this time. Nevertheless, keep in mind that such an implementation will slightly increase the amount of RAM consumed by your environment, so don’t be too greedy and choose wisely.

So, let’s proceed with configuring our future cluster.

1. Access the Calipso administrator panel by clicking the Log In link at the top right corner of its welcome page. Within the opened pop-up frame, enter the admin user credentials you’ve specified in the installation wizard.

install login

2. Once inside, let’s change the default amount of workers. For that, navigate to the Administration > Core > Configuration section using the expandable list at the Calipso tools panel.

install core conf

3. Then, switch to the settings Performance & Clustering tab, and set the desired number of workers (for example, 12) within the same-named field:

install workers number

4. Don’t forget to Save new Configurations with the corresponding button at the bottom of the page. If everything is OK, you’ll see the following message:

install conf changed

It’s almost complete, the last thing needed is to run Calipso in a cluster mode.

5. In order to activate clusterization, you need to switch back to the Jelastic dashboard and open the Configuration Manager for your NodeJS application server:

conf config

6. In the appeared frame, navigate to the webroot > ROOT directory and select the package.json file inside it. Then scroll till the very end of the code, find the “start”: “node app.js”  line and substitute it with the following one:

“start”: “node app-cluster.js”

cluster packagejson

7. Save the performed changes using the corresponding button above the editor and Restart the application server.

conf restart

Wait until all the stated workers are started and your Calipso instance is running in a cluster mode.

8. In order to make sure our configuration works properly, you can connect to your NodeJS application server via the SSH Gateway and check the amount of workers running. In case you haven’t performed similar operations before, you need to:

cluster nodejs select

9. Once you’ve entered the required container, execute the following command:

ps aux | grep node

In the received output, you’ll see a number of similar processes running according to the amount of workers you’ve determined via Calipso settings.

cluster ps aux new

Great! For now you can return to the Calipso admin panel and start populating your new website with the desired content, while being sure that all of your data is protected from loss by being replicated between a pair of servers, and your app’s performance is boosted, due to using the workers queue mechanism.

Take the opportunity to experience all the NodeJS hosting benefits, provided within the Jelastic Cloud, by trying it for yourself with our unique offer of a completely free, 2-week trial period.

Follow our blog to keep up with the most recent guides and important announcements!

Share on FacebookShare on Google+Tweet about this on TwitterShare on LinkedInEmail this to someone

Leave a Reply

Subscribe to get the latest updates