我是一名RoR初学者程序员,计划使用Heroku部署我的应用程序。我的其他顾问朋友说,Heroku真的很简单,很好用。唯一的问题是我仍然不知道赫鲁是做什么的…

我看了他们的网站,简而言之,Heroku所做的是帮助缩放,但是……这有什么关系呢?Heroku如何帮助:

速度——我的研究表明,如果我的目标受众是美国/亚洲,那么在美国东海岸部署AWS将是最快的。 安全性——他们有多安全? 缩放-它实际上是如何工作的? 成本效率——有一些像动态的东西,使其易于扩展。 他们在竞争对手面前表现如何?比如Engine Yard和bluebox?

请用外行的英语术语来解释……我是一个初级程序员。


当前回答

现有的答案大致准确:

Heroku非常易于使用和部署,可以很容易地配置为自动部署存储库(如GitHub),有很多第三方插件,每个实例收费更高。 AWS拥有更广泛的价格具有竞争力的第一方服务,包括DNS、负载平衡、廉价的文件存储,并具有能够定义安全策略等企业功能。

对于tl;dr,跳到这篇文章的结尾。

AWS ElasticBeanstalk尝试提供一个类似heroku的自动伸缩和简单部署平台。由于它使用EC2实例(它自动创建),EB服务器可以做任何其他EC2实例可以做的事情,而且运行成本很低。

EB的部署非常缓慢;每台服务器部署一次更新可能需要10-15分钟,部署到更大的集群可能需要将近一个小时——相比之下,在Heroku上部署一次更新只需几秒钟。EB上的部署也不是特别无缝地处理,这可能会对应用程序设计造成限制。

您可以使用ElasticBeanstalk在幕后使用的所有服务来构建自己的定制系统(使用CodeDeploy, Elastic Load Balancer, Auto Scaling Groups -以及CodeCommit, CodeBuild和CodePipeline,如果您想全部投入的话),但您绝对可以花几个星期的时间来第一次设置它,因为它相当复杂,比仅在EC2中配置东西稍微复杂一些。

AWS Lightsail提供了一个价格具有竞争力的托管选项,但对部署或扩展没有帮助——它实际上只是他们EC2产品的包装(但成本更高)。它允许您在初始设置时自动运行bash脚本,这是一个不错的操作,但与仅设置EC2实例的成本相比(您也可以通过编程方式设置EC2实例),它的成本较高。

关于比较的一些想法(试着回答问题,尽管是以一种迂回的方式):

Don't underestimate how much work system administration is, including keeping everything you have installed up to date with security patches (and occasional OS updates). Don't underestimate how much of a benefit automatic deployment, auto-scaling, and SSL provisioning and configuration are. Automatic deployment when you update your Git repository is effortless with Heroku. It is near instant, graceful so there are no outages for end users and can be set to update only if the tests / Continuous Integration passes so you don't break your site if you deploy broken code. You can also use ElasticBeanstalk for automatic deployment, but be prepared to spend a week setting that up the first time - you may have to change how you deploy and build assets (like CSS and JS) to work with how ElasticBeanstalk handles deployments or build logic into your app to handle deployments. Be aware in estimating costs that for seamless deployment with no outage on EB you need to run multiple instances - EB rolls out updates to each server individually so that your service is not degraded - where as Heroku spins up a new dyno for you and just deprecates the old service until all the requests to it are done being handled (then it deletes it). Interestingly, the hosting cost of running multiple servers with EB can be cheaper than a single Heroku instance, especially once you include the cost of add-ons.

其他一些问题没有被特别问到,但被其他答案提出:

Using a different provider for production and development is a bad idea. I am cringing that people are suggesting this. While ideally code should run just fine on any reasonable platform so it's as portable as possible, versions of software on each host will vary greatly and just because code runs in staging doesn't mean it will run in production (e.g. major Node.js/Ruby/Python/PHP/Perl versions can differ in ways that make code incompatible, often in silent ways that might not be caught even if you have decent test coverage). What is a good idea is to leverage something like Heroku for prototyping, smaller projects and microsites - so you can build and deploy things quickly without investing a lot of time in configuration and maintenance. Be sure to factor in the cost of running both production and pre-production instances when making that decision, not forgetting the cost of replicating the entire environment (including third party services such as data stores / add ons, installing and configuring SSL, etc). If using AWS, be wary of AWS pre-configured instances from vendors like Bitnami - they are a security nightmare. They can expose lots of notoriously vulnerable applications by default without mentioning it in the description. Consider instead just using a well supported mainstream distribution, such as Ubuntu or Debian (or CentOS if you need RPM support). Note: Amazon offer have their own distribution called Amazon Linux, which uses RPM, but it's EC2 specific and less well supported by third party/open source software. You could also setup an EC2 instance on AWS (or Lightsail) and configure with something like flynn or dokku on it - on which you could then deploy multiple sites easily, which can be worth it if you maintain a lot of services or want to be able to spin up new things easily. However getting it set up is not as automagic as just using Heroku and you can end up spending a lot of time configuring and maintaining it (to the point I've found deploying using Amazon clustering and Docker Swarm to be easier than setting them up; YMMV).

我同时使用AWS EC实例(单独和集群)、Elastic Beanstalk和Lightsail和Heroku,这取决于我正在从事的项目的需求。

我讨厌花时间配置服务,但如果我什么都用Heroku,而AWS只算其中的一小部分,我的Heroku账单每年将高达数千美元。

博士tl;

如果钱从来都不是问题,我会在几乎所有事情上都使用Heroku,因为它节省了大量时间——但我仍然想在更复杂的项目上使用AWS,在这些项目中,我需要Heroku无法提供的灵活性和更高级的服务。

对我来说,最理想的场景是ElasticBeanstalk的工作方式更像Heroku——也就是说,配置更简单,部署机制更快更好。

一个类似于此的例子是now.sh,它实际上在幕后使用AWS,但使部署和集群像在Heroku上一样简单(具有自动SSL、DNS、优雅部署、超级简单的集群设置和管理)。

我在Node.js应用程序和Docker镜像部署中都经常使用它,主要的警告是实例是共享的(这反映在它们的低成本上),目前没有购买专用实例的选项。然而,他们的开源部署工具“现在”也可以用于部署到AWS以及谷歌Cloud和Azure上的专用实例。

其他回答

Actually you can use both - you can develop an app with amazon servers ec2. Then push it (with git) to heroku for free for awhile (use heroku free tier to serve it to the public) and test it like so. It is very cost effective in comparison to rent a server, but you will have to talk with a more restrictive heroku api which is something you should think about. Source: this method was adopted for one of my online classes "Startup engineering from Coursera/Stanford by Balaji S. Srinivasan and Vijay S. Pande

有时候,我想知道为什么人们把AWS比作Heroku。AWS是一个IAAS(基础设施即服务),它清楚地说明了系统的健壮性和计算性。另一方面,Heroku只是一个SAAS,它基本上只是AWS服务的一部分。所以,当你可以使用Heroku将第一款产品发布到prime时,为什么还要费劲建立AWS呢?

Heroku是免费的,简单的,容易部署几乎所有类型的堆栈到web。Heroku是专门构建的,可以在短时间内绕过将应用程序传输到活动服务器的所有麻烦。

不过,您可能希望使用双方提供的任何教程来部署应用程序并进行比较

AWS DOCS和Heroku DOCS

从开发、IT和业务目标来看,有很多不同的方法来看待这个决定,所以如果它看起来势不可挡,也不要感到难过。但是,不要过度考虑可伸缩性。

想想你的需求。

我设计的网站每天服务超过800万次,每周提供tb的视频,这些网站建立在25万美元的硬件基础设施上,由庞大的IT劳动力组成。

但我也有一些较小的网站,它们的设计目标是每年产生1 - 2万美元,没有很高的流量、数据库或处理要求,我用一个每月10美元的通用托管账户毫不妥协地运行这些网站。

在未来,部署将更像Heroku而不是AWS,这只是因为进步。扩大互联网基础设施的IT旋钮没有任何价值,因为它不能越来越自动化,而且它与你所提供的产品或服务的价值没有任何关系。

此外,要记住,对于一个商业网站来说,可扩展性是我们通常所说的“好问题”——尽管像Facebook和Twitter这样的网站的可扩展性问题非常引人注目,但它们对他们的成功没有任何负面影响——这条新闻甚至可能有助于更多的注册(所有的新闻都是好新闻)。

如果你有一个每天生成超过10万份文件的服务,并且存在伸缩性问题,我很乐意帮你解决这个问题,不管你运行的是什么语言、数据库、平台或基础设施!

可伸缩性是一个可修复的实现问题——没有客户是一个存在的问题。

有趣的是,Heroku实际上在后端使用AWS。它消除了所有开销,并为您在EC2上进行体系结构管理。(在一次面试中从一家大公司的高级工程师那里得到的知识)

尽管AWS和Heroku都是云平台,但它们是不同的,因为AWS是IaaS, Heroku是PaaS