Wednesday, May 4, 2011

Cloud Computing part-2 Windows Azure

Hello,

This is going to be theoretical blog. In my last blog on cloud computing I explained what exactly is cloud computing.  In this blog I will explain why one should go for cloud computing. Mostly it will be related to Microsoft Windows Azure .Recently I attended a Windows Azure Training Camp where speaker gave a good example of it.

First of all let's see how windows azure works. Cloud computing is all about virtulization. When you deploy your application on azure cloud your application is actually running on virtual machine. Here you can configure number of instance of application. For example if you set number of instances to three. Your application is running on three different virtual machine. Application load is automatically balanced between these virtual machines. You don't have to worry about anything. So this is how windows azure works. Now let's see an example on how windows azure can help you.

Consider you have created an application which consumes more server resources than any other application. Now initially you have 100 users of application. So you buy a server and deployed your application. You are happy, your users are happy too. Now number of users increase to say 1000. Now your single server can not fulfill requirements. Now your users are not happy. So you buy another server for load balancing. After some time again number of users increase and you have to buy another server. This is how you buy almost 20 servers. Each month you have to pay for those servers. Now suddenly number of users decrease and now you can run application only on 5 servers and this situation continues. So what about other 15 servers? Those servers are not utilized and are ideal and still you have to pay for each sever per month.

Now let's see power of Windows Azure. Consider same scenario as above with Windows Azure. Initially you application is running on tow instances. When number of users increase you simply have to increase number of instances. Now your application is running on 20 instances and you are paying for  20 instances per month. Now number of user decreases and you have to reset number of instances to 5. That's it now you don't need to pay for other 15 instances because you are not using it. You only have to pay for 5 instances that you are using.

So it gives you flexibility on number of instances of your application. Anytime you can change it and you have to only pay for the resources which are in use. So that's the power of cloud computing and windows azure.

Hope this posts help you. Being a programmer usually I don't like to write theoretical blogs but still it's necessary to write. Now next posts will be on examples windows azure.


Saturday, April 30, 2011

How to install or uninstall pear packages in xampp for windows

Hello

Recently I had some tough time installing pear packages in xampp so I am sharing procedure here so that it can help you.

First of all go to folder c:\xampp\php and find the file pear.bat. In my case I installed xampp in c drive. If its not in c drive go to the correct path and find pear.bat file.

Open that file in Notepad or Notepad++ to edit. Find the following line in in that file.

IF “%PHP_PEAR_INSTALL_DIR%”==”" SET “PHP_PEAR_INSTALL_DIR=\xampp\php\pear”


Add following line above this line.

SET “PHP_PEAR_INSTALL_DIR=C:\xampp\php\PEAR”


Now include c:\xampp\php to PATH environment variable.

In windows vista you can find it here.

Start->Control Panel->System and Maintenance->System->Advanced System Settings->Environment Variable

That's it and now go to command prompt and type command pear. You will see all the possible options for that command.

Use following command to install pear package.

pear install -o 'path of package'

Use following command to uninstall pear package.

pear uninstall 'pearname'

Generally name of pear is directory name inside php/pears folder.

Hope this post saves your time.

Tuesday, April 26, 2011

Use JavaScript to built multilingual web application

Hello,

Recently I was working on a project which requires multilingual support. Front end was built ExtJs so I decided to add multilingual support through JavaScript files. At a time of login user language is retrieved from database and respective language is downloaded on a client side then it can be used through out the app.

The approach is to store all language files in one common folder and from there it will be dynamically loaded using ScriptLoader.

For Example.

/root/languages/en.js
/root/languages/sw.js
/root/languages/fr.js

Each language file stores conversation in some common format. See the example below.


Ext.ns('WebAppName.language');

WebAppName.language = {
    PageTitle : "Welcome to The Site",
    HomePage : "This is HomePage",
    WelcomeMessage : "Welcome to the Web App"
};

Here Ext.ns is used to define namespace. Once namespace is defined it can be used any where in the app with that reference name.

Once any of above files are loaded it can be used as follow.

var title = WebAppName.language['PageTitle '];

Above code will assign "Welcome to The Site" string to title variable. Same way any other words can be loaded and used through out the app.

So this was the approach to built multilingual web app using JavaScript. This approach is useful when you are building front end using JavaScript frameworks like ExtJs, jQuery. Main advantage of this approach is it will be one time download a language file and all the values are available on client side so it does not require server request.

Please remember above code will work for ExtJs.