AWS Compute Services - Elastic Beanstalk Flashcards
Elastic Beanstalk Overview Allows you to quickly deploy and manage applications in the AWS cloud without worrying about the infrastructure that runs those applications. automatically handles the details of capacity provisioning, load balancing, scaling, and application health monitoring for your applications. its is a platform-as-a-service supports the following languages: GO java .NET Node.js PHP Pythong Ruby supports the following web containers: Tomcat Passenger Puma Supports Docker containers your applications domain name is subdomain.region.elasticbeanstalk.com
Elastic Beanstalk Overview
Environment Pages
configuration - shows the resources provisioned for this environment. this page also lets you configure some of the provisioned resources
health - shows the status and detailed health information about the EC2 instances running your application
monitoring - shows the statistics for the environment, such as average latency and CPU utilization. you also use this page to create alarms for the metrics that you are monitoring
events - shows any informational or errors messages from services that this environment is using
tags - key-value pairs that are applied to resources in the environment. You use this page to manage your environment’s tags
Environment Pages
Concepts
Application - a logical collection of Elastic Beanstalk components, including environments, versions, and environment configurations. It is conceptually similar to a folder.
Application Version - refers to a specific, labeled iteration of deployable code for a web application. An application version points to an S3 object that contains the deployable code. Applications can have many versions and each application version is unique
Environment - a version that is deployed on to AWS resources. Each environment runs only a single application version at a time, however you can run the same version or different versions in my environments at the same time.
Environment tier - determines whether Elastic Beanstalk provisions resources to support an application that handles HTTP requests or an application that pulls tasks from a queue. An application that serves HTTP requests runs in a web server environment. An environment that pulls tasks from an SQS queue runs in a worker environment.
Environment configuration - identifies a collection of parameters and settings that define how an environment and its associated resources behave.
Configuration Template - a starting point for creating a unique environment configuration
There is a limit to the number of application versions you can have. you can avoid hitting the limit by applying an application version lifecycle policy to your applications to tell Elastic Beanstalk to delete application versions that are old, or to delete application versions when the total number of versions for an application exceeds a specified number.
Elastic Beanstalk Concepts
Environment types
load-balancing, autoscaling environment - automatically starts additional instances to accomodate increasing load on your application
single-instance environment - contains one EC2 instance with an Elastic IP address
Environment Types
Environment Configuration
Your environment contains
Your EC2 virtual machines configured to run web apps on the platform you choose.
An Auto Scaling group that ensures that there is always one instance running in a single-instance environment, and allows configuration of the group with a range of instances to run in a load-balanced environment.
when you enable load balancing, Elastic Beanstalk creates an elastic load balancing load balancer to distribute traffic among your environment’s instances
Elastic beanstalk provides integration with RDS to help you add a database instance to your Elastic Beanstalk environment: mysql, postgresql, oracle, or SQL Server. when you add a database instance to your environment, elastic beanstalk provides connection information to your application by setting environment properties for the database hostname, port, user name, password, and database name.
You can use environment properties to pass secrets, endpoints, debug settings, and other information to your application. Environment properties help you run your application in multiple environments for different purposes, such as development, testing, staging, and production.
You can configure your environment to use SNS to notify you of important events that affect your application.
Your environment is available to users at a subdomain of elasticbeanstalk.com. when you create an environment, you can choose a unique subdomain that represents your application.
Configuration changes that modify the launch configuration or VPC settings require terminating all instances of your environment and replacing them.
Rolling updates - to prevent downtime Elastic Beanstalk applies your configuration changes in batches, keeping a minimum number of instances running and serving traffic at all times.
immutable updates - a temporary auto scaling group is launched outside of your environment with a seperate set of instances running on the new configuration, which are placed behind your environment’s load balancer. Old and new instances both serve traffic until the new instances pass health checks, at which time that new instances are moved into your environment’s auto scaling group and the temporary group and old instances are terminated.
You can cancel in-progress updates that are triggered by environment configuration changes. You can also cancel the deployment of a new application version in progress. Elastic beanstalk will perform a rollback. You cannot stop Elastic Beanstalk from rolling back to the previous environment configuration once it beings to cancel the update.
Environment Configuration
Worker environments
if your AWS elastic beanstalk application performs operations or workflows that take a long time to complete, you can offload those tasks to a dedicated worker environment.
To avoid running long running tasks locally, you can use the AWS SDK for your programming language to send them to an Amazon Simple Queue Service (Amazon SQS) queue, and run the process that performs them on a separate set of instances. Worker instances can take items from the queue when they have the capacity to run them.
Worker environments run a daemon process provided by Elastic Beanstalk. The daemon is responsible for managing your SQS messages
you can define periodic tasks in a file named cron.yaml in your source bundle to add jobs to your worker environment’s queue automatically at a regular interval. If you configure your worker environment with an Amazon SQS FIFO queue, periodic tasks aren’t supported.
Elastic Beanstalk worker environments support Amazon SQS dead-letter queues. A dead-letter queue is a queue where other (source) queues can send messages that for some reason could not be successfully processed.
Worker environments
Deployments
deployment policies
all at once - this is the default deployment used by your environment
rolling - elastic beanstalk splits the environment’s EC2 instances into batches and deploys the new version of the application to one batch at a time. So some of your instances will sere the old version of your application while the deployment is occurring.
rolling with additional batch - configure your environment to launch a new batch of instances before taking any instances out of service to maintain full capacity during deployments.
Immutable - launch a full set of new instances running the new version of the application in a separate auto scaling group, alongside the instances running the old version. Immutable deployments can prevent issues caused by partially completed rolling deployments.
traffic splitting - lets you perform canary testing as part of your application deployment. Elastic beanstalk launches a full set of new instances, then forwards a specified percentage of incoming client traffic to the new application version for a specified evaluation period. if the new instances stay healthy, elastic beanstalk forwards all traffic to them and terminates the old ones. if the new instances don’t pass health checks, or if you choose to abort the deployment, elastic beanstalk moves traffic back to the old instances and terminates the new ones.
You can add elastic beanstalk configuration files to your web application’s source code to configure your environment and customize the AWS resources that it contains. Configuration files are YAML or JSON formatted documents with a .config file extension that you place in a folder named .ebextensions and deploy in your application source bundle.
Deployments
Blue/Green deployments with elastic beanstalk
you can avoid downtime by performing a blue/green deployment, where you deploy the new version to a separate environment, and then swap the CNAMES of the two environments to redirect traffic to the new version instantly.
after elastic beanstalk completes the swap operation, do not immediately terminate your old environment until the DNS changes are propagated and your old DNS records expire
blue/green deployment
When to use what
So when to use elastic beanstalk vs other compute options?
the benefits of using elastic beanstalk is that it is PaaS. this means that you just have to define your environment settings and AWS handles the provisioning to the integration for you. After that, you can simply upload your application and you would already have a fully working environment. Management is easy and you do not need to understand how different services work together before you can launch your application. That being said, it also limits your environment depending on whether elastic beanstalk supports the configuration you want or not.
When to use
Monitoring
elastic beanstalk monitoring console displays your environment’s status and application health at a glance.
elastic beanstalk reports the health of a web server environment depending on how the application running in it responds to the health check
enhanced health reporting is a feature that you can enable on your environment to allow AWS elastic beanstalk to gather additional information about resources in your environment. Elastic beanstalk analyzes the information gathered to provide a better picture of overall environment health and aid in the identification of issues that can cause your application to become unavailable.
you can create alarms for metrics to help you monitor changes to your environment so that you can easily identify and mitigate problems before they occur
EC2 instances in your elastic beanstalk environment generate logs that you can view to troubleshoot issues with your application or configuration files.
Monitoring
Security
when you create an environment, elastic beanstalk prompts you to provide two AWS IAM roles: a service role and an instance profile.
service roles - assumed by elastic beanstalk to use other AWS services on your behalf
instance profiles - applied to the instances in your environment and allows them to retrieve application versions from S3, upload logs to S3, and perform other tasks that vary depending on the environment type and platform.
User policies - allows users to create and manage elastic beanstalk applications and environments
Security
Pricing
there is no additional charge for elastic beanstalk. You pay only for the underlying AWS resources that your application consumes.
Pricing