一起使用S3作为静态网页和EC2作为REST API? (AWS) [英] Using S3 as static web page and EC2 as REST API for it together? (AWS)

查看:227
本文介绍了一起使用S3作为静态网页和EC2作为REST API? (AWS)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我找到了这个链接,该链接涉及将静态数据和Web api分离为静态s3 Web服务器以及用于api和ec2 Web服务器的Bean stalk应用程序以创建网站。 Charles的回答是正确的,CORS是您如何解决在两个域之间移动的问题。

I found this link that talks about separating static data and a web api into a static s3 web server and a bean stalk application for an api and an ec2 web server to create a website. The answer from Charles is accurate, CORS is how you address the problem with moving between the two domains.

How to use S3 as static web page and EC2 as REST API for it together? (AWS)

我的问题是,为什么要这么做?

The question I have is why you would do this?

我的一些想法是:

优点-我们使用node作为api的网络服务器,会减轻节点进程的负担。

Advantage - We use node as the web server for the api and this would lighten the burden on the node process.

就是这样。

不简单使用Bean Stalk的缺点做到这一切

Disadvantages of not simply using Bean Stalk to do it all

CORS的复杂性增加
更新软件更加复杂
除非您有大量的静态数据,否则似乎过分杀伤力了我不会

Added complexity of CORS Updating the software is more complex Seems like overkill unless you have a serious amount of static data which I do not

我错过了另一个优势

推荐答案

有将前端逻辑与后端逻辑分离并分别部署有很多好处。

There are a lot of advantages to separating your front-end logic out from your back-end logic, and deploying them separately.

第一个重要原因是,通过这种方式,您可以将业务逻辑(您的API)与设计(您的前端)分开。

The first big reason is that doing things this way allows you to separate your business logic (your API) from your design (your front-end).

您可以将两个项目保存在单独的Git存储库中。您可以让您的设计师根据需要向前端项目发送尽可能多的更新,而无需打扰工程师。

You can keep both projects in separate Git repos. You can have your designers ship as many updates to the front-end project as they want, without ever needing to bother an engineer.

在单个整体项目中执行此操作(例如,在Elastic Beanstalk上):几乎是不可能的,因为设计人员需要通过工程团队来迭代他们的代码。

Doing that in a single monolithic project (on Elastic Beanstalk, for instance): would be nearly impossible, as designers would need to iterate their code through the engineering team.

Web服务器运行缓慢。文件服务器(如S3)速度很快。之所以如此之快,是因为没有运行代码来访问文件服务器中的文件-只有文件正在下载。

Web servers are slow. File servers (like S3) are fast. The reason they are fast is that there is no 'code' running to access files from a file server -- there is just a file being downloaded.

例如,从EC2实例提供一个单一的Web应用程序,这意味着要查看页面,您需要运行一些代码来生成HTML。

If you have a single monolithic web application served from an EC2 instance, for example, this means that to view a page, you need to run some code to generate that HTML.

如果部署您的前端代码到S3,但是,该文件可以通过Web浏览器以更快的速度直接下载。

If you deploy your front-end code to S3, however, that file can be directly downloaded by the web browser MUCH faster.

PROTIP :您还可以将S3网站置于CloudFront(CDN)的后面,以通过在世界各地的多个数据中心保留缓存的副本来加快网站的速度。

PROTIP: You can also put your S3 website behind CloudFront (a CDN) to speed up your website EVEN MORE by keeping a cached copy if it in multiple data centers around the world.

当您将项目分离并分别部署时,可以更快地进行迭代。

When you have your projects separated, and deployed separately, you can iterate faster.

比方说,最终团队在网站中发现错误。他们可以轻松地修补/发布修补程序,而无需进行工程。

Let's say your front-end team finds a bug in the website. They can easily patch / release a fix WITHOUT going through engineering.

您的工程师也是如此-他们现在有更多时间专注于构建核心应用程序逻辑,并且可以部署修补程序而不必担心UI更改等。

The same is true of your engineers -- they now have more time to focus on building the core application logic, and can deploy fixes without worrying about UI changes, etc.

如前所述,您还可以获得简化后端逻辑的好处。

When you deploy things separately as you've described, you also get the benefit of simplifying your back-end logic.

通过让您的核心工程师构建API,而不必担心前端-出于担忧,您可以比其他方式更快地发布更新。

By having your core engineers just build APIs, and stop worrying about front-end concerns, you can ship updates significantly quicker than you could otherwise.

这篇关于一起使用S3作为静态网页和EC2作为REST API? (AWS)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆