Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the purpose of 'Reservations' in Amazon EC2

I'm just starting to explore amazon ec2. And I want to hear some explanations or may be some brief examples of how and why do you need 'reservations' in amazon ec2. I'm using python framework boto to manage Amazon Service. And so far I don't really see any reasons why do we have this extra step in order to get your instances, for example:

reservations = ec2.get_all_instances() instances = [instance for res in reservations for instance in res.instances] 

That's how I get all my instances, some times I do it like this:

reservation = ec2.run_instances(image_id, min_count, max_count, key_name .....) instance = reservation.instances[0] 

And than I use those instances to attach volumes, add tags, add security groups and so on.... But what is the purpose of boto.ec2.instance.Reservation (I'm not asking only about boto framework, of course its preferred, but in a whole meaning of this in Amazon EC2)

>>> reservation = reservations[0] >>> reservation Reservation:r-74d11509 >>> dir(reservation) ['__class__', '__delattr__', '__dict__', '__doc__', '__format__', '__getattribute__', '__hash__', '__init__', '__module__', '__new__', '__reduce__', '__reduce_ex__', '__repr__', '__setattr__', '__sizeof__', '__str__', '__subclasshook__', '__weakref__', 'connection', 'endElement', 'groups', 'id', 'instances', 'item', 'owner_id', 'region', 'startElement', 'stop_all'] >>> reservation.__class__ <class 'boto.ec2.instance.Reservation'> 

I couldn't find any useful methods. Please explain me why do we need this? What's the reason it to be there? In what cases you would use it?

like image 850
Vor Avatar asked Mar 25 '13 15:03

Vor


People also ask

What is the use of reserved instance?

Reserved Instances are automatically applied to running On-Demand Instances provided that the specifications match. If you have no running On-Demand Instances that match the specifications of your Reserved Instance, the Reserved Instance is unused until you launch an instance with the required specifications.

What is a reservation instance?

Reserved Instances are not physical instances, but rather a billing discount applied to the use of On-Demand Instances in your account. These On-Demand Instances must match certain attributes, such as instance type and Region, in order to benefit from the billing discount.

What is benefit of choosing reserved instance over on Demand instance?

In terms of compute options and configurations, Reserved Instances and On Demand instances are the same. The only difference between the two is that a Reserved Instance is one you rent (“reserve”) for a fixed duration, and in return you receive a discount on the base price of an On Demand instance.

What is scheduled reserved instance in AWS?

With Scheduled Reserved Instances, you can reserve capacity that is scheduled to recur daily, weekly, or monthly, with a specified start time and duration, for a one-year term. After you complete your purchase, the instances are available to launch during the time windows that you specified.


2 Answers

From my understanding, a reservation is an act of launching instances. Basically, a reservation is what you do, while an instance is what you get. If you launch multiple instances from one image via run_instances() you make one reservation, but get multiple instances.

run_instances together with Reservation.stop_all() allows you to run a bunch of instances, wait for them to complete the task and then stop them all at once.

like image 115
georg Avatar answered Oct 04 '22 07:10

georg


From the boto docs:

A reservation corresponds to a command to start instances. You can see what instances are associated with a reservation:

>>> instances = reservations[0].instances >>> instances [Instance:i-00000000] 
like image 20
Rose Perrone Avatar answered Oct 04 '22 05:10

Rose Perrone