Monday, September 7, 2015

Why OS Virtualization?

When it comes to server virtualization, we have few choices to choose from:  Xen, OpenVZ, LXC, Linux V-Server, KVM, Hyper-V, VMware ESXi and a few of others. Despite the names, we can generally break them down into two camps: Operating System (OS) Virtualization and Hardware (or Hypervisor) Virtualization.

In general, Hardware-level Virtualization provides better isolation and it is considered as a full virtualization platform. Operating System virtualization, however, is often considered as jail-like containerization. In this post, I list a few of top benefits as why you may give OS virtualization technology a try.

Reason 1: Performance

Performance is the main reason you choose operating system-level virtualization. Unlike Hardware-level virtualization that emulates the entire hardware layer and creates a dedicated kernel on each Virtual Machine, operating system- level virtualization like OpenVZ useschroot environments that rely on the same kernel. The emulation layer created by Hardware-level virtualization has greatly degraded the overall performances (I/O, Network throughput), as well as wasting the CPU cycles and requiring the dedicated memory to run custom kernel on each virtual machine. Generally speaking, the overall performance degradation in Hardware-level virtualization is distinguishable at most scenario, especially in the high-traffic web loads and I/O intensive applications.

Reason 2: Density and Utilization

In general, the operating system-level virtualization has 3 times higher density than its hardware-level counterpart due to the nature of design. Hardware-level virtualization creates an emulation layer called Hypervisor so that its "guest" system would "falsely" treats the underlying hardware resource as the dedicated resources. The Hypervisor further dedicated the resources (such as OS kernel, drivers, user applications and tools) on each "guest" system. With that being said, about 20% of hardware resources have been used for virtualization platform in various processes (known as "overheat" in the virtualization industry).

Operating system-level virtualization, however, uses the single OS kernel in its underlying hardware node. It's Virtual Environment (known as VE) is just a bunch of files and process in that kernel. The underlying kernel manages all the processes across the VEs in the same hardware node. As a result,, OS-level virtualization produces near-zero overheat in virtualization process.

Soon after you come down to the realization of how the virtualization platforms utilize the hardware resources. You have find no trouble why OS-level virtualization has higher "guest" density then hardware-level one.

Reason 3: Agility

Agility is another reason you may think about choosing operating system-level virtualization. To eliminate the misunderstanding, I would like to put some efforts on explaining what "agility" really mean in Virtualization world.

Agility indicates how flexible and easy a virtual instance can be changed in size at any running state of server operations. In other words, how easy we can "scale-up" and "scale-down" the server resources at any time we want it - without interrupting the on-going processes and operations.

In operating system-level virtualization platform, since all of virtual instances are running on the same OS kernel and are sharing the same hardware and OS resources, the resources that are allocated to a specific virtual instance can be changed at the run-time. But, in hardware-level virtualization, since the resources and custom kernels have been provisioned in the course of virtual machine creations, it's almost impossible to dynamically re-size the same instance at the real-time. The common practice of resizing the instances is to spin up a new instance with either larger or smaller resources and then transitions user's files, processes and user configurations onto the new instance - the Linux kernel and visualization platform make this transition possible but require additional techniques involved.

Wednesday, November 12, 2014

Node.js and NPM system

Yesterday I encountered some problems when installing Node.js modules onto my Debian/Ubuntu servers using it's packaging system, NPM. I realized it would be better not to install NPM via it's official install script here. Instead, we can install NPM and Node.js via Chris Lea's Personal Package Archive (PPA)

It's simple, just do following:

 $ apt-add-repository ppa:chris-lea/node.js
 $ apt-get update
 $ apt-get install nodejs npm

If you don't have python-software-properties installed in your server, please do install it:

 $ apt-get install python-software-properties

Please also note that npm install puts your node modules onto current working directory. This is referred as "local" install. If you'd like to install mode modules globally, you would have to explicitly use -g option. That way, you can run the commands from anywhere on your machine.

Tuesday, August 13, 2013

Web Frameworks in PHP

Model–view–controller (MVC) is one of major architectural patterns in the world of making web applications. It helps us to separate the concerns, reduce the code complexities, and make our codes more easily to write, read and share. Today, I am here to collect all of the major MVC frameworks that are written in PHP. If I am missing something you think are signinicant, please feel free to ping me.


1: Symfony

Symfony is a full-stack MVC framework, a library of cohesive classes written in PHP. Symfony provides an architecture, components and tools for developers to build complex web applications faster. Choosing Symfony allows you to release your applications earlier, host and scale them without problem, and maintain them over time with no surprise. Please note that Symfony 1.x and Symfony 2 are very different. Symfony 2is a bold step forward on supporting PHP 5.3+ only and it doesn't support backward compatibility. Therefore, if you are planning to give Symfony 2 a spin, you must ensure that your hosting provider (your own development environment) has PHP 5.3+ installed.  


2: Zend Framework

Zend Framework is an open source, object-oriented web application framework written in PHP. Zend Framework is backed by Zend Technologies, a for-profit company specializing in PHP and Web Development & Consulting. Zend Framework has extensible MVC implementation supporting layouts and PHP-based templates out-of-box. Like Symfony 2, Zend Framework 2.0 also requires PHP 5.3+ and doesn't support backward compatibility.You should ensure your server environment has met the version requirements.


3: CakePHP

CakePHP  also follows the MVC esign pattern and aims at helping developers to make a rapid development on PHP applications. Compared to Symfony and Zend Framework, in my own perspective, CakePHP feels "smaller" and can be tapped into new projects very quickly by a junior PHP developers (with months to a year experience in PHP programming). CakePHP's Model approach is a bit Ruby on Rails-lish because it exibits similarly with ActiveRecord in Ruby on Rails (although it isn't exactly an AR implementation).




4: Yii Framework

Yii is a high-performance MVC framework in PHP that comes with a great deal of rich features. One of features I personally like is its build-in authentication support. Since it supports authorization via hierarchical role-based access control (RBAC), you can use it a case-base for you CMS-like project - Drupal guys, it's time to roll out your own CMS!


5: CodeIgniter


CodeIgniter is a powerful PHP MVC framework with a small footprint. It has less automatic-generated codes than Symfony 1.x and it allows developers to fully control of application flow. For many core developers, less automatic codes is a HUGE plus since they are given with more freedom to write custom application logic without "hijacking" or "dissecting" on what had been built. Disclosure: I like light-weight, small footprint framework as well.


6: Kohana Framework

Kohana is an open source, object oriented MVC web framework built using PHP5 by a team of volunteers (former CodeIgniter developers) that aims to be swift, secure, and small. More precisely, Kohana is a HMVC framework, which H stands for "Hierarchical". Hierarchical MVC pattern allows multiple MVC parts (known astriad) in a single web application. A triad can request access or communicate to another triad via their controllers. Due to the nature of HMVC, HMVC pattern hasn't been used widely in web application developments. However, more or less, Drupalguys have explored the similar idea of composing the hierarchical structure of agents (each consisting of a triad of presentation, abstraction and control parts) in Drupal cores & modules.

In my own point of view, Cascading Filesystem is what makes Kohana stands out of crowd. HMVC in Kohana comes from the heirarchy of similar directory structures that cascade. Another win-out point is Kohana doesn't generate database codes for its developers.