Is it possible to prevent Amazon Elastic Beanstalk from dropping an instance and creating a new one on its own, like for it to ask for approval first. I run a redis instance locally because elasticache is quite expensive and I dont want to have to keep installing and starting redis every time elastic beanstalk drops the instance and starts a new one. Is it possible to make sure it keeps a specific instance of EC2?
Elastic Beanstalk is meant for scaling web applications, so I'm not sure it's the right tool here.
If you are just looking to run a single instance with a manual install of redis at low cost, then launching an EC2 instance directly (rather than using Elastic Beanstalk) may be more appropriate?
You would of course then need to bear in mind that the EC2 would not automatically recover in the event of a problem, but it sounds like you don't have that currently anyway.
Related
Which is the best strategy to deploy .net Web application on AWS?
1. On EC2 instance where on single instance deploy both application and MS sql database.
2. On elastic beanstalk where the application is deployed on EC2 instance and database in RDS.
OR any other strategy.
What do you think?
This depends on your use case and budget. Running on the single instance is affordable but will be a single point of failure, and in case your instance goes down, your entire web app is gone. On top of that, any updates can be a nightmare. This is only ideal for development environments.
If you deploy via Beanstalk with external database, it will be expensive but it will be exponentially more fault tolerant. If your EC2 instance goes down, it will get replaced automatically (though you can achieve this even when using single instance. For prod, you must decouple your database instance from your environment, so you can run a database instance in Amazon RDS and configure your application to connect to it on launch. This enables you to connect multiple environments to a database, terminate an environment without affecting the database, and perform seamless updates with blue-green deployments.
Also, the 2nd option will be pretty convenient. All you have to do it give EB your application source bundle and it will do all the legwork. You can read more about EB and RDS setup here.
So, I'm running an AWS Elastic Beanstalk environment with a single instance.
This particular app is a background job app, and in order to deploy changes to my database, I need to pause the app during the deployment process. I'm running into a couple of problems with this: -
I can stop the EC2 instance for that EBS env, however this eventually terminates that instance, and it will spin up a new instance that immediately tries to run (don't want this, I want to control when the EBS env starts again).
When the new instance starts up, the Elastic IP I've associated to the previous instance gets un-allocated, and is not automatically allocated to the new EC2 instance (this is a problem because my database has an IP firewall, so I need it to keep the same IP, before and after pausing).
I read that associating my EBS to an VPC might solve the IP issue, but I can't figure out how to do that. In my configuration it says "This environment is not part of a VPC.", but there isn't an option to make the environment part of a VPC?
Ideally, I'd love to just "pause" the instance, so that it stops and can be re-started without me losing that instance or the IP configuration of that instance.
Can anyone help me to solve these problems, or provide some other method of configuring this setup?
I'm not so experienced with Beanstalk, but you can use .ebsextension to get a script run at instance start, right? Then use that script to call aws api to get available Elastic IP and assign that to the instance itself.
I have an spring boot application which is deployed on EC2 server which runs fine.
But after a certain amount of time, that task is killed automatically. I have tried to search for a solution but couldn't find any or may be I didn't exactly know what to search for. And hence the question on SO.
Is there anything that I can implement which will keep on pinging the instance which will keep it alive?
If yes, how do I implement it? And do I have to consider any other drawback for doing this?
Option 1. Elastic Container Service
Dockerize your app. Create a ECS cluster and publish you service. You Docker container will still run on a EC2 instance, but ECS will automatically maintain the number of app instances "alive". If you container gets killed (because the main Java process got killed), ECS will automatically restart the container.
Option 2. Elastic Beanstalk
Publish your Java app with Elastic Beanstalk and it will automatically monitor the "health" of you web app, and replace "unhealthy" EC2 instances automatically. It only works for web apps, since Elastic Beanstalk does HTTP(S) checks calling a URL you specify.
Option 3. Use Elastic Load Balancer with Auto Scaling Group
ELB can do HTTP(s) checks on you app. If an instance doesn't respond, it will be automatically replaced. You will require to create an AMI or cloud-init script to bootstrap new instances.
I' m a little bit confused with caching.
So let's say i want to build a simple chat website with users login/register and photo uploading.
I plan to save uploaded files in amazon s3.
user data in dynamodb.
So which type of data should i put in elasticache to improve my website performances ?
Another question, if i use elastic beanstalk, should i need to use elastic load balancing along ?
I read that Elastic beanstalk was an automated version of EC2 so no need to take care about manual processes, so is this involving ELB ?
Thanks for helping
I think you are confused about terms. The technologies you are talking about are totally different things.
Elasticache is a managed Memcached/Redis solution. You use it for caching purposes, not for persistent data
Elastic Load Balancing is a managed Load Balancing solution. Like Haproxy. If you want to leverage high availability and scalability features of AWS you need it. You create an autoscaling group which spawns or kills EC2 instances whenever it is needed (according to rules you will set up) and autoscaling groups attaches or detaches EC2 instances from ELB. If you install your application only to one instance you do not have to worry about it, but if you are doing like that you're doing wrong, it is not how AWS works. Just go and use a cheaper and easier VPS company.
Elastic Beanstalk is a wrapper service. It is intented to abstract the complexity of all these EC2 stuff. It is like Heroku or Google App Engine, you give it your application file (or docker image) and it just installs everything for you.
If you are new at AWS I'd recommend you to start with Elastic Beanstalk, understand how it works under the hood and which type of resources will create for you. Once you learn the basics, you can create your own stack and customize it more. But Elasticbeanstalk is also production-ready product. You can trust in it.
I created a elastic beanstalk environment and it created an EC2 instance. Then I thought I don't actually need this yet so I'll stop the EC2 instance, but then it seemed to start another one.
So my question is if I have an EB instance will I be charged by the hour for the underlying EC2 image all the time or only when the the service it provides is being access via the public elasticip. And if Im charged all the time is there a way to halt a elastic beanstalk application or only delete it or instantiate to a new environment.
The auto scaling feature of Elastic Beanstalk will automatically start another instance if a current instance continues to fail a health check. Stopping individual instances outside of the environment will cause failed health checks and trigger a new instance to be spun up.
You will be charged when the components within the environment are running as stated by Amazon here:
There is no additional charge for Elastic Beanstalk – you only pay for the underlying AWS resources (e.g. Amazon EC2, Amazon S3) that your application consumes.
You can completely stop an environment through the CLI. I gave this answer to a previous question about starting and stopping Elastic Beanstalk:
The EB command line interface has an eb stop command. Here is a little bit about what the command actually does:
The eb stop command deletes the AWS resources that are running your application (such as the ELB and the EC2 instances). It however leaves behind all of the application versions and configuration settings that you had deployed, so you can quickly get started again. Eb stop is ideal when you are developing and testing your application and don’t need the AWS resources running over night. You can get going again by simply running eb start.