Friday, April 5, 2019

AWS - Beanstalk

AWS Elastic Beanstalk is an service for deploying and scaling web applications and services developed using Java, .NET, PHP, Node.js, Python, Ruby, Go, and Docker on servers like Apache, Nginx, Passenger, and IIS.
We can simply upload our 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.
There is no additional charge for Elastic Beanstalk - you pay only for the AWS resources needed to store and run your applications.

















CLI Command to deploy .net web app using Elastic beanstalk

Key steps: 

  1. Publish your app using:

    dotnet publish -c Release
  2. Zip the output folder.

  3. Deploy to Elastic Beanstalk via AWS Management Console or CLI:

    aws elasticbeanstalk create-application-version --application-name MyApp --version-label v1 --source-bundle S3Bucket=mybucket,S3Key=myapp.zip


Benefits 
  1. Fast & Simple: Its very useful for those not having deployment and infrastructure knowledge.
    You simply use the AWS Management Console, a Git repository, or an integrated development environment (IDE) such as Eclipse or Visual Studio to upload your application, and Elastic Beanstalk automatically handles the deployment details of capacity provisioning, load balancing, auto-scaling, and application health monitoring. Within minutes
  2. Productive for Developers: No need to spend time to learn deployment techniques 
  3. Auto Scaling: It provides auto scaling. Scale up to handle high load and traffic and scale down for cost saving automatically using your config settings.   
  4. Resource Control: Full control to select your choice resource like EC2 instance ex. t2.micro
    You have full control over underlying resources opted through beanstalk, you can takeover on some/all resources you want. It keeps resources up to date with latest updates/patches
Points to Remember:
  1. You can have multiple versions of your application 
  2. Your application can be split in multiple tiers like web tier, app tier and database tier 
  3. You can update application whenever needed 
  4. You can update configuration whenever needed 
  5. update can be 1 instance at a time, % wise update or immutable update (creating separate copy) 
  6. Beanstalk is free, you pay for resources opted 
  7. Beanstalk can create database for you but it get deleted if you delete beanstalk.So better create your separate database and link with beanstalk, with this approach database would not deleted with Beanstalk 
  8. Supported languages and servers for them
    1. Apache Tomcat for Java Applications 
    2. Apache Http server for PHP applications 
    3. Apache Http server for Node JS applications 
    4. Nginx or Apache Http server for python applications 
    5. Java SE 
    6. Docker 
    7. GO 
    8. IIS 7.5, 8.0 8.5 for .Net applications 
    9. Passenger or Puma for Ruby
  9. Configuration applied while creation or updation of environment from multiple sources as given 
    1. Settings applied directly to the environment: Direct setting applied from sources like AWS management console, EB CLI, AWS CLI or SDK, AWS and EB CLI also apply recommended values. 
    2. Saved Configuration: Settings for any option that are not applied directly to the environment are loaded from Saved Configuration. 
    3. Configuration Files: (.ebextensions) Settings for any option that are not applied directly to the environment and from Saved configuration are loaded from Configuration files, multiple .ebeextensions files executed in alphabetic order from folder .ebextensions root of the the application. 
    4. Default Values: If any configuration option has default value and it has not been supplied any value from options given above then default value will be applied.
  10. Immutable deployments perform an Immutable Update to 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. If the new instances don't pass health checks, Elastic Beanstalk terminates them, leaving the original instances untouched.






CI/CD - Safe DB Changes/Migrations

Safe DB Migrations means updating your database schema without breaking the running application and without downtime . In real systems (A...