AWS EC2 - Rich man with secretary

Photo by Lukas on Unsplash

AWS EC2 - Rich man with secretary

AWS EC2 is a rich man serving requests coming from all around the world with a load balancer ahead of it. This rich man always has a secretary (root EBS volume) with him, to store everything he has.

Why use EC2?

To deploy and run an application, make your applications highly available for everyone across the world. Forget about the underlying hardware, and focus on running your application with a pay as you use model.

Security

To Protect this rich man, he has a bodyguard with him (security-group).

Security Group is a firewall for a ec2-instance. Here we can define the inbound and outbound rules for our server.

Storage

Every server has one root EBS volume attached to it. EBS volume is a storage device for EC2. You can attach & detach volumes to ec2 servers, but the root volume is the primary storage. EBS volume data is encrypted with KMS keys.

Status checks

EC2 performs automated checks on it every minute, to ensure both hardware and software are properly running. 2/2 status check means it's properly running, If its 1/2, then either CPU has been 100% for a long while, or there's a network problem, or the storage is full (100%).

  • How to debug it?

    Check ec2 system logs. If you don't find any logs for troubleshooting, detach the root volume, and attach this root volume to another ec2. Then mount this volume, and check /var/log/messages to find the issue.

Backups

We can take automated backups (AMI) of our EC2 servers using lifecycle manager.
These AMI's will have entire data our ec2-instance, and this feature of AWS is really useful, when there's an issue with existing server or you want to launch a copy of the server.

Monitoring

We can monitor our servers CPU, memory, disk usage using Cloudwatch alarms. Cloudwatch alarms are great when you want to do an analysis of the trends, patterns of server's cpu, memory usage. You can get alerts with aws sns when the alarm crosses the set threshold.