Building Applications Using Elastic Beanstalk

Building Applications Using Elastic Beanstalk

What is Elastic Beanstalk?

Elastic Beanstalk is a service provided by AWS, 

  • that provides a Managed Application Environment for building Highly Scaled Application
  • It allows you to build and deploy cloud-based applications and services at scale.
  • We can run this application in nearly any region or regions around the world.

You can build your Application using nearly any Programming Language, as well as any Application or Service that has been encapsulated within a Docker Container. 



Scalable Architecture:

Elastic Beanstalk provides a scalable architecture, making it extremely easy to scale your application up or down, in order to handle more or less traffic. You can do that manually at any point in time, via either the Console, a command line utility, or the built-in API, or you can have your application scale automatically, as response to traffic demands, that come to your application.

Automated Deployments:

However large or small your` application is, you can use Elastic Beanstalk to automate your application deployment process. Elastic Beanstalk takes care of the process of delivering and installing updated software images to all of the servers that have been deployed for your application, whether that is one server or 1,000 servers, Elastic Beanstalk will automate the deployment process to upgrading your application to a newer application image.

On-Demand Testing and Staging Environments:

With Elastic Beanstalk, you can also dynamically create new test and staging environments, on demand, quickly and effortlessly. This makes it easy for an individual developer, or a QA engineer, to bring up their own copy of an application in a production-like environment, and allow them to test, integrate and debug problems, easily and quickly. They can then terminate the environments when they are complete, freeing costly resources. When they need the environment again, they can simply spin up another instance.

Automated Infrastructure Updates:
Additionally, Elastic Beanstalk can automate the process of updating your infrastructure. If new operating system patches become available, for example, Elastic Beanstalk can be set up to install them automatically on all your servers, using the Infrastructure Management Pane considerably. 


Basic Anatomy of a Bean Stalk Environment:

 let's take a closer look at the components that make up an Elastic Beanstalk environment

Elastic Beanstalk environment is basically a series of individual AWS components, assembled automatically, by the Elastic Beanstalk service, in order to create the environment.

 First, and most basically, an Elastic Beanstalk environment is composed of one or more EC2 instances. These serve as the servers that run your application, these instances run special Elastic Beanstalk software, along with your application, in order to allow the Elastic Beanstalk service to manage those servers.


Next, an Elastic Load Balancer, or ELB, is attached in front of your servers. This load balancer takes all requests sent to your service, and distributes them as appropriate across the server for processing.



The EC2 instances themselves are also contained within a Auto-Scale Group, or ASG. The purpose of the Auto-Scale Group is the make sure there are always the correct number of instances running to run you application. If an instance is terminated for some reason, the Auto-Scale Group will automatically start another instance. Additionally, depending on how it is configured, the Auto-Scale Group with examine the load applied to the ELB, or the EC2 instances, and if the service gets to loaded, it will arrange to add additional EC2 instances to the service. Additionally, if traffic falls off, the Auto-Scale Group can arrange to have unnecessary EC2 instances terminated. You can also manually change the number of desired EC2 instances, and the Auto-Scale Group will automatically start or terminate the appropriate number of EC2 instances, until the desired number of instances are running, and connected to the load balancer.



Now let's take look inside one of the EC2 instances themselves, each EC2 instance that is started by the Auto-Scale Group, runs the exact same software. And it's configured the exact same way, automatically when the instance is started. First, each instance has a basic operating system, Elastic Beanstalk will work with almost any operating system, but in our examples and demonstrations, we will always be using Amazon Linux. Next, Elastic Beanstalk runs an application on the instance called the Elastic Beanstalk Agent, or just Agent, for short. The Agent talks to the Elastic Beanstalk service, and receives instructions from the service on what the instance should be doing. The portion of the Elastic Beanstalk service that the Agent talks to is called the Elastic Beanstalk Control Plane. The Agent takes commands from the Control Plane, and it used them to perform whatever actions it requires. This might involve talking to the instance's operating system to perform some action, such as starting or terminating a process. The Agent also determines what software and infrastructure must be installed and configured in order to run the application. Depending on what language the application is written in, if the application is within a Docker Container, then the Agent must install and setup the Docker runtime environment as well. Next, the Agent downloads and installs the application, performs any necessary configuration, and starts the application running. The Agent will monitor the application until it is sure that the application is running successfully. Once the application is up and running successfully, and ready to accept traffic, the Elastic Load Balancer is connected to the instance, and begins sending traffic to the instance. At this point in time, the Agent then starts monitoring the application, the operating system, and everything else within the instance. If anything goes wrong, it fixes it. If it runs into something that is not fixable, as a last resort, it terminates the instance, which will cause Auto-Scale to have to launch a new replacement instance. There are a few other AWS components that make up the support infrastructure for the Elastic Beanstalk environment. There is an S3 Bucket associated with the environment, where Elastic Beanstalk will store the application software and infrastructure components that are downloaded and installed onto the instance. The Elastic Load Balancer also has a domain name associated with it, this may be a system assigned domain name, such as the one that we used in the sample application, in the previous demonstrations, or you can assign any domain name that you own to the load balancer, hence, the entire Elastic Beanstalk environment. Additionally, a security group is created, which is used to control and manage access to the AWS resources, and the EC2 instances themselves.




Terminology








Different Types of Environment




Load Balanced Auto Scaled Environment


Example




Single Instance Environment


Example




Worker Environment



Example

Such as sending emails, background transaction,  and regular system clean up task




Deployment Options




All at once 




Rolling Deployments



Rolling Deployments w/additional Batch



Immutable







Platforms

A platform is a Machine Image, or AMI, consisting of new versions of  the Operating System the instance runs, the language runtime environment for the specified programming language, the tools web container, and runtime environment necessary to use the language runtime environment by the Application, and set of standard default configuration values utilized by instances running this version of the platform.


Recommended Way of Updating Platform:(Major Update)

The recommended way of upgrading your production environment is to launch a duplicate environment using the new environment. Then once the new environment is working correctly, swap the two environments and terminate the old environment.






Minor Updates:

Elastic Beanstalk has a mechanism called managed updates, that allow these minor and patch updates to be automatically applied to your environments as they become available. You typically specify a maintenance window for your application, and the updates are applied using a zero downtime deployment strategy during the maintenance window. The update is automatically canceled if your instance update fails for any reason. This process allows you to receive minor and patch infrastructure improvements regularly and conveniently, without needing to do any active work on it yourself. You'll receive notifications when these updates are performed and completed.



Setting Configuration Values












Comments

Popular posts from this blog

Postgresql Hacked ? - FATAL: pg_hba.conf rejects connection for host "127.0.0.1", user "postgres", database "", SSL on

AWS RDS