Best practices upgrading web app on Amazon EC2 - amazon-ec2

Let’s say I've already deployed a web app on EC2, maybe thru FTP or Remote desktop. So from now on, what would be the best way to update to a new version of my web app?
My main concern would be when running several instances of that web app behind the load balancer: is there a way to update all instances at once so that there are never two instances running with different versions of the web app?
Thanks.

Yeah. Remove each instance from the load balancer (using the API or AWS management console) and update its software, until there is only one instance left. Upgrade that one without removing it, then re-add all the other instances.
There will be no time when the load balancer sends your traffic to two different versions of the software.

Related

How to implement auto stop for iddle or inactive applications on Google cloud platform like Heroku does?

Classic approach on GCP is rent a linux host with static monthly payment. It doesn't matter if your application is not running or users aren't consuming it, you will always pay the static monthly payment. I think this is acceptable for production environments but for development and testing not.
This does not happen on Heroku :
If an app has a free web dyno, and that dyno receives no web traffic in a 30-minute period, it will sleep. In addition to the web dyno sleeping, the worker dyno (if present) will also sleep.
Free web dynos do not consume free dyno hours while sleeping.
Question
How stop or delete app on google (gae, cloud run, cloud build, containers) if does not receive web traffic?
If it is possible using just google tools it would be great:
https://cloud.google.com/products
Idea
Developing a basic router with nodejs which works as minimal balancer. If web traffic is not detected for some apps, an instruction to google cloud platform api could stop the app or container. This would also apply to other clouds.
Any help is appreciated.
Update
I cannot find any solution yet. I will try to add that feature here https://github.com/jrichardsz/http-operator or a basic shell script to detect incoming request to a specific port like How to print incoming http request on specific port
GCP is offering several serverless products (like you mentioned) and they offer a pricing where you are only charged for the resources you use (when requests are processed).
In Cloud Run you are only billed when an instance is handling a
request using the autoscaling to know more. See their pricing as well for a better overview.
For Google App Engine the app.yaml configuration file contains several settings you can use to adjust the trade-off between performance and resource load for a specific version of your app. You
also check this link how to manage the auto scaling settings.
You can also check this Google Cloud blog for other strategies in auto scaling your applications.
To answer the Comment below:
This video can help you better understand their differences to be able to see the appropriate service for your use case.
To clarify, there's 2 variations of cloud run, the first is managed by google and the other runs on gke. As long as your classic application (api app) is stateless, you should be able to deploy it as a container and take advantage of being charged based on only the resources you use. Snippets would fall under Cloud function where it only runs functions based on triggers.
You can choose to deploy your Cloud Run app on fully managed infrastructure ("serverless", pay per use, auto-scaling up rapidly and down to 0 depending on traffic) or on a Google Kubernetes Engine cluster.
It is also possible to run Docker containers in Serverless using App Engine (Flexible). App Engine is always fully managed, with auto-scaling. App Engine Flex auto-scales gradually and down to 1. App Engine Second Generation auto-scales up rapidly and down to 0.
In your current use case I would recommend to use Cloud Run, check its limitations first before getting started. See the official documentation here and on Cloud Run How-To Guides

Elasticsearch on cloudfoundary

I am trying to deploy my asp.net core 2.2 application using buildpacks on SCP cloudfoundary. My application has dependency on elasticsearch. How can I assembly my buildpack file so that I can install both my dotnet core 2.2. app along with Elasticsearch running as a service.
Thanks,
I don't think you would want to run Elasticsearch as an app on Cloud Foundry because it would be difficult to persist any data. The file system your app gets on CF is ephemeral, and is scoped to the lifetime of your app instance. Thus if your app restarts anything you've written to disk is gone. If that doesn't matter to you, I suppose you could proceed.
That said, you wouldn't want to run it as part of the same app. You'd want to push them separately as two different apps. That way you can scale them separately, if one crashes, you don't lose both, and you have dedicated memory limits for each app (i.e. one of the two, cannot consume more than it's share of memory and crash the app).
Having said all that, my suggestion would be to run cf marketplace and see if there is a Elasticsearch service in your Marketplace. That would be the easiest way forward. You could simply cf create-service and make your Elasticsearch service.
If there isn't one in your marketplace, then you can look at getting one through AWS/GCP/Azure or some other provider. Then you can create a service instance in CF with cf cups (it's called a user-provided service). You can bind this user-provided service to your app just like a service created through the marketplace.
If all else fails and you can't find a service from a provider you trust, you could always run your own. Then use a user-provided service to pass in creds.

Cheapest, future-scalable way to host a HTTPS PHP Website on AWS?

I've already got an RDS instance configured and running, but currently we're still running on our old web host. We'd like to decrease latency by hosting the code within AWS.
Two concerns:
1) Future scalability
2) Redundancy ... not a huge concern but AWS does occasionally go down.
Has anyone had this problem where they just need to cheaply run what is essentially a database interface via a language such as PHP/Ruby, in 2 regions? (with one as a failover)
Does Amazon offer something that automatically manages resources, that's also cost effective?
Amazon's Elastic Beanstalk service supports both PHP and Ruby apps natively, and allows you to scale your app servers automatically.
In a second region, run a slave RDS instance off of your master (easy to set up in RDS) and have another beanstalk setup there ready as a failover.

deploying an asp.net application on multiple ec2 instances?

Suppose i have created an amazon load balancer with three ec2 instances :A,B,C.
Whenever i deploy an asp.net app to the instance A ,Does Load balancing deploy/updates it in the B,C instances?
If no,how one can achieve that?
The ELB (load balancer) has nothing to do with the deployment, at least nothing useful. It's just there to split traffic to different instances for incoming (http) requests from clients.
AWS Elastic Beanstalk (the easy way)
Create an Elastic Beanstalk Application, where you deploy your asp.net application via the Amazon Visual Studio Toolkit. The process is very straightforward and it's not your part to do the deployment to all instances. After building and uploading the project to S3 beanstalk will distribute the new version to all instances within 20-60 seconds, depending on the size.
Advantage:
very easy
existing Tools
it's Platform as a Service (PaaS), not Infrastructure as a Service (IaaS) which applies if you setup all AWS resources yourself.
Disadvantage:
you can just deploy ONE "project" per Beanstalk App which means you are not able to deploy different "virtual directorie apps"
maybe you need to build your own custom Beanstalk AMI, but usually you can use a AWS default image (beanstalk host manager needs to run on the instance, otherwise it will not work)
you may lose a little bit of control, but imho that's not an issue
More Infos:
https://aws.amazon.com/elasticbeanstalk/
https://forums.aws.amazon.com/forum.jspa?forumID=86
http://aws.amazon.com/visualstudio/
The harder way
If you have already setup a load balancer with 3 instances behind it's your task to deploy your code to all instances.
You could do that e.g. via Visual Studio and Web Deploy deploying to all 3 instances after another... you need to use the public dns name here of he instances itself, not the load balancer/app dns name.
You could use some kind of web server sync software for the app directories, e.g. MS web deploy, which should work, but the setup is not like fun imho and definitely more complex than Beanstalk.
More Infos:
http://www.iis.net/downloads/microsoft/web-deploy

Is it possible to use AWS as a web host? [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed last year.
The community reviewed whether to reopen this question last year and left it closed:
Original close reason(s) were not resolved
Improve this question
Is it possible to load / host an entire website using AWS? Or is it only a service that can load specific pieces of a website - such as images, etc. Obviously, I'd want to use my own domain. If you can use it, are there any limitations?
Here's the AWS link, for context:
http://aws.amazon.com/s3/
AWS = Amazon Web Services = a suite of different web services.
S3 (which you linked to) is an object store. You can't host a web service on S3.
EC2, also under the AWS umbrella, is virtualized compute space. You CAN host a web service on EC2. It is just like having a server in a rack somewhere, except that when you shut down an instance, it is gone forever. But using EBS, which is like a virtualized hard drive, will prevent you from losing your data when the EC2 instance shuts down.
See http://aws.amazon.com/ec2/ and http://aws.amazon.com/ebs/
EDIT: Aug 12, 2016 they have a dedicated section on how to get started hosting a website on AWS. Please note S3 only allows STATIC websites but AWS provides SDKs in case you want to run PHP, ASP.NET, etc on your instance. See the links for more details.
http://docs.aws.amazon.com/AmazonS3/latest/dev/WebsiteHosting.html
https://aws.amazon.com/websites/
So guess what I just found while doing some Google searches for hosting on AWS?! A blog post by the AWS stating that you can (now) host a website on S3. (Funny enough, the StackOverflow and the AWS post were right next to each other in the SERPs!)
http://aws.typepad.com/aws/2011/02/host-your-static-website-on-amazon-s3.html
Yes it is completely possible to host websites on AWS in 2 ways:
1.) Easy - S3 (Simple Storage Solution) is a bucket storage solution that lets you serve static content e.g. images but has recently been upgraded so you can use it to host flat .html files and your site will get served by a default Apache installation with very little configuration on your part (but also little control).
2.) Trickier - You can use EC2 (Elastic Compute Cloud) and create a virtual Linux instance then install Apache/NGinx (or whatever) on that to give you complete control over serving whatever/however you want. You use SecurityGroups to enable/disable ports for individual machines or groups of them.
#danben your EC2 instance does not have a constant public IP by default. Amazon makes you use a CNAME - not an A record as your IP may change under load. You have to pay for an ElasticIP to get a consistent public IP for your setup (or use some sort of DynDNS)
As #danben mentioned, there is a difference between S3 and EC2.
One thing that may be interesting for people looking to host a website on Amazon, specially if they want to start small is that Amazon started offering a free tier some months ago. Together with services like BitNami Cloud Hosting (disclaimer, I helped design it, so it is a bit like my baby :) means you can get your site on the Amazon cloud in just minutes, for basically 0 dollars. You still need to give credit card info to Amazon, but it will not be charged if you stay within the limits of their free tier.
One thing to consider too is that at the time of writing this (Jul 2011), Amazon restricts you to one IP address per server. If you need to host multiple domains, you may need to use name-based virtual hosts or some tricks using their Elastic Load Balancer (which will cost you more). But all in all, it is worth a try if you are a bit technical and want more control than what shared hosting provides you
At reinvent 2018, AWS launched the Amplify Console, a continuous deployment and hosting service for single page and static apps with serverless backends. Check it out: http://console.amplify.aws
Yes! You can easily host your website on AWS.
There are two ways;
One with Native AWS - This is a tricky method that requires expertise and a series of commands to run. You need to manage security, DNS, SSL, server protocols, and more by yourself.
Managed Cloud Platforms like Cloudways - You can easily launch an AWS server and host your website with a few clicks. Moreover, you can quickly manage your server protocols, packages, security firewalls, DNS, and more from its intuitive platform.

Resources