EC2 or S3 to host AngularJS app?

Leon picture Leon · Jan 10, 2018 · Viewed 8.5k times · Source

I want to launch a production version of an AngularJS application, and I find Amazon AWS to be an awesome hosting suite. As AngularJS is essentially static it could be hosted on S3 storage, or on an EC2 server with node.js backend.

Either of these solutions would suit my deployment method, so the question is, will I (in theory) get better performance from one or the other, and why? Is there anything wrong with hosting a professional website frontend on S3? Does anyone have any experience with both methods? The site involves streaming audio, video and potentially many many users.

Any advice appreciated.

Answer

Kush Vyas picture Kush Vyas · Jan 10, 2018

On reviewing your requirement if you are adamant about using S3 For Front end , I would like to suggest you use Cloudfront With S3 , the reason being:

S3 can't handle custom HTTP routes. Since "export" isn't a file S3 doesn't know what to do. In order to properly handle Angular routes you must use an actual HTTP Server like Nginx, Apache, IIS.

You can read these blog posts for more information :

How to host your Angular 2 application in AWS with S3

Using AWS CloudFront to serve an SPA hosted on S3

Now Moving to second option you mentioned using EC2 To host , I think using that option would give you more control over your environment and more flexibility on scaling too.

Thanks