Elastic Load Balancing w.r.t EC2 Memory - amazon-web-services

So basically I have this EC2 Linux Instance with 8GB memory and I am having multiple applications running on it. It doesn't happen often, but when there is huge traffic, 8GB memory isn't enough, and the whole instance stops responding. To make things work like normal, I have to reboot the instance every time.
I have heard that Elastic Load Balancing might scale the memory as required. But how to achieve that? Is there any other way to solve my problem? Is there a tutorial that'd guide me through this?

I have heard that Elastic Load Balancing might scale the memory
ELB does not scale a memory of your instance. Instead it can distribute your connections among multiple instances. Thus, instead of having one instance which servers all your traffic, you would have two or more. In this setup, ELB would distribute traffic equally among your instances, so that collectively they can server more connections then a single instance.
What's more you usually use ELB with autoscaling so that the number of instances is adjusted automatically up and down, depending on the incoming traffic.
Is there a tutorial that'd guide me through this?
You can start with offical AWS tutorial Set up a scaled and load-balanced application .

Related

What is the best practice to host multiple website?

Currently I have hosted 150+ sites in one AWS EC2 instance. And continuously I am adding more websites, approximate 10 to 15 websites per month. So I need suggestion for this. One EC2 instance is good or I need to divide it in multiple EC2 instances. And another thing EC2 auto scaling is good for this or not ?. I can't use beanstalk due to the limitation.
Depends on what you mean by 'good'.
Good for your wallet is to host them all on a single ec2 instance, in a single region and hope that singe instance (or AZ) doesn't go down or have problems.
Good for uptime would be to host all of the websites together on multiple ec2 instances, across multiple AZ's and use a load balancer to distribute traffic across several identical instances.
Better for uptime and performance would be multiple larger ec2 instances in multiple AZ's behind a load balancer
Best for uptime, performance and your wallet would mean multiple smaller ec2 instances, behind a load balancer and with autoscaling enabled to bring up (and turn off) instances depending on traffic load.
Besides the above, you can also offload some of your static assets (css, js, images etc) to an s3 bucket which should save some $$ and reduce the load on your web servers (thus needing smaller or less of them) and then put cloudfront in front of everything to cache assets/pages closer to your end users.
So lots of options, but what you are doing now is perhaps a bit risky.
If you are looking on a perspective of cost saving I would suggest to go with docker and ECS. Since you are adding multiple websites there's a chance some of the websites will have more or less load. Use ECS tasks along with application load balancer and autoscaling group. You'll have reliability and separation between applications.

Are Amazon Elastic Load Balancer (ELB) failure proof?

The title might be a little too much, but i am unable to find any statements regarding this. I am trying to set up computes in multiple AZ's (in a region) with auto-scaling. i am also trying to see if i can get away with only one ELB to do the load balancing act.
In this setup, the ELB is a single point of failure so, I would like to know, if anyone knows the recovery associated with ELB's. There are documentations about scaling in ELB but not the recovery/higher availability.
thanks
Make sure you select multiple AZs for the load balancer as well. You will have to in order for it to work with EC2 instances in multiple AZs anyway. When you do that, multiple ELB instances are created for you behind the scenes, one in each AZ. So the ELB isn't really a "single point of failure".
The most common issue you may see with an ELB is if you have a very quick, large burst of traffic, which will take the ELB a few minutes to scale up to meet the demand. If you know ahead of time you will be getting a large increase in traffic you can send a request to AWS support to pre-warm the ELB for you.
I recommend reading the section titled "Common Pitfalls When Testing Elastic Load Balancing" in this article.
An ELB is a logical entity that consists of multiple (at least 2 - one per AZ - and generally more) instances that route traffic to your back ends.
If an individual ELB instance were to fail, it would be replaced automatically, much in the way autoscaling replaces failed instances.
You can usually tell how many instances are in your ELB by doing a DNS lookup - you will see multiple IP addresses returned.
ELBs can become overloaded if you have a sudden burst of traffic, so they are not failure proof, but for most loads they do a very good job.

Load Balancer Monitoring Surge Queue Length

Can anyone explain me what's happening with my AWS Load Balancer?
I see the metric Surge Queue Length with two lines growing "together" in a cumulative way:
From the documentation, it says that this is the queue of requests on the Load Balancer to be processed by the backend (EC2 instance) and all the trouble-shooting advices that I found points to a performance issue on the backend, but in my case the instance is healthy (CPU, memory, disk i/o, etc.. everything is fine).
This Load Balancer belongs to a Elastic Beanstalk worker environment with only one instance. And every time I deploy a new version, it seems that the Surge Queue Length is purged.
Can anyone explain me why this cumulative queue is growing even if my backend instance is fine? And why this is purged when I deploy?
Even if the EC2 instance in the back end is healthy looking (CPU, memory, disk, etc...), it could be behind in processing the requests sent by the ELB. This can happen if (like in my case) the EC2 is running under an Elastic Beanstalk environment with Docker, where the EC2 instance can only run one Docker container. In this case, the Docker container running the app can't process all of the incoming requests, but since it's inside an isolated environment (the container), it can't use all of the available resources within the EC2 instance.
In my case, I had to scale up my EC2 instances inside the Autoscaling Group (sitting behind the ELB) even when my EC2 instances report that they are using 5% CPU. After scaling up (CPU Utilization went down to 1%), my performance issues went away.
Hope this helps

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.

Using EC2 only when under load or incase of failure

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.