EC2 or S3 to host AngularJS app?

后端 未结 3 498
耶瑟儿~
耶瑟儿~ 2021-02-02 00:14

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

相关标签:
3条回答
  • 2021-02-02 00:44

    Updated: 13 Jan 2020

    Another way, we can host an Angular app with S3 and enable Website hosting

    https://aws.amazon.com/getting-started/projects/build-serverless-web-app-lambda-apigateway-s3-dynamodb-cognito/module-1/

    0 讨论(0)
  • 2021-02-02 01:03

    1) S3 Bucket + CloudFront (CDN) is really fast for static files serving. The Angular minified app is a group of static files which works best here. For the build of those minified files, I recommend using a CI/CD process or build them locally and just upload them to S3.

    2) EC2 requires more work to setup, it consumes resources, it is not necessary for static files or Angular (unless you are using Angular Universal for dynamic content serving), and Node.js is not recommended for static files (Node.js get's blocked since it is single threaded so it is a best practice to keep static files away from it).

    Here is a good article on the topic: https://www.quora.com/Should-I-use-AWS-EC2-to-host-an-Angular-web-app-or-AWS-S3

    0 讨论(0)
  • 2021-02-02 01:08

    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

    0 讨论(0)
提交回复
热议问题