This article will tell you about Amazon EC2 Services and will also look at a hypothetical service hosted on Amazon platform
Overview
Following are the major Amazon Services
1. Amazon S3
2. Amazon EC2
3. Amazon EBS
Amazon S3
S3 stands for Simple Storage Service. A Service which allows to store and retrieve files from 1 Byte to 5GB.
You can think this as the online hard drive for your cloud computing. A hard drive that contains images of OS with preloaded softwares. This is an essential service for Amazon Ec2
Amazon Ec2
EC stands for Elastic Computing. To give an example, think about you having a single machine which is so powerful that you can run many many VMWares on it. This is basically virtualization of PCs, but with a difference that it has many interfaces which allow you to control this virtualization. You can control the virtualization using
1. Command line tool
2. Web UI
3. Web Services (programmatically)
The image of EC2 is referred to as AMI. Thsi AMI is taken from Amazon S3.
If you want to run a web server on EC2, you will have to install an AMI from S3 for that OS, and then shh to this instance, download and install the needed softwares. Now you also have a choice to package this instance as a customized AMI. On S3 you will find many many AMIs of OS, with preloaded softwares.
You will find AMIs for Java Web Server same for Php and Ruby and so on. Also, you will find AMIs for MySQL etc.
Once you run this instance, Amazon EC2 charges you on an hour rate (for every hour you instance is up).
Amazon EC2 provides you a facility to simply clone a instance and start n similar instances.
Please note one thing, when you launch an instance and work with it, the instance develops some kind of statefulness (filesystem has new files etc), but when you take an instance off, the whole state is lost.
Amazon EBS
EBS stands for Elastic block. The Elastic block comes as a rescue for the last point I mentioned in Amazon EC2. What happens if I have a filesystem or database on Amazon, if i shutdown that instance, all data is lost.
For this purpose, Amazon provides Elastic block. You can create an Elastic block and then put your filesystem or database on that. Now this block is different from EC2 Instance. It can be used along with a Amazon EC2, by attaching a EBS to EC2 Instance. This is more like mounting a drive.
Now even if you take the EC2 instance down, you will always have the database or filesystem persisted on the Elastic Block
Hypothetical Example
Our Hypothetical example is of that running a web application on amazon services. Typically we start a business and we need a web application to help customers buy or sell on your web application. It so happens that no of visitor during 10 months of 12 months is low. Its so happens that during november and december this web application experience peak loads.
Hypothetically speaking, for 10 months 1 machine for web server and 1 machine for database suffices my need but for the 2 months I need atleast 4 machines for my web server.
We start with taking an Fedora Image from Amazon S3 and start an instance. We then download and install needed Web Server on this instance. We also install our web application on this instance. Then we back this instance up (privately) on Amazon S3.
Now we take a EBS instance and put MySQL Master on this block. We then start another EC2 instance for Database and attach this EBS block to this instance. This is our Master MySQL running on a separate EC2 instance.
This configuration suffices my need for 10 months.
Now as we start to enter the month of November, I scale up the no. of EC2 for my web server from 1 to 4 and I can also launch couple of more EC2 instances for MySQL slave.
Now only starting more instances does not help you will need to configure it. I also start a apache proxy on my main web server instance, which is a load balanacing proxy, which sends the request either to the main web server instance or any one of the secondary web server instances.
For MySQL, we can put a MySQL proxy on the main Mysql instance and configure it to know the slave mysqls. This proxy will also do load balancing for all the read operation.
(please not I am not an MySQL Expert, and this is an hypothetical examples, I may not be 100% correct on these usage of proxy with slaves here, but you will get the point I am trying to make).
To Summarize the things
for 10 months, I have two instances running
1. Main Web Server EC2 instance with
- Web application
- With a load balancing Apache Proxy
2. Main Database EC2 instance with
- MySQL Master
- MySQL proxy
- EBS block to put mysql files on.
for month of November than december I have
1. 3 more EC2 instances with
- Web application running
2. 2 more Mysql Slave instances running with EBS block
Hence we call it Elastic Computing, when needed we stretch from 1 instance to 4 instance for web application to match the load and later we come back to 1 machine.
This is cost effective as, we only pay extra for 2 months, when my business is flourishing.
Feel free to ask questions or correct me where ever you feel appropriate.
(In load balancing one of the main hurdles is lack of static IPs on Amazon services, but that is the topic for another day)
No comments:
Post a Comment