AWS and spinning down an Elastic Beanstalk instance - amazon-web-services

I have a test environment setup (along with a staging and production). The staging environment has spun down automatically in to red (health).
I would like to spin down the test server as well, is this possible without destroying the actual instance? I will be using it again in a few months, but until then I don't need it consuming resources.

Server == Instance.
Termination ==> killing a server, no chance to get it back.
Stop => Stopping a server, it can be restarted. No EC2 costs while it's stopped. ( EBS costs may apply.)
Having a single node Beanstalk environment means having 1 EC2 instance. I never tried to stop it, but you should be able to do it. ( Just check it a few minutes ago, if AWS spins up a new instance or not. In a single node setup it shouldn't.)

Related

How to access the apache container of a task on AWS ECS?

I am setting up an infrastructure to deploy my application on AWS. I am using ECS service because I am trying to deploy a Docker-based application. So far I have created a task definition with two containers one for the apache and another one for PHP. Then I launched an ECS cluster with an EC2 instance and a task running. They all seem to be up and running. Now, I am trying to figure out how I can access the apache of my EC2 instance with the Cluster on the browser.
This is how I created the apache container.
And then I created the php container as follow.
Then I launched an EC2 based ECS cluster with one instance in it. Then I run one task within the cluster. Then I tried to open the public IP address of my instance. It just keeps loading loading and loading. What is wrong with my configuration? How can I access it on the browser?
It seems to me there's a couple of possible scenarios here you could check:
If do you reach the service and are stuck on an endless reloading loop, which might point to something in your code that could be causing it to do that,
If you're having a long wait time till the browser actually gives a timeout, which might be caused by not having the right port open on the Security Group associated with your task definition.

Amazon EC2 becomes unresponsive when running two Mean pm2 processes

I have an amazon ec2 (t2.micro) instance running. I have 2 Mean applications hosted on it. It was working fine for more than 5 months. But from last two days when more than one pm2 process starts the instance get stopped and I need to restart it again. With one pm2 it is working fine but as I start the second pm2 process it gets stopped (It becomes unresponsive and I can't login into) and again I need to reboot.
It was working fine with 3 to 4 pm2 processes but from last 2 days it is not working as expected.I have checked the CloudWatch Logs but everything is fine there.
I am using Nginx server. I have checked nginx, pm2 and mongodb logs but nothing is wrong there.
Also, I have one Lightsail instance with 1GB memory and 40GB SSD. I have hosted 5 WordPress websites there. It is also having the same issues I need to reboot the instance more than twice a day.
I don't know what is the reason behind that so, asking here for help. Is there any issue with AWS EC2 or Lightsail instances?
This is EC2 CloudWatch graph please check.

ELB backend connection errors when deregister ec2 instances

I've written a custom release script to manage releases for an EC2 autoscaling application. The processing works like so...
Create an AMI based on an application git tag.
Create launch config.
Configure ASG to use new launch config.
Find current desired capacity for ASG.
Set desired capacity to 2x previous capacity.
Wait for new instances to become healthy by querying ELB.
Set desired capacity back to previous value.
This all works fairly well, except whenever I run this, the monitoring for the ELB is showing a lot of backend connection errors.
I don't know why this would be occurring, as it should (based on my understanding) still service current connections if the "Connection draining" option is enabled for the ELB (which it is).
I thought perhaps the ASG was terminating the instances before the connections could finish, so I changed my script to first deregister the instances from the ELB, and then wait a while before changing the desired capacity at the ASG. This however didn't make any difference. As soon as the instances were deregistered from the ELB (even though they're still running and healthy) the backend connection errors occur.
It seems as though it's ignoring the connection draining option and simply dropping connections as soon as the instance has been deregistered.
This is the command I'm using to deregister the instances...
aws elb deregister-instances-from-load-balancer --load-balancer-name $elb_name --instances $old_instances
Is there some preferred method to gracefully remove the instances from the ELB before removing them from the ASG?
Further investigation suggests that the back-end connection errors are occurring because the new instances aren't yet ready to take the full load when the old instances are removed from the ELB. They're healthy, but seem to require a bit more warming.
I'm working on tweaking the health-check settings to give the instances a bit more time before they start trying to serve requests. I may also need to change the apache2 settings to get them ready quicker.

Rebooting AWS EC2 instance restored my app to an old version

I have hosted a CakePHP app in EC2 using Elastic Beanstalk. Due to some performance issues I had to restart the server. Now I have lost all the files.
Did you reboot the instance or stop and start it?
If you rebooted it then it's certain your app and data are there.
If you stop and start an instance-store instance (not EBS-backed), then you will loose all your data on the ephemeral volume.
All this is well explained on the following link, take a look at it: http://docs.aws.amazon.com/AWSEC2/latest/UserGuide/Storage.html.

Elastic Beanstalk Availability Zones & Initial Instances -- volume not preserved?

I've spent a few days just going over Elastic Beanstalk trying to identify the benefits of using this. I'm new to this service but also don't have much experience with EC2, so I'm really just trying to make sense of everything. My main objective is to have auto-scaling and Elastic seemed to make sense.
Last night, suddenly my existing instance terminated a new one was spun-up (automatically). Upon SSH'ing to this new instance, all my files were gone. I expected the volume to be replicated over?
I'm just not understanding what took place and why a instance was spun up and my other terminated - or more importantly, why the new instance didn't have my files.
Here is a log of what happened:
2013-12-26 23:03:23 UTC-0800 WARN Environment health has transitioned from YELLOW to RED
2013-12-26 23:01:21 UTC-0800 WARN Environment health has transitioned from GREEN to YELLOW
2013-12-26 23:01:21 UTC-0800 WARN Elastic Load Balancer awseb-e-i-AWSEBLoa-K5TNOB5OZNKU has zero healthy instances.
2013-12-26 23:00:36 UTC-0800 INFO Removed instance 'i-c75df99a' from your environment. (Reason: Instance is in 'shutting-down' state)
2013-12-26 22:55:14 UTC-0800 INFO Adding instance 'i-4d46d010' to your environment.
2013-12-26 22:54:14 UTC-0800 INFO Added EC2 instance 'i-4d46d010' to Auto Scaling Group 'awseb-e-ikszmdzite-stack-AWSEBAutoScalingGroup-TC41QI6DT3O0'.
Is this because I have 2 availability zones? I'm really confused.
Update
When I developed my Elastic Environment, I indicated that I wanted to use multiple availability zones. I then identified 2 zones to use. I indicated to use a minimum of 1 instance. I feel that this is where the problem happened -- I should have set the minimum to the same number of zones I identified. But I can't confirm except continued testing... Still looking for insight.
The storage on an EC2 instance is ephemeral, and is gone when that instance terminates. Rather than uploading your codebase to that specific instance manually, you should let Elastic Beanstalk do it for you. That way, you application's code base, including previous versions of it, are stored with Elastic Beanstalk, which is automatically deployed to new instances when they are spun up.
For example, for a PHP application, this link explains how it can be deployed using Elastic Beanstalk:
http://docs.aws.amazon.com/elasticbeanstalk/latest/dg/create_deploy_PHP_eb.html