Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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?

Some of my thoughts are:

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

That's about it.

Disadvantages of not simply using Bean Stalk to do it all

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

Am I missing another advantage

like image 435
KCIsLearning Avatar asked Jan 04 '17 15:01

KCIsLearning


1 Answers

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

Separation of Code

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).

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.

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.

Separation of Deployment

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.

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.

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

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.

Faster Iteration

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.

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.

Simpler Product Logic

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

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.

like image 92
rdegges Avatar answered Oct 10 '22 09:10

rdegges