Using EC2 only when under load or incase of failure - web-services

Is it possible to have most of our server hardware outside of EC2, but with some kind of load balancer to divert traffic to EC2 when there's load that our servers can't handle, or as a backup incase these servers go down?
For example, have a physical server serving out our service (let's ignore database consistency for the moment), but there's a huge spike due to some coolness - can we spin up some EC2 instances and divert traffic off to it? This is much like Amazon's own auto scaling.
And also, if our server hardware dies for some reason (gremlins eat the power cables for example) - can we route all our traffic over to EC2 instances?
Thanks

Yes you can but you will have to code. AWS has Command Line Tools for doing EC2/Autoscaling/S3 stuff with simple commands in bash or other interfaces and SDKs, like Boto for Python etc.
You can find it here: http://aws.amazon.com/code/

Each Ec2 instance has a public network interface associated with it. Use a DNS CNAME record to "switch" your site traffic to the Ec2 instance. If you need to load-balance across multiple machines you can use round-robin DNS, or start a ELB and put any number of Ec2 instances behind it.
Ec2 infrastructure is extremely easy to scale. Deploying your application on top of an Ec2 is a whole other matter. It could be trivial -- or insanely complicated.

Related

AWS EC2 Instance - Is it a single virtual image or single physical machine?

Sorry, I had a few basic questions. I'm planning to use an AWS EC2 instance.
1) Is an EC2 instance a single virtual machine image or is it a
single physical machine? Documentation from Amazon states that it is
a "virtual server", but I wanted to clarify if it is an image
embedded inside one server or if it is an single physical server
itself.
2) Is an Elastic Load Balancer a single EC2 instance that handles
all requests from all users and simply forwards the request to the
least loaded EC2 instances?
3) When Auto-Scaling is enabled for an EC2 instance, does it simply
exactly replicate the original EC2 instance when it needs to scale
up?
An EC2 instance is a VM that gets some percentage of the underlying physical host's RAM, CPU, disk, and network i/o. That percentage could theoretically be 100% for certain instance types, including bare-metal instances, but is typically some fraction depending on which instance type you choose.
ELB is a service, not a single EC2 instance. It will scale on your behalf. It routes by round robin for TCP, and routes on fewest outstanding requests for HTTP and HTTPS.
Auto Scaling is "scale out" (it adds new EC2 instances), not "scale up" (resizing an existing EC2 instance). It launches a new instance from a template called an AMI.
It is a virtual server, a VM, as stated in the documentation.
It's a little more complicated that that, based on the way AWS might scale the load balancer, or create a version in each availability zone, etc. It also provides more features such as auto-scaling integration, health checks, SSL termination. I suggest you read the documentation.
It uses a machine image that you specify when you create the auto-scaling group (when you create the Launch Configuration used by the Auto-scaling group to be more precise). A common practice is to configure a machine image that will download any updates and launch the latest version of your application on startup.
You might also be interested in Elastic Beanstalk which is a PaaS that manages much of the AWS infrastructure for you. There are also third-party PaaS offerings such as OpenShift and Heroku that also manage AWS resources for you.

What is the best practice for a persistent LAMP on AWS?

Let me preface this by saying that I am primarily a programmer, though I have a pretty good working knowledge of Linux and "standard" LAMP installations. I have been tasked with setting up a persistent LAMP environment in Amazon Web Services (AWS), which is a good deal more involved than what I'm used to in this regard.
Although AWS is very well documented, I have yet to find a clear, definitive "Best Practices" overview for setting up a persistent LAMP environment. I followed the official Amazon tutorial ( http://docs.aws.amazon.com/AWSEC2/latest/UserGuide/install-LAMP.html ) to set up a LAMP server on our EC2 instance, but found out later that these instances are "temporary" and that I need an EBS to make anything persist. Interestingly, EBS (Elastic Block Storage) does not appear in my Management Console , though they offer pricing out on the public side ( https://aws.amazon.com/ebs/pricing/ ). Is it still called EBS?
Of course, that begs the question - what happens to the programs I installed (Apache, MySQL) along with their respective config files? Surely Amazon doesn't expect us to reconfigure our server from scratch every time it boots up?
What I have now
1x EC2 instance running Amazon Linux. I installed and configured Apache and MySQL following the "Install LAMP" tutorial posted by Amazon.
1x Route 53 Hosted Zones (for DNS routing)
1x Elastic IP attached to the EC2 server
Additionally, there appears to be one unencrypted 8GB volume attached to /dev/xvda, although I didn't set it up and nobody has access but myself - it seems to have been generated when I requisitioned the EC2 - no idea if it is persistent or not.
What I think I need
So, here is what I'm thinking I need to do. Please tell me if I'm way off - is there a more sane alternative?
1x EC2 instance running Amazon Linux and Apache
1x RDS for MySQL
1x Route 53 Hosted Zone
1x Elastic IP attached to the EC2 server
1x (EBS? S3? EFS?) for storing htdocs
1x Snapshot of the EC2 to save server configuration
Does that sound right? Is there a better way to do this? Thanks so much for any advice. Amazon docs seem to be very good at giving granular information, but not as great at addressing overall strategy concerns.
Web Application
It is recommended to have 2 EC2 instances under an Elastic Load Balancer with these 2 instances being in separate availability zones for high availability. Going further is better to monitor these instances for CPU and bandwidth - CloudWatch - and once you see they are above some threshold you could automatically add more instances to the ELB, this is the auto scaling. Of course like you said you will need the AMI (snapshot) with the server software to be ready to be launched. You also need to take down servers when the load is small - again automatically with the metrics, but you should never go down under 2 machines. And don't forget to update these images when you upgrade the software.
Route 53
Because you would use an ELB you don't need Elastic IPs anymore, your web servers could only have private IPs. And on the Route 53 you need to point your website to the name of the ELB - here are more details about it
Database
For the database part go for the RDS for MySQL including Multi-AZ deployment, so you will have the master and one stand by replica in different availability zones.
EBS (disks)
For the EBS part you will ned to use that and they come in 3 flavours: magnetic(slowest), General Purpose SSD (faster) and Provisioned IOPS (fastest). These are the disks you mount on your machines, web servers and databases. For the database you should go with Provisioned, it is much harder to change them later, while for the web server we use General Purpose. In the AWS Console you find them under EC2, section Elastic Block Store.
The 8G disk that appeared is the default when you create a Linux machine and it is a General Purpose SSD which is good enough for a web server, but I think you should go with a bigger one, 50G at least.

AWS architecture with limited elastic IPs

Right now our small-ish business has 3 clients who we have assigned to 3 elastic IPs in Amazon Web Services (AWS).
If we restart an instance no one loses access because the IPs are the same after restart.
Is there a way to handle expanding to 3 more clients without having things fall apart if there's a restart?
I'm trying to request more IPs, but they suggest it depends on our architecture, and I'm not sure what architecture they're looking for (or why some would warrant more elastic IPs than others or if this is an unchecked suggestion box).
I realize this is a very basic question, but googling around only gets me uninformative docs from the vendors mouth.
EDIT:
There is a lot of content on the interwebs (mostly old) about AWS supporting IPv6, but that functionality appears to be deprecated.
You can request more EIPs in the short run. Up to 5 EIP is free depending on your account. You should also considering using name based URLs and assign each of your clients to a subdomain, for example,
clientA.example.com
clientB.example.com
clientC.example.com
This way you will not be needing an additional IP for every client you add. Depending on your traffic, one EC2 instance can serve many clients, and as you scale, you can put multiple EC2 instances behind an AWS Elastic Load Balaner, and this will scale to serve exponentially more clients.
If the client wants to keep their servers separate and can pay for them, you can purchase EIP as many as you need. You should also consider separating database into one database instance for each client, which is probably what clients desire more than separation of IPs.
For IPv6, a quick workaround would be to use a front-end ELB that supports both IPv6 and IPv4.
If you use elastic IPs from VPC, you get 5 per region for an AWS account. See Amazon VPC Limits.
So, you can go to console and select VPC. Then click on elastic IPs, create it. Once created, assign it to a relevant instance.
So, atleast for now, you can solve the problem if you are not bothered about region.

Is ssl termination at AWS load balancer ELB secure?

We have a web application running on ec2 instance.
We have added AWS ELB to route all request to application to load balancer.
SSL certificate has been applied to ELB.
I am worried about whether HTTP communication between ELB and ec2 instance is secure?
or
should I use HTTPS communication between ELB and ec2 instance?
Does AWS guarantees security of HTTP communication between ELB and ec2 instance?
I answered a similar question once but would like to highlight some points:
Use VPC with proper Security Groups setup (must) and network ACL (optional).
Notice your private keys distribution. AWS made it easy with storing it safely in their system and never using it again on your servers. It is probably better to use self-signed certificates on your servers (reducing the chance to leak your real private keys)
SSL is cheap these days (compute wise)
It all depends on your security requirements, regulations and how much complexity overhead are you willing to take.
AWS do provide some guaranties (see network section) against spoofing / retrieval of information by other tenants, but the safe assumption is that multi-tenant public cloud environment is not 100% hygienic and you should encrypt.
Single tenant instance (as suggested by #andreimarinescu) will not help as the attack vector discussed here is the network between the ELB (shared env) and your instance. (however, it might help against XEN zero days)
Long answer with short summary - encrypt.
Absolute control over security and cloud deployments are in my opinion two things that don't mix very well.
Regarding the security of traffic between the ELB and the EC2 instances, you should probably deploy your resources in a VPC in order to add a new layer of isolation. AWS doesn't offer any security guarantees.
If the data transferred is too sensitive, you might also want to look at deploying in a dedicated data-center where you can have greater control over the networking aspects. Also, you might want to look at single-tenant instances on EC2, since you're probably sharing your physical resources with other EC2 customers.
That being said, there's one aspect that you also should take into account: SSL termination is quite an expensive job, so terminating SSL at the ELB level will allow your backend instances to focus resources on actually fulfilling the requests, but this will also impact the ELB (it will automatically scale, but it will have to do it faster, and you might see increased latency as it does so during spikes of traffic).

Web Service Large Volume Of Calls On Amazon EC2

I am new to using web services but we have built a simple web service hosted in IIS on an Amazon EC2 instance with an Amazon RDS hosted database server, this all works fine as a prototype for our mobile application.
The next stage s to look at scale and I need to know how we can have a cluster of instances handling the web service calls as we expect to have a high number of calls to the web service and need to scale the number of instances handling the calls.
I am pretty new to this so at the moment I see we use an IP address in the call to the web service which implies its directed at a specific server> how do we build an architecture on Amazon where the request from the mobile device can be handled by one of a number of servers and in which we can scale the capacity to handle more web service calls by just adding more servers on Amazon
Thanks for any help
Steve
You'll want to use load balancing, that conveniently AWS also offers:
http://aws.amazon.com/elasticloadbalancing/
Elastic Load Balancing automatically distributes incoming application traffic across multiple Amazon EC2 instances. It enables you to achieve even greater fault tolerance in your applications, seamlessly providing the amount of load balancing capacity needed in response to incoming application traffic. Elastic Load Balancing detects unhealthy instances within a pool and automatically reroutes traffic to healthy instances until the unhealthy instances have been restored. Customers can enable Elastic Load Balancing within a single Availability Zone or across multiple zones for even more consistent application performance.
In addition to Elastic Load Balancing, you'll want to have an Amazon Machine Image created, so you can launch instances on-demand without having to do manual configuration on each instance you launch. The EC2 documentation describes that process.
There's also Auto Scaling, which lets you set specific metrics to watch and automatically provision more instances. I believe it's throttled, so you don't have to worry about creating way too many, assuming you set reasonable thresholds at which to start and stop launching more instances.
Last (for a simple overview), you'll want to consider being in multiple availability zones so you're resilient to any potential outages. They aren't frequent, but they do happen. There's no guarantee you'll be available if you're only in one AZ.