Sep 13, 2021 • 3 MIN READ
The Web Engineering Team at Ayazona looks after hosting several web services on AWS EC2 based on EBS. Here, we take a high-level look at how we do it and how we manage updates and improvements to this system.
One of our goals of moving our production services from Firebase Functions to AWS EBS was to help demystify our infrastructure and have better options for configuring our workspace and making the most of the dockerization capabilities.
This post marks our first engineering article where we highlight how we use EC2 (AWS Elastic Compute Cloud) and EBS (AWS Elastic Beanstalk) to host critical web services that our Software Engineers build and improve every day.
Before deciding to move our web services to AWS we relied on Firebase Functions to manage our hosting services, based on GCP instances, which performed well until our services outgrew the capabilities of Firebase. We still use Firebase Functions for our staging environment.
Amazon Elastic Compute Cloud (Amazon EC2) is a web service that provides secure; resizable compute capacity in the cloud. It is designed to make web-scale cloud computing easier for developers. Amazon EC2’s simple web service interface allows you to obtain and configure capacity with minimal friction. It provides you with complete control of your computing resources and lets you run on Amazon’s proven computing environment.
It comes preinstalled with the software required to make it a usable computer, like an operating system (you can assume Linux for now - others are available, though), so it can be booted up and run processes - more on that later.
A few different uses, but the most common use is in an ECS Cluster, a grouping of EC2 machines used as a home for EBS Tasks - these are the Dockerized containers of our applications running with a command specified by the engineer in a config file.
EBS is AWS's Elastic Beanstalk. It is an orchestration service that provisions and operates the infrastructure and manages the application stack (platform) for you, so you don't have to spend the time or develop the expertise. It will also keep the underlying platform running your application up-to-date with the latest patches and updates. Instead, you can focus on writing code rather than spending time managing and configuring servers, databases, load balancers, firewalls, and networks.
An engineer can upload the code, and Elastic Beanstalk automatically handles the deployment, from capacity provisioning, load balancing, auto-scaling to application health monitoring. At the same time, you retain full control over the AWS resources powering your application and can access the underlying resources at any time.
Based on a need, say during a high traffic demand, EBS makes sure that at all times, there is at least one healthy instance of their Docker container running on any one of the EC2 hosts. This is the desired number of tasks - if the number of running tasks is less than this, EBS will start more containers to reach the desired number. If there are more than desired, EBS will safely terminate running containers to reach the desired number.
This takes us back to our cluster of EC2 machines. EBS will find an EC2 machine in the cluster with enough spare capacity to hold and run the task (i.e. it has enough spare reserved CPU and memory - which is specified in the config file). There are some other rules in place regarding which Availability Zone your task is running in (we don’t want all your eggs in one basket), but for the most part, we leave it to EBS to decide.
It is impossible to outgrow EBS with our current setup. It automatically scales our applications up and down based on the applications' specific need using easily adjustable Auto Scaling settings. For example, we can use CPU utilization metrics to trigger Auto Scaling actions. With EBS, our services can handle peaks in workload or traffic while minimizing our spending.
The one critical adjustment we may need to make in the future is to switch from EBS to ECS, giving us more control over the configuration, but for now, EBS is the way to go.
Want to work with our engineering team? We’re hiring! Check out our current Engineering openings.
More from Engineering