AWS Cloud Best Practices - Architecting for the Cloud

Introduction:
https://d0.awsstatic.com/whitepapers/AWS_Cloud_Best_Practices.pdf

Migrating to cloud without much change - Lift and Shift. This may not be making use of lot of cloud features, but just using it as infrastructure.

For new applications, cloud specific architecture patterns are evolving.

This WP is highlighting principles to consider while moving to cloud .

The Cloud Computing Difference:
IT Assets become programmable resources.
Global, available, and unlimited capacity.
 Higher level managed services.
Security Built in.

Design Principles
 Scalability : Vertical Scaling and Horizontal Scaling.
Scaling Vertically: Increase the spec of one resource. Like upgrading server with powerful CPU or adding larger hard drive.Easy to do in AWS. Stop instance and resize it to an instance type that has more RAM, CPU , IO or networking capacities.
Scaling Horizontally:Through increasing the number of resources ( adding more hard drive to a storage array, or more servers). However not all applications are designed to distribute their work load to multiple resources. Need to examine certain scenarios.

Stateless Applications:
No need to know about the previous interaction. Every request is treated new. Peer resources doesn't care about each other. Mere distribution of the workload is sufficient. 
   Distributing load to multiple nodes:
      Push Model: e.g using an elastic load balancing ( ELB )
      Pull Model: For asynchronous event-driven work loads. Amazon SQS can store the messages which will be pulled by resources. Amazon Kinesis model  an example.

Stateless Components:
Web applications mostly will have to maintain some kind of state. One way to make back end stateless is by storing info in the client side cookies. Even then some info can be stored in back end database or file systems which makes the stateful effect for the application.
Stateful Components:
   How to implement session affinity: For multiplayer gaming applications it is utmost importance to have the stateful nature  maintained.  Session affinity model can be used. Sticky session feature of ELB can be used for this.

Distributed Processing:
When very large amount of data processing is needed and one computing resource is not enough.
  How to implement distributed processing: Amazon EMR service to run Hadoop on top of a fleet of EC2 instances is a great choice. For real time streaming data Kinesis is a good choice.



Disposable Resources Instead of Fixed Servers.
 Mindset change compared to starting a work on Cloud.Issues with fixed servers include Configuration drift. Immutable infrastructure pattern can be tried - no patch or fix pplied ever.

Instantiating Compute Resource: An automated and repeatable process.



 Bootstrapping: Scripts that install updates or software and bring an instance of the resource to a particular state after boot up. Parameterizing configurations ( Prod vs QA ) also possible. In practice several ways and tools available. AWS Ops works, Chef, Puppet , Custom scripts, AWS APIs, AWS Cloud formation etc.

Golden Image
GI is a snapshot of a particular state of a resource like EC2, RDS or EBS volume. Very faster start time. Can be launched with test data and different configurations. Can have versions. Golden image can be stored as an AMI ( Amazon Machine Image ).  Also, an on premise Virtualization Export/Import feature of  AWS can be used to create Golden Image and AMI.

Containers.
Popular container is Docker. 
Containers allows you to build and deploy distributed  applications inside software containers. Docker allows you to package a piece of software in a Docker image , which is a standardized unit for software development , containing everything that software needs to run : code, runtime,system tools, system libraries etc.  EBS and ECS support Docker and enable you to deploy and manage multiple Docker containers across a cluster of EC2 instances.


Hybrid 
It is possible to capture some part of the configuration in a Golden Image and some part through Bootstrapping.

The line between bootstrapping and golden image.
Items that doesn't change often can be part of Golden Image and those change can be part of boot strap script.

EBS follows hybrid model.

Infrastructure as Code
You can make your whole infrastructure as code and that way it is reusable, maintainable, extensible and testable. 

AWS CloudFormation:
Templates for a collection of related resources.


Automation
In a traditional IT infrastructure there is a need to manually react to many events. In an AWS cloud deployment there is an opportunity to automate to improve stability and efficiency. 

AWS Elastic Beanstalk.
Amazon Auto recovery.
Auto Scaling
Amazon CloudWatch Alarms
Amazon CloudWatch Events
AWS OpsWorks Lifecycle Events
AWS Lambda Scheduled events.

 In a traditional IT infrastructure there is a need to manually react to many events. In an AWS cloud deployment there is an opportunity to automate to improve stability and efficiency.




Loose Coupling
Minimum interdependence in such a way failure of one should not cascade to other.

Well-Defined interfaces
Allow various components to interact through technology agnostic interfaces ( like RESTFul APIs ).
   Amazon API Gateway is a fully managed service.

Service Discovery
  For a lot of features of cloud to work ( Elasticity, hiding underlying network topology ) and there by hiding addressing( e.g hard coded IP address ) details from the client web services need a way they can be discovered ( on which machine or instance it is running etc ) 
   How to implement service discovery? On AWS a simple way is through ELB. If not LB then should be implemented in a a different way.



Asynchronous Integration
Another form of loose coupling between services. This model suits where an immediate response is not needed and only an acknowledgement of request received is sufficient.
    Examples of Asynchronous integration: a)A front end inserts jobs in a SQS queue. b) AN API pushes data streams to Amazon Kinesis. Back end process this at leisure. c)Heterogeneous systems use A Workflow solutions to communicate to each other. d) AWS Lambda implementations

Graceful Failure
Another way to increase loose coupling is by way of designing applications in such a way that a component failure is handled in a graceful way. In practice:




Services Not Servers
Architecture needs to use the breadth of services offered by AWS to make the most of cloud computing and should not just limit to EC2.

Managed Services
e.g SQS, Email, Transcoding etc

Serverless Architecture
Lambda can be used for this. Jut upload the code and get it triggered by events. Only code execution time is charged. No need for server or instance of your own. 
Amazon congnito can be used for mobile back end services.  Lamda is good for IoT applications as well.


Databases
Enterprise performance at open source cost with many DB to choose.
How to choose the right database technology for each work load?
- IS it read heavy? write heavy or balanced? how many RW per second? how will that number change if users increased?
- How much data and how long? growth rate of data?  Is there an upper limit? what is the  min, max and average size of each data object? 
- Requirements in terms of durability of data? Is this storage source of truth?
- Latency requirements? How many concurrent users?
- What is data model and querying approach? Is it rational with joints or flat ( easy to scale)? 
- What kind of functionality? Strong integrity controls? or more flexibility?( schema less ). You need sophisticated reporting and search capabilities? Developer skill set is relational or no sql?


Relational databases :
Tabular structure which consists of rows and columns. Amazon RDS makes it easy to set up operate and scale RDBMS in the cloud.
Scalability: Can scale vertically ( upgrading to larger DB instance or adding more and faster storage ). Consider Amazon Aurora. Also for high read DBs Read Replica is also an option.  Relational DB that needs to scale beyond one instance will have to take partitioning or sharding approach. High Availability: Amazon recommends use of RDS Multi - AZ deployment feature.
Anti-Patterns: If no complex joins or indexes, consider NoSQL DB.


NoSQL databases :
NoSQL is a term used to describe a database which trades some of the query and transaction capabilities of relational database for a more flexible data model that seamlessly scales horizontally. Amazon Dynamo. It supports both document and key-value store models.
Scalability: Scales very well horizontally. No need to implement logic in the data access layer of the application.
High Availability: Synchronously replicates data across three facilities in a region.
Anti-Patterns: If application needs joins use RDBMS.

Data Warehouse:
A special type of RDBMS specialized for analysing and reporting on large amounts of data. Amazon Redshift is a cost effective solution.
Scalability: Redshift's MPP architecture allows multi node clustering.
High Availability: Multi nodes and replication to S3.
Anti-Patterns: Redshift not meant for writing.


Search :
On AWS you have the choice of Amazon cloud search or Amazon elastic search. Cloud search is a managed search with easy implementation and scalability. Amazon ES exposes ope source APIs to give more control over search.It can also be used as an analytics engine.
Scalability: Both allows scalability. Cloud search does it automatically.
High Availability: Data stored across AZ.



Removing single point of failure

Introducing Redundancy :
Detect Failure:
Durable Data Storage:
Automated Multi-Data Center Resilience :
Fault Isolation and Traditional Horizontal Scaling :


Optimize for Cost

Right Sizing :
Elasticity:
Take advantage of the variety of purchasing options:
- Reserved Capacity
- Spot Instance
- On Demand 
Strategies for bidding.

Caching
Caching is a strategy where previously calculated data is stored for future use. 

Application Caching:
Amazon ElastiCache: In memory cache. Two open source technologies. Memcached and  Redis.

Edge Caching:
Copies of static content is cached as a CDN - CloudFront.


Security
Most of the security tools can be used in cloud too. AWS allows you to formalize the design of security controls in the platform itself.

Utilize AWS features for defense in depth:
Offload security responsibility to AWS.
Reduce privileged access.
Security as code:
Real-Time Auditing:






Comments

  1. Goal was the one retailer with comparable scale. It succeeded by sustaining a good concentrate on high quality and vogue with a purpose to differentiate itself from the behemoth. It adopted this formulation into the supercenters as effectively.This is great blog. If you want to know more about this visit here AWS Cloud Certified.

    ReplyDelete

Post a Comment