Can an aws instance fail? Do I need backups?
You will definitely need a backup! When running a single EC2 instance to host a webserver and that EC2 instance fails, your data will be gone. There are no automatic backups if you just fire up an EC2 instance without further configuration (i.e. make the root volume an EBS volume).
EC2 instances can fail and this must be part of your architectural concept. Usually, AWS announces before an AWS is scheduled for retirement, however, I’ve seen instances fail without any warning. I recommend to regard them as ephemeral and assume that they can fail at any time.
From the AWS documentation:
An instance is scheduled to be retired when AWS detects irreparable failure of the underlying hardware hosting the instance. When an instance reaches its scheduled retirement date, it is stopped or terminated by AWS. If your instance root device is an Amazon EBS volume, the instance is stopped, and you can start it again at any time. Starting the stopped instance migrates it to new hardware. If your instance root device is an instance store volume, the instance is terminated, and cannot be used again.
From https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/instance-retirement.html
Also:
- Regularly back up your EBS volumes using Amazon EBS snapshots, and create an Amazon Machine Image (AMI) from your instance to save the configuration as a template for launching future instances.
- Deploy critical components of your application across multiple Availability Zones, and replicate your data appropriately.
- Regularly test the process of recovering your instances and Amazon EBS volumes if they fail.
From https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/ec2-best-practices.html, section Backup and Recovery
So depending on the uptime you’re trying to achieve, it can be advisable not to run just a single EC2 instance, but multiple and add them to a load balancer. Based on a health check you can configure, it will take care of replacing faulty instances automatically.
You might also want to consider hosting your website on AWS Elastic Beanstalk, which can take care of setting up the required infrastructure for you.