Chinaunix首页 | 论坛 | 博客
  • 博客访问: 3049272
  • 博文数量: 535
  • 博客积分: 15788
  • 博客等级: 上将
  • 技术积分: 6507
  • 用 户 组: 普通用户
  • 注册时间: 2007-03-07 09:11
文章分类

全部博文(535)

文章存档

2016年(1)

2015年(1)

2014年(10)

2013年(26)

2012年(43)

2011年(86)

2010年(76)

2009年(136)

2008年(97)

2007年(59)

分类: 系统运维

2009-12-15 11:39:55

Working with virtual infrastructure is not a whole lot different than using real hardware, but it's easy to get confused when things are different. In this article I'll take a look at the life cycle of Amazon EC2 instances and how it differs from the traditional life cycle of real computers.

The Life Cycle of "Real" Computers

By "life cycle" I mean "the different stages that a computer goes through from power-on to power-off". This is best explained with a diagram:

Real computers begin their service lives "off". Someone hits the power button and the computers start booting up, eventually settling into a "running" state. From there they can be rebooted, hibernated, suspended, or shut-down normally. (Of course, something abnormal can happen, such as a power failure, which would cause the machine to immediately return to the "off" state. This is not represented in the diagram above.)

The diagram highlights two important features of the life cycle of real computers:
  1. Real computers cost you money even when they are not in use. Of course they consume power when they are on, and you pay for that power. But even when they are off they cost money, if only for the space that they occupy. This is represented in the diagram by the green box: real computers cost you money no matter if they are in use or not.
  2. Even when they are "off", real computers remain yours. The information stored on their hard drives stays there, waiting to be accessed the next time the machine is powered on. This is represented by the arrows leading into and exiting the "off" state: even if you turn a computer off, you can still turn it on again.

The Life Cycle of EC2 Instances

The above two features of real computers, costing money and being yours to control, are different for virtual computers in the cloud. Different clouds have different features, but the Amazon EC2 instance life cycle looks like this:

EC2 instances begin their lives when you launch them (such as with the ec2-run-instances command). They spend some time in the "pending" state, waiting for the reservation to be fulfilled. Once the instances have begun to boot they are in the "running" state. Here they will stay until they are terminated (such as with the ec2-terminate-instances command), which causes the instances to begin "shutting down", ending with the instances being "terminated".

The above diagram illustrates how EC2 instances are different than real computers as far as costing money and being yours to control is concerned:
  1. EC2 instances only cost money when they are "running". You do not pay for instance-hours for pending, shutting down, or terminated instances. This is represented in the diagram by the green box, which only surrounds the "running" state. This is unlike real computers, which cost money even when they are off.
  2. Once an EC2 instance is no longer "running", you no longer control it. In the diagram, there is no way to get an instance from "shutting down" back to "running". This means that you cannot get back an instance that was terminated - the data stored on that computer's local disks ("ephemeral storage") can not be retrieved. Real computers, on the other hand, are still controlled by you when they are not running - all you need to do to access their data is to power them on.

Follow-on Questions

If the data that you place on the "ephemeral storage" of an EC2 instance is no longer accessible once you terminate it, what happens to the data? Specifically:
  • What processes does Amazon have in place to make sure that the ephemeral storage drives do not present a privacy risk, allowing other instances possibly belonging to other people to see the data left over on the ephemeral drives you have relinquished?
  • What can you do to mitigate the privacy risk of your leftover data on ephemeral storage, without relying on Amazon to do it for you?
If you can't restart a terminated instance and you can't access the data on a terminated instance, how do you accomplish in the EC2 cloud all the "usual" things that you do with real computers? Specifically:
  • How do you keep data and applications in EC2 without keeping an instance running?
  • How do you make sure that your data and applications can be easily restored if your instance terminates unexpectedly?
And, what does an AMI have to do with the life cycle model? What about the life cycle model changes if you bundle your instance into an AMI? (Spoiler: nothing).

These questions will be the subject of future articles, so stay tuned. Until then, remember that one of the major differences between real computers and EC2 instances is their life cycles: in EC2 you only pay for, and control, instances that are running. 
阅读(2699) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~