A Spot EC2 architecture for Web applications
Published in16:45 2015-05-28|
This blog post uses a practical example to describe a reference framework, which is designed to help keep you at the same time maintaining the high availability of web applications and to achieve a more cost saving, no state web layer. We recommend that you adjust and test your application before you apply it to the production environment.
Instance Spot allows you to make a simple bid to specify your own Amazon based on your application, by using EC2 Instance Amazon that is not in use.
Instance EC2 computing power price. Often can greatly reduce the cost of your EC2 Instance Amazon. For example, using the same load balancer behind the different spot bid, will be based on on-demand instance running automatic telescopic group based on the spot
Instance runs the automatic retractable group put together to provide greater flexibility and meet the changing needs of the traffic. Please refer to
The session state can be stored in the DynamoDB data table in the web layer. DynamoDB is a regional service, which means that data can be automatically replicated across the available area to achieve fault tolerance. You can also use other databases to save the state of the schema. Spot The availability of Instances depends on how many unused EC2 Instance Amazon can be obtained, because real-time demand and supply determines the amount of Instance Spot available and the number of instances of business requirements. You should build it to be flexible to terminate the instance (Note: this translation is not sure, the text is "you" Should architect it to be resilient to instance termination "). This includes when the price more than you originally specified price (bid), this example will receive a two minute warning: the instance will be terminated. You can manage an instance by creating a IAM role, which comes from the Spot that they used to log off from ELB Instance. once they receive the notification, they will be terminated. About "an IAM Role Creating Using the AWS CLI" details see Here, see the details of "Instance Termination Notices Spot" Here. The picture below describes what it would be like:
Like the following script can be placed in a loop, and can be run at startup (for example, by rc.local or SYSTEMd) to detect whether the Instance Spot is terminated. Then save any session information to the DynamoDB and log out of ELB from the so that it won't accept any more requests. We propose (for this method) to be interested in the application of this method to terminate a notification every 5 seconds;
$curl -s ifHttp://169.254.169.254/latest/meta-data/spot/termination-time| \ -q.*T.*Z then; instance_id=$grep (-s curlHttp://169.254.169.254/latest/meta-data/instance-id);\ ELB deregister-instances-from-load-balancer AWS \ My-load-balancer --load-balancer-name \ $instance_id --instances; /env/bin/flushsessiontoDBonterminationscript.sh; fiBased on the automatic telescopic group instance running and using the same load balancer behind different bid and is based on the Spot Instance's automatic telescopic group collaboration will ensure the availability of applications in the case of Spot market prices and Instance Spot changes. If the Spot in the auto expansion group Instance because the price increases close to the bid price and the termination, then run in the case of the automatic expansion group will be based on a custom expansion strategy to expand to meet the needs of the service (before the end of the case). In order to achieve the automatic expansion group according to the application needs to determine the expansion, you have to explain how you want to change to respond to changing circumstances. You can run Spot Instance's scalable group allocation for more aggressive scaling policies(such as CPU to achieve the use of 75% to expand the scale of the scale, CPU usage down to 25% when the size of the scale), to run the required instances of the scaling group allocation more conservative expansion strategy. For information about using CloudWatch Amazon metrics to auto flex, see Scaling Dynamic.
Please note, elastic load balancer uses least unfinished request routing algorithm (for HTTP / HTTPS connections). This algorithm has to at least not completed request at the rear end of the example. Since we use across multiple availability zones automatic telescopic group, we strongly recommend that you enable inter regional load balancing the load balancer. Load balancing across regions allows each load balancing node to send requests across multiple areas, ensuring that each area accepts an equal amount of requested traffic. In the canceled Spot Instance will be terminated, in order to complete the request in the transmission, the load equalizer in the connection pipe to allow 90 seconds of delay (ie, 90 seconds after the cancellation of the connection pipe closed)
Text link: Https://aws.amazon.com/cn/blogs/compute/
Activity recommendation:June 9th CSDN online training - the use of AWS to build a hybrid Cloud Architecture
(translation / Li Yili / commissioning editor Wang Xinhe)
AWS Chinese technology community for the majority of developers to provide a Web Service Amazon technology exchange platform, push AWS latest information, technology, video, technical documents, wonderful technology and other related exciting content, more AWS community experts to communicate directly with you! Quickly join the AWS Chinese technology community, faster and better understanding of AWS cloud computing technology.
- step on
- Related articles
- Latest report
- 10 tricks make it easier for you to use AWS
- High performance Web application to create a strategy: the expansion of the process of the 20 biggest stumbling block
- Google vs. GCE Amazon EC2: fast from Google some of the details
- Amazon EC2 cloud computing platform will start the cloud search business
- Modify the driver, using Erlang+VoltDB to achieve business transactions per second
- Yang Yuyao: when the research projects in the case of AWS cloud
Related popular articles