Skip to content
Permalink
Browse files

perf(platform-server): use shared `DomElementSchemaRegistry` instance (

…angular#28150) (angular#28151)

Right now the `ServerRendererFactory2` creates a new instance of the
`DomElementSchemaRegistry` for each and every request, which is quite
costly (for the Tour of Heroes SSR this takes around **30%** of the
overall execution time). Since the schema is never modified, but only
used in a read-only fashion, it should be possible to re-use a single
instance instead.

Naive performance testing with 100 concurrent connections and 1000
requests in total shows an approximate **33%** improvement in Req/Sec
on the Tour of Heroes SSR example.

PR Close angular#28150

PR Close angular#28151
  • Loading branch information...
bmeurer authored and wKoza committed Jan 15, 2019
1 parent b21edb1 commit 9723683d7a0d23d476258d5559c44eda3b08ad68
Showing with 3 additions and 1 deletion.
  1. +3 −1 packages/platform-server/src/server_renderer.ts
@@ -12,11 +12,13 @@ import {DOCUMENT, EventManager, ɵNAMESPACE_URIS as NAMESPACE_URIS, ɵSharedStyl

const EMPTY_ARRAY: any[] = [];

const DEFAULT_SCHEMA = new DomElementSchemaRegistry();

@Injectable()
export class ServerRendererFactory2 implements RendererFactory2 {
private rendererByCompId = new Map<string, Renderer2>();
private defaultRenderer: Renderer2;
private schema = new DomElementSchemaRegistry();
private schema = DEFAULT_SCHEMA;

constructor(
private eventManager: EventManager, private ngZone: NgZone,

0 comments on commit 9723683

Please sign in to comment.
You can’t perform that action at this time.