在 S3 与 EC2 上部署 SPA(angular2)

Deploying SPA(angular2) on S3 vs EC2

我有 angular 带有 nodejs 后端(REST API)的应用程序。我对 S3 和 EC2 感到困惑。哪个更好,部署到 each.Considering 平均负载的优缺点是什么。非常感谢您的帮助。

您可以在 EC2 中设置一个流行的 ubuntu 服务器 Nginx 为您的 angular 前端和代理请求提供服务 节点 Api

S3 是一个主要用于静态内容和媒体文件(jpg、字体、mp4 等)的文件存储

理论上您可以在 EC2 实例中托管所有内容,但使用 S3 可以更轻松地扩展、备份和迁移您的静态资产。

您可能可以从一个简单的 EC2 实例开始 运行 一切,当一切正常时您可以尝试将静态资产移动到 S3

我自己想出来的

S3 is used to store static assets like videos, photos, text file and any other format file. It is highly scalable, reliable, fast, inexpensive data storage infrastructure.

EC2 is a like your own server. And it is on Cloud so computing capacity can be decreased or increased instantly as per server need.

所以我的困惑很明显...

When we build Angular2 Application it generates .js files which called bundle in term of angular2. Now, these files can be hosted on S3 Bucket. And can be accessed through CloudFront in front of it. Which is very fast cache enabled. And pricing model is pay per request.

But EC2 is like running own server. And we have to configure server it self so for angular application it is not good. It is good for node Applicationas it can do computation.