Better, Faster, Stronger with Angular.js
Oh, and more flexible too...
Posted 2 years ago by Tom Maiaroto.
So I recently gave hosting some static content on Amazon S3 a whirl. I wanted to ensure that, in the event of massive traffic, the site (along with my other sites) didn't go down. I also wanted to host it for as cheap as possible. I'm still waiting to see the next bill to check if my quick math was accurate.
With the CORS feature which was recently added to S3, I think there's a lot of potential. I love designing web hosting architecture. It changes based on how the application works, but caching always remains a big challenge. That's why there is a plethora of options. So having S3 another option is exciting. One can practically offload most of the traffic to their web server by cleverly using Angular.js and S3. Many sites have more reads than writes, so if you were to cache JSON files on S3, voila - zero traffic back to your web server to hit up a database.
Even still, if the web server was just responsible for a RESTful application, you really shouldn't need a large web server. I think a lot of energy is wasted in serving up web pages...Worse yet, web pages rendered through a server side scripting language like PHP or Python, etc.
The stronger part is that Angular.js also allows you to have test cases. Crazy, I know! So on top of whatever QA process you do, Selenium tests, etc. you also have testing with Angular.js. The other thing that makes it stronger is now you're taking a dynamic thing and making it more static. That makes a site stronger in terms of handling traffic. Here we go back to S3. There's no reason why your Angular.js templates (and all of it really) can't be hosted on a CDN like S3. The CSS and HTML as well for that matter. Build in cases for when your REST service is down and cache what can be cached and you will end up with a site that will virtually never crash. So even if your web server that draws from a database and handles authentication, etc. is down, you still could be showing your users something. The average user may not even know there's a problem. This will give you time to bring on more servers, restart something, fix something, etc. You'll also never have to worry about a user seeing an ugly server error message. Not just your commonly decorate 404's, but you know those 501's and 505's that we all love and like to forget about.
There's a few other interesting things now that your templates can come from anywhere. Remember, traditionally, they couldn't because they were tied together with back-end server-side code. Now that they are truly isolated...Think about this for a second, "fork this site." If I tied in GitHub authentication here and allowed you to link your fork of my site (the front-end template portions), you could easily change the design of my site and everyone could then use that design. Maybe a silly example, but think about it for a CMS. Installing themes for WordPress, Drupal, etc. is terrible. You upload some zip file through the interface that's supposed to make it easy (or FTP it all to the proper places) and pray it works out. Remember, it's not exactly like these themes are testable with test cases. So you or, worse yet, your visitors will stumble upon the problems at some point sooner or later if they are there. Then if you want to modify that theme...Oh man, now you have to again pick out all the HTML between the PHP code (in this case) and you need to learn the anatomy of a WordPress theme. I mean, fair enough, these template systems were devised in an age when there really wasn't much better. However, now we do have something better. Faster. Stronger. Oh and more flexible. You will have a many more options for your application and hosting architecture as well as how you divide up the work to build the site or application if you're working on something large with a team.
Search for Posts
Popular Labelssocial media virality score general internet web development reviews and opinions php web tools hosting lithium web design
- 16 Jun Social Media Analytics on a Budget
- 15 May Thinking About Using Laravel?
- 22 Apr Why Dart?
- 16 Jan PHP 5 Framework Comparisons: Bootstrap
- 02 Jan GitHub Issues Feels
- 23 Dec News Ox: Building a Better News Aggregator
- 18 Dec Discovery and Ranking
- 12 Dec Viral News Search
- 06 Dec Flexible Twitter Bootstrap Grid
- 04 Dec Problems With Google Analytics