Where OS and its settings are stored in EC2 instance - amazon-web-services

Using ec2 Windows instance with Instance storage (let's say 32GB SSD) - where OS and its settings are stored? Like Program Files, User profiles. Are they all stored on Instance Storage? As far as I understood from other topics Instance storage is not-persistent and doesn't survive shutdowns/terminations. Does that mean I will lose everything under C: drive if I turn it off?
Can I use EBS storage as a default storage for OS (C drive)? Can I map multiple EBS storages to one Windows storage?
If above is true, then I will be charged for the capacity used by OS on EBS instance? It would be around 20GB I believe. Is that correct?
I am quite new in aws, and before paying for such instances or EBS I would like to know how this technical and billing model is working.
Thank you!

The Storage for the Root device is dependent on the AMI (EBS-Backed or Instance Store-Backed) used to launch the instance.
As far as I understood from other topics Instance storage is
not-persistent and doesn't survive shutdowns/terminations.
If the Root storage device is Instance Store, Stopping (shutdown) the instance is not possible. On termination, Both the storage and Instance does not survive. The Instance does not survive once terminated even if the AMI is EBS-Backed, but you can persist the Root Volume by setting the DeleteOnTermination flag set to False.
Does that mean I will lose everything under C: drive if I turn it off?
You cannot turn off (shutdown) an Instance Store-backed instance.
Can I use EBS storage as a default storage for OS (C drive)?
Yes, Choose an EBS backed Windows AMI.
Can I map multiple EBS storages to one Windows storage?
Yes, multiple EBS Volumes can be attached to one EC2 Windows Instance.
If above is true, then I will be charged for the capacity used by OS
on EBS instance?
You will be charged for the total size of the EBS volumes attached to the instance including the Root Device.
It would be around 20GB I believe. Is that correct?
The EBS Volume Size is adjustable. The upper Size limit is 16TiB.
Read Storage for Root Device and Ec2 Root Device Volume

Please spend more time on the AWS documentation, I don't think here is enough to cover all your question.
Only for specify EC2 instance come with attached SSD storage AKA instance storage. Bare in mind that, this instance storage doesn't come with Snapshot capabilities, so you must backup the file yourself. This is mean for people who need fastest disk access to process their data.
Only EBS allow you do multiple snapshot.
You can always create an AMI image for your instance after complete the deployment. AMI image is store inside EBS, so you will not lost the initial instance if you do this, so for new instance, you just trigger load it from AMI.
If you "Terminate" an instance, it will delete the virtual image. There is no way to recover it even with EBS, unless you make a snapshot. However, attached EBS storage will not be deleted.
EBS is calculate by Per GB and give you 1GB x 3 IOPS, with base 100 IOPS given. This is not enough if anyone want to carry out disk I/O intensive task.

Related

difference between hibernating and stopping an EC2 instance?

Obviously, hibernation and stop are two different actions that I can select.
What's the difference?
Benefit of Hibernating over Stopping
The memory state is preserved
Since the memory state is perserved and loaded again when the instance start, this reduce the boot time of the instance.
The long running process can continue without interuption
A great benefit if you have some services that take a great amount of time to fully initialized
Under the hood
The whole hibernation process in visual:
When the instance is in Stopping state, the instance memory is persisted in the instance's EBS root volume, and is loaded again when the instance start.
Reference
AWS Instance Hibernate Overview
From the docs
When you hibernate an instance, Amazon EC2 signals the operating
system to perform hibernation (suspend-to-disk). Hibernation saves the
contents from the instance memory (RAM) to your Amazon Elastic Block
Store (Amazon EBS) root volume. Amazon EC2 persists the instance's EBS
root volume and any attached EBS data volumes. When you start your
instance:
The EBS root volume is restored to its previous state
The RAM contents are reloaded
The processes that were previously running on the instance are resumed
Previously attached data volumes are reattached and the instance retains its instance ID
Read more
TL;DR
When you stop your instance, the data stored in memory (RAM) is lost.
When you stop-hibernate an instance, AWS signals the OS to perform hibernation (suspend-to-disk), which saves the contents from the instance memory (RAM) to the Amazon EBS root volume.
From the charging perspective, AWS does not charge usage or data transfer fees for your instance after you stop it, but storage for any Amazon EBS volumes is still charged.
A practical example
Suppose you want to build a caching layer (e.g. on top of your DB) in an EC2 instance. For such a case, the stop-hibernate feature would be instrumental in persisting storage. It would prevent you from having to manually create scripts to save the RAM data before shutting down the server.

Is volume in aws like a hard drive that the instance uses?

I am learning about aws and using ec2 instances. I am trying to understand what a volume is.
I have read from the aws site that:
An Amazon EBS volume is a durable, block-level storage device that you
can attach to your instances. After you attach a volume to an
instance, you can use it as you would use a physical hard drive.
Is it where things are stored when I install things like npm and node? Does it function like the harddrive o my server?
AWS EBS is block storage volume, and for the ease of understanding, yes you can consider it same as hard drive, however with more benefits over traditional hard drive. few of them are:
You can increase/decrease size of the storage as per your requirement
(Hence name Elastic)
You can add multiple ebs to your instances, for example 20 GB of volume1 and 30 GB of volume2
And for the question you asked if you can install npm & node yes you
can as it would be attached to your EC2 instance and your instance
can easily utilised attached data, modules,etc
For further explanation you can refer this user guide from AWS on EBS: https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/ebs-volumes.html
Yes it is exactly like a hard drive on your server and you can have multiple devices.
The cool thing is that you also can expand them if you need extra space.
where things are stored when I install things like npm and node
Yes, technically ebs volume is virtual storage drive which is
connected to your instance through network, ( flash drive connected over network).
Since network is involved which implicitly means there will be some latency because of data transfer through network.
The data is persistent even if instance stops,terminates, hibernates or hardware failure.
Since it is network drive it can be attached or detached to any other instance.
Adding to this there is another type of storage which you will find called as instance store
You can specify instance store volumes for an instance only when you launch it. You can't detach an instance store volume from one instance and attach it to a different instance.
it gives very high IOPS because it is directly (physically) attached to instance.
The use case for instance store would where data changes rapidly like for cache or buffers.
Your data will be lost if any of these events happens like The underlying disk drive fails The instance stops, instance hibernates instance terminates or drive failure.

EC2 Instance Storage: pricing and persistence

I have purchased an EC2 Reserved Instance. Its a t3large in some region, lets say r1. I want to install MySQL on this instance.
Now when I create the EC2 instance (t3large in r1), I come to the Storage tab:
8GB is too small for this server, I want the instance to have 100GB storage.
Questions:
If I change the storage from default 8GB to 100GB, would the instance attribute still match my reserved instance? Or because the storage is different I will be charged the On Demand rate?
Lets assume I change the default 8GB to 100GB, is this storage persistence? I have heard that instance store is not persistence... but I am not really sure if this 100GB is within the instance store? Also if this storage is not persistence, how should I add persistence storage to my EC2?
I'm pretty sure reserved instances don't cover the cost of EBS, but I can't find any document that states that at the moment. So you can choose however much storage you need. You'll pay for that separately.
t3.large doesn't have instance storage (list of instances that do). You're adding EBS storage which is network attached. It will be deleted when the instance is deleted (unless it's a secondary drive where you chose not to delete it with the instance).

AWS t2.micro instance

I have one service running on my t2.micro instance. How can i confirm if there is any bandwidth and storage limit or not.
Attached is that status screen shot of it.
Please guide me on this.
Thanks
Bandwidth
The only bandwidth limitation in AWS is related to the Instance Type of Amazon EC2 instances.
Put simply, smaller instances have less bandwidth than larger instances. You'll see this in the Launch Instance screen (right column):
The documentation doesn't specifically say what bandwidth you are given, but you can run some performance tests to determine available throughput.
Storage
There are two types of disk storage for Amazon EC2 instances:
Instance Storage
Amazon Elastic Block Store (EBS)
Instance Storage is disk storage that is directly-attached to the instance (or, more accurately, to the host computer running the instance). As you'll see in the Instance Storage column in the above picture, not all EC2 instances have Instance Storage -- some of them just say "EBS only", meaning that it is not available.
For instance types that provide Instance Storage, the size is fixed and is again based on the Instance Type.
The most important thing to know about Instance Storage is that it is lost when an instance is stopped/terminated. This is because the virtual machine is deleted, which gives back the CPU, RAM and Instance Storage. Thus, it is only useful for temporary files, virtual memory swap files and local cache. Do not store the only copy of important data on Instance Storage.
Amazon EBS is network-attached storage. Data is retained when instances are stopped. When they are later started, the disks are exactly the same as when the instance was turned off. When an instance is Terminated, the EBS volume can optionally be kept or deleted.
EBS volumes have the advantage that you can configure a disk of any size up to 16TB and there are various different types of volumes to trade-off cost/performance.
Bottom line: Your t2.micro instance has no Instance Storage. It has EBS volumes that you have attached (at whatever size you configured). It has Low to Moderate network bandwidth.

Difference between Memory, Instance Storage and Volume in AWS

I am new to AWS functionality and is confused in these 3 things.
To me if I consider
Memory as the RAM
Instance Storage as the hard disk space
then what is size and volume type means?
When you launch an instance on EC2, Amazon has to look for a physical server that will host your instance with enough unallocated capacity to be able to run your instance.
In the case of an m1.medium instance, this physical host would need to have enough unallocated resources so that the m1.medium instance specs would fit into it:
at least 1 unallocated core
at least 3.7 GiB of unallocated RAM
at least 1 disk with 410 GiB of unallocated space
So, from this description you see that "Memory" is the amount of RAM and "Instance Storage" is the amount of disk space inside the physical host that is running your instance.
Note that, I insist, this "Instance Store" is disk space local to the physical host. What does this imply? Well, if you stop the instance, you will deallocate all those resources so that another customer can use them. This means that you will deallocate the cores, the RAM and the disks. Which means the data saved on Instance Store is lost when you stop/terminate the instance, or whenever the physical host running the instance fails for whatever reason ("Everything fails, all the time" -- Werner Vogels, CTO at Amazon). This is why Instance Store is called ephemeral storage.
If you want persistent storage, then you'd need to use a service called Amazon EBS -- Amazon Elastic Block Store. In EBS, you create volumes. EBS Volumes are a kind of network attached storage. You can attach a Volume to any EC2 Instance in the same Availability Zone, then you can detach without losing data, then attach to another instance, and so on. When you stop an Instance, you don't lose data stored on EBS Volumes -- this is why they are called persistent storage.
In the screenshot in your question, what you see is that the Root volume (i.e., the "disk" where your operating system will be running) is an standard EBS volume (there's another kind of EBS volume, called PIOPS). This implies that any OS settings you change (and save to the root volume) will be persisted and survive an stop-start sequence, or instance restarts due to crashes.
There are some AMIs (Amazon Machine Images) that use Instance Store as the Root Volume. Instances launched with those AMIs won't persist any changes to the OS settings that are saved to the root volume -- therefore, if you stop them and start them again, you'd get a fresh OS.
I hope this answers your questions.