This tutorial shows you how to deploy a Rails app on AWS Elastic Beanstalk. This is part of a series on Running Rails in AWS.
In this post, I'll outline four basic options for running Rails on AWS and provide the details to help you decide which is best for your situation.
Is your app bogging down under the weight of increased traffic? Read this post to find out how to boost Rails performance and turn your app into Usain Bolt.
You may have to follow a few of the items listed here or all of them. Before you make any changes, make sure you identify the problem correctly and measure your application's response time. An improvement in the response time tells you that your changes are correct.
Amazon announced on August 29, 2017 that customers can now expand existing VPCs.
AWS customers can add up to 4 secondary CIDR blocks to an existing VPC. AWS cites two benefits of this new feature. First, customers can launch more resources (eg EC2 instances) in their VPCs on-demand. Second, customers don't have to over-allocate private IPv4 space when creating VPCs since you can add more in the future.
A typical Rails setup in AWS contains multiple EC2 instances running your application. Your database is in RDS or installed on another EC2 instance. When users upload images, you can't save the files locally. The images have to be stored in a location where all the EC2 instances have access.
Two AWS services that we can use are S3 and EFS.
S3 is an object storage service from AWS where you can store a massive amount of data easily. You pay per GB of storage without any minimum. It's used by Netflix to store billions of hours of contents and by Airbnb to store 10 petabytes of user pictures. You never have to worry about capacity planning. They'll always have room to store your images.
This checklist of Ruby on Rails Security Best Practices focuses on the development side.
Rails already provides a way to handle secrets. This has gotten better in 5.1 with the introduction of encrypted secrets. Find out how to use this feature and what you need to change on your current Rails application.
This post comprises of the following sections:
Secrets Without Encryption
Reading the Secrets
Advantages of Encrypted Secrets
Managing the Key
A Note on Secret Key Base