Knowing how IP addresses work in AWS is very important when you use EC2 instances to build your infrastructure on cloud. It could be a simple website or a large application that you are building, it’s very important to understand what’s the difference Private IPs, Public IPs and Elastic IPs.
But don’t worry! I’ll break it down with simple, everyday examples to help you get the hang of it.
Private IP: Your House Address in a Gated Community
Imagine you live in a private, gated community. You have an address (private IP) that allows people within the community to find and communicate with you, but people outside the gate cannot reach your home directly.
Similarly, a private IP address in EC2 is used for communication inside a private network. Other machines on same network can talk to each other using private IPs, but these machines can't be accessed by outside world (internet) unless special steps are taken. This keeps things secure and organized within your AWS environment.
Public IP is similar to your mobile number. If someone wants to reach you from anywhere across the globe and if they have your mobile number, they can simply dial your number. Likewise, public IP helps in accessing your EC2 instance from any part of internet world. You will be using a public IP when you wish to allow people over internet to access your website or application.
For example, if you host a website on your EC2 instance, the Public IP is what people would use to visit your website.
But, here’s the thing: if you restart your EC2 instance, AWS may give it a new Public IP – much like how your phone number changes every time you turn off/on your phone! (Don’t worry, this doesn’t actually happen in real life with your phone! Just imagine it for a moment so that you understand the idea behind EC2). So how do we ensure that our “phone number” stays the same even after restarting? That’s where Elastic IP comes in!
Elastic IP: Your Permanent Address
This is where Elastic IPs come in picture. Consider this, what if your phone number would have never changed, no matter you restart your phone or change city! Exactly an Elastic IP does pretty much the same thing, it provides your EC2 instance a fixed public IP and that too remains same across instance restarts/replacements.
This is particularly handy if you’re working on a website or service that you want to always be reachable at the same address, e.g. if you’re hosting a business website and don’t want your customers to have to look up where to find you.
That said, AWS only grants you five Elastic IPs for free, so it pays off to spend them wisely. Rather than overusing Elastic IPs it’s better practice and easier to use a proper DNS service like Route 53 to map a domain name (e.g. mywebsite.com) to an ever-changing public IP address.
EC2 Placement Groups: Managing How Your Servers are Positioned in the Cloud
When you run multiple EC2 instances how they are “placed” in AWS’s infrastructure can affect their performance and availability. AWS offer something called Placement Groups to help you control how your instances are positioned.
Cluster Placement Group: All Servers in One Super-Speed Hub
Let's say you're hosting an epic esports tournament. Your players need to talk to each other fast, or the game comes crashing down. In a Cluster Placement Group, all of your EC2 instances are placed closely together within a single availability zone for the lowest latency and fastest networking possible.
This is good if you need low-latency group-to-group communication between your servers, like for real-time data processing. But if the power goes out in that "stadium," all your servers will go down, which is the main risk of this setup.
Spread Placement Group: Servers Spread Out Like Branches of a Franchise
In a spread placement group, each server is placed in a distinct rack, which means they are connected to different switches and power distribution units (PDUs).
Let’s say that you have a chain of restaurants, and you want each restaurant to be in a different city. That way if one of them has problems, the others don’t get affected. A Spread Placement Group does exactly that, it takes your EC2 instances and it spreads them across multiple availabilities zones in multiple physical hardwares making sure that you have the least chance as possible to have all your instances down at the same time.
This is strategy is perfect when dealing with critical applications where you should maximize availability. However yo can only have 7 instances per availability zone with this strategy
Partition Placement Group: The Warehouse with Multiple Storage Sections
Now, let's say you have a giant warehouse in which each section stores different things. You want to make sure that if there is a problem in one section, it doesn't affect the others. In a Partition Placement Group, your instances are divided into sections (partitions) all on different racks of hardware if something happens on one partition it does not effect the other partitions.
This is ideal for big data applications, like running Hadoop or Cassandra or Apache Kafka, where you need to manage hundreds of instances efficiently.
Elastic Network Interfaces (ENI): Network Adapters for Your Instances
An Elastic Network Interface (ENI) is like a SIM card in your phone, if you can imagine. If you take the SIM card out of one phone and put it into another, then essentially that other phone now has the same identity because the number is still associated with that SIM. Similarly, an ENI is something that you can attach to or detach from EC2 instances and effectively give them the same network identity.
Why Would You Need It?
Let’s say you run an online store, and your payment server is struggling. In order not to lose sales, you decide to swap your ENI (your “SIM card”) with another healthier server. Your customers don’t notice anything and keep shopping because the network identity doesn’t change. ENIs can hold IP addresses, security groups, and more — so it’s easy to swap network configurations between instances.
EC2 Hibernate: Pausing Your Work Without Shutting Down
Have you ever put your laptop into sleep mode instead of shutting it down completely? When you wake it up, all your apps are still open, and you can jump right back into what you were doing. EC2 Hibernate does this for your instance.
When you hibernate an EC2 instance, it hibernates the instance and saves its in-memory state (including all open applications, application data, and so on) to your Amazon Elastic Block Store (Amazon EBS) root volume. When you start the instance again, it reads the saved state from your Amazon EBS root volume.
This is especially useful for long-running workloads or when an instance takes a while to set up or warm up because you don't have to reestablish a connection or restart work that's already done.
I will catch you in next post where we will see more new exciting AWS concepts. Stay tuned and if you have any queries put it in the comments below.I will catch you up in my next one till then Happy Learning! :)
Top comments (0)