AWS Elastic Beanstalk is a Platform as a Service (PaaS) offering from Amazon Web Services (AWS) that makes it easy to deploy, manage, and scale web applications and services. It abstracts away the underlying infrastructure details and automatically handles the deployment of a web application, from capacity provisioning, load balancing, auto-scaling to application health monitoring. This allows developers to focus on writing code rather than managing underlying infrastructure.
At the same time, you retain full control over the AWS resources that are powering your application and can access them at any time. While it abstracts away the complexity of managing infrastructure, it still allows you to retain full control over the underlying AWS resources powering your application. This is important for several reasons:
Flexibility: By retaining control over the AWS resources, you have the flexibility to customize and configure them according to your specific requirements. You can choose the instance types, storage options, networking configurations, and other settings that best suit your application.
Performance Optimization: Full control over AWS resources allows you to optimize performance by fine-tuning configurations. For example, you can adjust instance sizes, add caching layers, or configure load balancers to improve performance and scalability.
Cost Management: Having visibility and control over AWS resources helps you manage costs more effectively. You can monitor resource usage, identify cost drivers, and make adjustments to optimize cost-efficiency.
Compliance: Some industries or organizations may have specific compliance requirements that necessitate full control over resources. With Elastic Beanstalk, you can ensure compliance by configuring resources according to these requirements.
It's worth emphasizing that using Elastic Beanstalk does not incur any extra costs. Instead, you only pay for the AWS resources required to store and operate your applications. You can learn more about its pricing here.
Reviewing some concepts
Application: In Elastic Beanstalk, an application is a logical container for your web application and its associated resources. Think of it as a folder. It helps you manage and organize your application components, including environments, versions, and configurations.
Environment: An environment is a collection of AWS resources that run your application. This includes EC2 instances, load balancers, databases, and other resources necessary to host your application. Each environment corresponds to a specific version of your application.
Environment Tier: Elastic Beanstalk offers two environment tiers:
- Web Server Environment: This tier is used for web applications that serve HTTP requests. It typically includes a load balancer to distribute traffic among multiple EC2 instances running your application.
- Worker Environment: This tier is used for applications that perform background tasks, such as processing messages from a queue or performing batch jobs. It does not include a load balancer and is optimized for tasks that do not require direct user interaction.
Application Version: An application version is a specific iteration of your application's code that you deploy to an environment. Each version is identified by a unique version label and can be deployed to multiple environments.
Configuration: Elastic Beanstalk allows you to configure various aspects of your environment through configuration files or the management console. This includes settings such as instance type, auto-scaling parameters, environment variables, and more. Configurations can be saved and reused across environments.
Auto Scaling: Elastic Beanstalk provides auto-scaling capabilities to automatically adjust the number of EC2 instances in your environment based on traffic levels. You can define scaling triggers based on metrics such as CPU utilization, network traffic, or custom metrics.
Environment Health: Elastic Beanstalk monitors the health of your environment and takes corrective actions to ensure high availability. This includes replacing unhealthy instances, adjusting auto-scaling settings, and triggering alarms based on predefined thresholds.
Steps to deploy a sample Python application
Now that we know some basics, let's try to deploy a sample application. Navigate to the Elastic Beanstalk console and create new application.
After this, on the left sidebar, you will see the application created. Click on the application.
Then Click on create new environment at the top right. You will then run through a series of steps, instructing Beanstalk on how to build our web application.
You will need to configure you environment based on the web application that you want to deploy. Elastic Beanstalk supports a wide range of web applications and frameworks including Java ( using Apache Tomcat, Java SE, or Java with Docker containers), .NET (using IIS and Windows Server), Nodejs, PHP, Python, Ruby, Go, and last but no least Docker (supports applications packaged as Docker containers, allowing you to use any language, framework, or runtime that can run in a container).
Since our aim is to deploy a sample python web application, we will use a Web Server environment.
Next, you can choose an environment name or use the autogenerated one. You may also enter a domain name or use one that will be autogenerated.
Next, we will choose the python version that we want to use. You may choose the appropriate version for your application. For this demo, we will use the latest versions available.
We then select the application we want to deploy. At the moment, since we don’t have code, we can deploy the sample application, which we can change at a later stage to the python application we want.
The next section, Service access, has to do with IAM roles that will give elastic beanstalk the appropriate permissions to set up and run our application with the appropriate permissions.
Even though Elastic Beanstalk is setting up and managing the environment, it is possible to log into your EC2 once it’s running. You can create the EC2 key pair and specify it here. Since I had created an application on elastic beanstalk, I already have some roles defined that can be used. You may choose the “Create and use new service role” to create roles as needed.
The following section covers network and database configurations. You can select the Virtual Private Cloud (VPC) and the specific subnets where you want your instances to run.
Next, should your application need a database, you might need to configure some database settings. Since ours doesn’t at the moment, we can skip this part. Should you need a database, toggle the option to enable, choose the subnets you want it to be deployed to, and update the settings such as the Engine you want, instance class of the compute that will run your database, the amount of storage you need and configure your database credentials as well.
At step 4, you will configure more aspects of the EC2 instances that run your application. These aspects include The number of gigabytes of the root volume attached to each instance, Input/output operations per second for a provisioned IOPS (SSD) volume, the amount of throughput desired, security groups (you can choose the default or create your own) and configure CloudWatch monitoring as well.
You can also configure the compute capacity of your environment and specify aspects such as the environment type, number of instances you need among other settings based on your needs.
In the next tab, you can configure various monitoring and logging aspects of your application. You can then review your settings and create the environment
Once you click on create, you can monitor the events that are happening on the dashboard of your environment.
After a while the environment will launch successfully
You may visit the url for your deployed application
With our simple Python application now successfully deployed on Elastic Beanstalk, our next step involves exploring the deployment of a Dockerized container. This will further enhance our understanding and utilization of Elastic Beanstalk's capabilities, allowing us to leverage containerization for our application deployment in future articles.
Top comments (0)