Skip to content
This repository has been archived by the owner on Aug 9, 2018. It is now read-only.

Fast render AngularJS on server #37

Open
vostrik opened this issue Sep 14, 2016 · 1 comment
Open

Fast render AngularJS on server #37

vostrik opened this issue Sep 14, 2016 · 1 comment

Comments

@vostrik
Copy link

vostrik commented Sep 14, 2016

Hi,
can you tell about real implementations of this server?

I mean render heavy directives, etc.

@apparentlymart
Copy link
Collaborator

Without an idea of what specifically you're interested in it's hard to give a detailed answer, but here are some general insights about our main application using this library:

  • When we first started trying to use AngularJS-Server, this application had already existed for some time and had some expensive directives and services. Without any optimizations, our app was taking nearly 10s to render under AngularJS-Server, with much of that being spent in DOM manipulation.
  • We were able to improve performance a reasonable amount through changes that went into AngularJS-Server itself. You can see some of these in the ngoverrides.js file, where we re-implemented certain Angular services to skip unnecessary DOM manipulation work.
  • We spent a non-trivial amount of time doing CPU optimization work within our application itself. This was a long time ago so I don't remember all of the details, but in particular we had some code that would repeatedly walk the DOM to measure layout and that was both slow and useless in jsdom, since jsdom doesn't do any layout.
  • We also saw lots of improvements from using one-time bindings once that became available in AngularJS. This shortens digest cycles, which were the other big CPU blocker aside from jsdom.
  • The AngularJS-Server-based rendering of our pages today is taking between 1 and 2 seconds most of the time, with some outlier pages taking up to 4 seconds. We use a caching proxy layer in front of the renderer to mitigate that, and explicitly prime our caches when a new page is added so that the first visitor sees a fast response.
  • We run AngularJS-Server in dedicated worker processes that each render one page at a time, because AngularJS, our app and jsdom are too CPU-intensive to run in a shared nodejs process; digest cycles and DOM manipulations will stall the NodeJS event loop and hurt performance of any concurrent operations.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants