What Is a Virtual Private Server and Xmpp Server?

Virtual private server (VPS) is the term used in the web hosting industry to refer to a virtual machine. Virtual private servers are similar in some ways to dedicated servers and are similar in other ways to shared servers. In a VPS service, the client feels that he/she is allocated a separate server for his/her website. The client is provided with a separate operating system and he/she can install any software that is permitted by the operating system. The client is also allocated separate resources such as CPU time and bandwidth. These are the ways in which VPS hosting is similar to dedicated servers.

In reality the client’s operating system is stored in the same server as many other VPS operating systems (of other clients). In other words, the client actually shares a single server with other VPS clients; similar to shared hosting. The difference between shared hosting and VPS hosting is that the client is allocated separate software and other such non-physical resources in VPS hosting. The functionality of the client’s operating system is not at all influenced by the presence of other operating systems. VPS severstypically cost more than shared hosting, but is less expensive than dedicated servers. Some types of software will not function properly in a VPS operating environment. Such software includes anti-virus software and firewalls. The web hosting provider may also place additional restrictions, but usually such restrictions are more lenient than the restrictions placed on shared hosting. The number of VPS clients who can share one machine is limited by the resources available in that machine (including processor speed and RAM).

Xmpp stands for Extensible Messaging and Presence Protocol. It was earlier known as the ‘Jabber’. The main purpose of xmpp is to provide extensible instant messaging (IM). It is also used for contact list maintenance and presence information. Although it was not originally present, xmpp has been extended to support new features such as Voice Over Internet and File transfer. When compared to other IM protocols, the specialty in xmpp is that it is an open systems protocol. This means that one xmpp service can be incorporated with other organizations’ services. Both the software and most other additional applications are available for free download.

Xmpp uses a decentralized approach. This means that any person can implement and maintain their xmpp server; there is no central server controlling the whole network. There are many security features implemented in xmpp. Xmpp servers can be isolated from the public network. This is useful for running an intranet service. Tough security specifications have been built into the xmpp software. Client-server approach is used in xmpp to facilitate communication. In this approach, any two clients will not be able to communicate directly with each other, but will have to communicate through a server. However, unlike some chat services, there is no centralized server controlling all communications.

Virtualization Replaces Client-Server With Virtual Machines

As mentioned in a previous article on virtualization, the advent of client-server topology thankfully put computing power into the hands of end users, but as these applications were rolled out over many years a number of financial and technical issues became readily apparent.

* Low Infrastructure Utilization – often times operating at less than 25% of total capacity

* Increased Infrastructure Cost – for servers, desktop computers, facilities and cooling

* Increased Maintenance Cost – more network administrators and server upgrades

* Insufficient Disaster Protection – complex networks became more difficult to backup

Coming to the rescue was the implementation of virtualization technology inside x86-based hardware. Pioneered by VMware, this new layer of software allowed multiple “virtual machines” to operate on a single server. Taking advantage of multi-core, multi-processor hardware, these virtual machines act like a single physical computer, complete with CPU, memory, hard drive storage, and network interface.

Operating systems, which are loaded onto each of the virtual machines, behave as though they were running on a dedicated server, even though this fully isolated environment is software based. These operating systems, which can include Microsoft Windows running alongside various flavors of Linux, are completely isolated from each other. If one virtual machine encounters a problem and crashes, the others are unaffected while the problem is resolved and the one machine is rebooted separately.

Beyond the level of a single server, users can now create what VMware calls a Virtual Infrastructure which lets the IT group manage a series of servers as though they were a single machine. In this case, the physical resources of multiple servers, along with associated storage and networks, are pooled in a way that offers greater utilization, availability, performance and flexibility.

Within such configurations, dynamic provisioning allows computing resources to be allocated where needed, and these workloads can even be moved across hardware systems in real time. Scheduled maintenance can also occur without critical applications being taken off line while at the same time reducing overall points of failure.

Virtual machines and virtual infrastructures are being widely deployed, from data centers to industrial automation, video processing and simulation. Trenton offers a broad range of computing platforms that support such applications, using single board computers and backplanes or fully integrated rackmount computers with segmented backplanes supporting multiple SBCs in a single rackmount enclosure.

Two Trenton white papers covering the topics of Cross-Domain Networks and Cluster Computing can provide additional information on how Trenton is serving the needs of high performance computing in a virtualized environment.

NodeJS Hosting Tips – Creating a Multi Room Chat Client

Node.js is a platform built on Chrome’s JavaScript runtime for easily building fast, scalable network applications. Node.js uses an event-driven, non-blocking I/O model that makes it lightweight and efficient, perfect for data-intensive real-time applications that run across distributed devices. NowJS is a framework built on top of Node.js that connects the client side and server side JavaScript effortlessly.

The core of NowJS functionality lies in the now object. The now object is special because it exists on the server and the client.

This means variables you set in the now object are automatically synced between the client and the server. Also server functions can be directly called on the client and client functions can be called directly from the server.

You can have a working HTTP server up and running in NodeJS with just a few lines of code. For example:

var http = require('http'); 
http.createServer(function (req, res) { 
res.writeHead(200, {'Content-Type': 'text/plain'}); 
res.end('Hello Worldn'); 

This little snippet of code will create an HTTP server, listen on port 8080, and send back “Hello World” for every request. That’s it. Nothing more needed.

Using NowJS, communication between the client and server side is just as simple.

Client Side:

<script type="text/JavaScript"> 
now.clientSideVariable = 'someValue'; 

In this code snippet, the client side sets a variable to ‘someValue’ and calls serverSideFunction(), which is declared only on the server.

Server Side:

everyone.now.serverSideFunction = function() { 

The server side is then able to access clientSideVariable, which is declared only on the client.

All the details such as establishing connections and communicating change of data between the server and client are handed automagically by the framework.

In fact writing code using this framework is so simple, the NowJS hello world example is a working chat client and server written in under a dozen lines of code. Go check it out.

As a simple exercise to get comfortable with the NowJS API, we can modify the chat client example to support multiple chat rooms. Let’s take a look at how easy it is.

Server Side (multiroom_server.js)

1. The first thing we need to do is modify the distributeMessage() function to only send messages to users in the same chat room as the user.

// Send message to everyone in the users group 
everyone.now.distributeMessage = function(message){ 
var group = nowjs.getGroup(this.now.serverRoom); 
group.now.receiveMessage(this.now.name+'@'+this.now.serverRoom, message); 

We store the name of the server room on the client side (this.now.serverRoom). When the client calls the distributeMessage() function we send the message to everyone in the same chat room by using getGroup() and using the group.now object instead of theeveryone.now object. (everyone is just a group that contains all users connected to the server).

2. Next we need to handle the client changing chat rooms.

everyone.now.changeRoom = function(newRoom){ 
var oldRoom = this.now.serverRoom; 
//if old room is not null; then leave the old room 
var oldGroup = nowjs.getGroup(oldRoom); 
// join the new room 
var newGroup = nowjs.getGroup(newRoom); 
// update the client's serverRoom variable 
this.now.serverRoom = newRoom; 

The getGroup() method fetches the group object if it exists and creates a group if it doesn’t already exist. We use the groups addUser() and removeUser() methods to move the client from the old room to the new room.

That’s about it on the server side.

Client Side (multiroom.html)

3. First we add a drop down with the list of server rooms.

<option selected="selected" value="room1">Room 1</option> 
<option value="room2">Room 2</option> 
<option value="room3">Room 3</option> 

4. Next we call the server side changeRoom() function when the user first connects and whenever the drop down is changed.

// on establishing 'now' connection, set the server room 
// By default pick the first chatroom 
// On change of drop down, clear text and change server room 

5. For extra credit, we can allow the server to dynamically provide the list of rooms when the client connects.

The changes required would be

Server Side:

// Declare a list of server rooms 
everyone.now.serverRoomsList = {'room1':'Room 1','room2':'Room 2','room3':'Room 3'};

Client Side:

// Pick up list of chatrooms from server and populate dropdown 
// By default pick the first chatroom 
// populate the #server-room dropdown from a list 
function setServerRoomFromList(roomList){ 
$.each(roomList, function(key, value){ 

That’s really all you need to do. We now have a multi room chat client/server with

i) A drop down on the client side with list of server rooms

ii) On connection with server, client auto populates server room list and enters the first room

iii) Changing drop down changes room

iv) Entering new room clears the screen for the user

This is obviously a fairly barebones version (like the original example), but it serves as a proof of concept of all the essential elements of NowJS communication.

I am hoping that this post about tips of NodeJS Hosting would be useful for you.