Copy EC2 instance to another region

Is it finally possible ? While the AMI import tool is long awaited for but only available for Windows, it is rather a big hazzle to transfer manually (see this) any other OS ( my last attempt in 2010).

Today Amazon announced the EBS Snapshot Copy Feature (across regions). The intention is certainly to allow easy migration of data to another region, as you can copy the snapshot, create a volume and attach it to an instance. I was curious to try if I can migrate my Ubuntu instance to another region and it worked. You can use both command-line as well the AWS web admin.

Running Ubuntu 12.04 Desktop on EC2

To say it upfront: Usually there is no need to run an Ubuntu server with a desktop in the cloud. Whatever you do on the desktop you can do in a terminal too (assuming you dont want to use GIMP in the cloud). Here a little summary to get you started with a Precise Pangolin desktop running in the cloud.

Security: We will not use VNC, but NX. VNC is not secure (though can be tunnelled through SSH) and it works by sending compressed bitmaps of the screen, which is slower and less accurate than a NX server (X Server calls, Unix/Linux only)

Requirements: Amazon AWS account

Step-by-Step

  • Log into your AWS account
  • Optional: Create a security group with port 22 inbound only
    Security Group

    Security Group

    Port 22 only

    Port 22 only

    Continue reading

Running EC2 spot instances

or ‘ Save ultimately more money with AWS’

I use EC2 instances for test, development, demo and also for deployment to production. Amazon offers different types of instances, ranging from a micro instance (613 MB Ram and 2 CPU units) to a full fledge Cluster Compute Quadruple Extra Large Instance (60GB RAM and 33 CPU units). Of course a different price and paid per hour usage, available anytime.

All on demand Linux instances (Singapore):

  • Micro instance: U$ 0.02 per hour
  • Medium instance: U$ 0.34 per hour
  • High Mem/CPU instance: U$ 2.024 per hour

On top of this there are 3 different categories of instances (in contractual terms)

Some price comparison for a m1.Large instance we use for testing (7,5GB RAM and 4 CPU units)

  • On Demand (any time without any contractual obligations, we are using them currently)
    $0.340 per Hour > 1 month U$ 244.80 (fulltime 24h)
  • Reserved Instance (1 year term, one time payment U$ 276.00)
    U$ 0.196 per Hour > 1 month U$ 141.12 (3 months: U$ 699.36 vs on-demand U$ 734.40, 12 months: U$ 1969.44 vs. on-demand U$ 2937.60 = ~30% savings )
  • Spot Instance (depends on availability, you bid on a price range, if price exceeds your limit your instance shuts down)
    U$ 0.04 per Hour (as of December 5th 2012) > 1 month U$ 28.80

The spot instance, almost at 10% of the on-demand price, is extremely attractive and I am using it as test server.
Not suitable for production or demo purpose though.

The reserved instance starts to break even after 3 months full-time usage !

In order not to pay for instances running idle (at night, weekend) they auto-shutdown and the user can start them in a self provision fashion (for test, demo or training).

Interesting enough, the price fluctuation is very different in the AWS regions. Lets look at a m1.large instance type in the Ireleand  versus Singapore datacentre.

AWS Ireland

AWS Ireland

 

AWS Singapore

AWS Singapore

Obviously Singapore customers are not into this bidding concept, it remains permanently at 4cts while for Ireland the price jumps up to several Dollars !

More information at:

Code Snippet: ZK controller reading URL parameter

How to pass parameters as part of the URL like http://….?name=Smith&first=John ?

ZUL page

<pre><?xml version="1.0" encoding="UTF-8"?>
<zk xmlns="http://www.zkoss.org/2005/zul">
    <window id="index" apply="controller.indexController" >
        <label value="Parameter 1:"/>
        <label id="lblPar1" />
        <label value=" - Parameter 2:"/>
        <label id="lblPar2" />
    </window>
</zk>

Controller

package controller;

import org.zkoss.zk.ui.Component;
import org.zkoss.zk.ui.Executions;
import org.zkoss.zk.ui.util.GenericForwardComposer;
import org.zkoss.zul.Label;

public class indexController extends GenericForwardComposer {

    private Label lblPar1;
    private Label lblPar2;

    @Override
    public void doAfterCompose(Component comp) throws Exception {
        super.doAfterCompose(comp);

        if (Executions.getCurrent().getParameter("parameter1") != null) {
            String par = Executions.getCurrent().getParameter("parameter1");
            lblPar1.setValue(par);
        } else {
            lblPar1.setValue("null");
        }
        if (Executions.getCurrent().getParameter("parameter2") != null) {
            String par = Executions.getCurrent().getParameter("parameter2");
            lblPar2.setValue(par);
        } else {
            lblPar2.setValue("null");
        }
    }
}

SVH20121203001

On Simulation and Engines II

My fascination would not end only using simulation software or games with a strong simulation focus, but the idea to produce your own software got my attention already back in the 80′s. At that time the access to decent hardware and software was rather limited and the only viable option was to use a Commodore C64 (anyone older than 35 and with some techy genes should know this little grey-brown box). I cant remember any title with a simulation context other than subLOGIC’s FS II and the only software that would allow the creation of games without coding in Assembler was Garry Kitchen’s GameMaker.

Fast forward to present time (2012): There are dozen’s of graphic, physics and game engines – both commercial and opens source – available, ready for developers to jump into the field. It would be tedious to list them up and compare features, there are some other websites doing this better (please look at devmaster.net). I like to highlight a few engines that I am following for a few years and which (imo) have some impact in the industry.

A major challenge to the simulation and rendering topic is the steep learning curve. Not only you need to excel in programming but understand the concepts of 3D rendering and physics in order to get started. Most engines today are using C++, even with wrapper for other languages available, due to the higher performance you achieve(d) with native C (++) applications compared with Java.

We need to distinguish 3 types of engines here:

  • Physics engine (does nothing but simulating physical systems with rigid body, soft body and fluid dynamics, inclusive of collision handling, without any graphical output)
  • 3D Rendering engine (software framework to visualize 3D content, usually on top of OpenGL or Microsoft DirectX)
  • Game (Simulation) Engine (combining the 2 features above and also offering GUI’s to create content and orchestrate flow and logic)

Continue reading

S3 for Backup

I use S3 for all kind of backup purpose, assuming S3 will be always available and the data/files are secure. Amazon offers a encryption of storage, but at the end of the day they are in control and not you. This encryption is rendered useless the moment someone picks up your AWS keys (I am not jumping into more paranoid scenarios covered under the Patriot Act where the US government may access your data, since Amazon is an US based company). I prefer to encrypt at the source, here a 2-liner to add to your backup procedure (Linux). You can even combine this with a cronjob including the S3 transfer using the S3cmd toolkit.

Encrypt on the fly:
tar cz whichfile | openssl des3 -salt -out whichfile.tar.gz.enc -k mysecretpassword

Decrypt and uncompress:
openssl des3 -d -salt -in whichfile.tar.gz.enc -out whichfile.tar.gz -k mysecretpassword
tar -xf whichfile.tar.gz

More:

On Simulation and Engines

I love technical simulations, such as flight or driving simulators, specifically that ones aiming to simulate real physical entities, in contrast to game software where the focus is entertainment and not realistic behavior. Of course, nowadays you cant draw a clear borderline between gaming and simulation  (for the PC market, not the industrial purpose simulator). Amazing to observe the development and evolution of software and underlying physics and graphics rendering engines over the last 30 years, I still remember getting my hands on Microsoft’s first version of the Flight Simulator from 1982 (its version history ended in 2006 with Flight Simulator X).
Due the hardware limitation of that time (typically 4.77 MHz IBM PC, 64K memory, 360K floppy , no harddisk !) the graphics were rather simple, not to say extremely simple, but still it made us being overly excited to use this simulator in the early 80′s. The software focused from the first version to be accurate on flying physics and navigation.

MS flight Simulator 1.0 Screenshot

30 years later we have such high level of graphical and physical rendering quality, that we almost simulate reality as-is. Hardware build in phones surpasses easily the capabilities of hardware of 80′s, you even get simulation software for tablets today.

The above screenshot is from the website  fshistory.simflight.com (the copyright belongs to them) and I ask you to drop by the website setup by Jos Grupping, unfortunately there are no updates since 2007, as well the Wikipedia entry.

Comparing to visual impact of the version X from 2006.

MS Flight Simulator X

On a side note: Microsoft restarted their effort to build a flight simulator with MS Flight, this time targeting the mass market with a more entertaining version. It is FREE to play, but Microsoft decided again to cease development and scrapped the project in July 2012. Download from here. Wikipedia Info.

In this series I will look further into the simulation software and underlying engines for Windows and Linux.