Skip to content

Template Engine Performance Increases

Brian edited this page Aug 5, 2014 · 1 revision

1 Core, templates cached in memory.
Numbers represent the number of milliseconds that it took for 99% of the requests to complete at or under
First Number is compiled, the second is the way we used to do it.

Admin Login:
1000 Total w/ 1 Concurrent: 28/31
1000 Total w/ 10 Concurrent: 47/173
100000 Total w/ 100 Concurrent: 681/2913

Home page:
1000 Total w/ 10 Concurrent: 373/1648

Under minimal load we see a performance boost of approximately 10%. As load increases we
see that more and more resources are consumed during the template processing stage and
things get a little backed up. In these circumstances we see performance gains of up to
427% by parsing the template once and creating an array of parts to be reassembled later.
For simple pages such as the admin login this makes sense. There are a minimal
number of replacements to be made which drastically reduces the number of template parts
that must be assembled. The home page is much more complex. Despite the complexity,
during concurrent load we still saw performance gains of approximately 440%.

The results of the performance improvements demonstrate that we were exhausting an
enormous amount of resources to iterate over each template. Taking the time to compile
the template and then cache it has proved to be much more efficient. The process is
completely backward compatible and only requires that any caches be flushed before
deployment.

The caveat is that not all forms of caching were tested. In addition, the case of caching
being disabled was not tested. In this particular use case I suspect we would still see
performance improvements due to the increased efficiencies of the parsing algorithm.

Compiled: 1000 => 1
-————————-
Server Software:
Server Hostname: 127.0.0.1
Server Port: 8080

Document Path: /admin/login
Document Length: 2788 bytes

Concurrency Level: 1
Time taken for tests: 3.046 seconds
Complete requests: 1000
Failed requests: 0
Write errors: 0
Total transferred: 2955000 bytes
HTML transferred: 2788000 bytes
Requests per second: 328.28 [#/sec] (mean)
Time per request: 3.046 [ms] (mean)
Time per request: 3.046 [ms] (mean, across all concurrent requests)
Transfer rate: 947.34 [Kbytes/sec] received

Connection Times (ms)
min mean[+/-sd] median max
Connect: 0 0 0.0 0 1
Processing: 2 3 1.4 2 21
Waiting: 2 3 1.3 2 21
Total: 2 3 1.4 3 21

Percentage of the requests served within a certain time (ms)
50% 3
66% 3
75% 3
80% 3
90% 4
95% 4
98% 7
99% 10
100% 21 (longest request)

Compiled: 1000 => 10
-————————-
Server Software:
Server Hostname: 127.0.0.1
Server Port: 8080

Document Path: /admin/login
Document Length: 2788 bytes

Concurrency Level: 10
Time taken for tests: 2.138 seconds
Complete requests: 1000
Failed requests: 0
Write errors: 0
Total transferred: 2955000 bytes
HTML transferred: 2788000 bytes
Requests per second: 467.71 [#/sec] (mean)
Time per request: 21.381 [ms] (mean)
Time per request: 2.138 [ms] (mean, across all concurrent requests)
Transfer rate: 1349.69 [Kbytes/sec] received

Connection Times (ms)
min mean[+/-sd] median max
Connect: 0 0 0.0 0 1
Processing: 12 21 5.8 20 47
Waiting: 12 21 5.8 20 47
Total: 12 21 5.8 20 47

Percentage of the requests served within a certain time (ms)
50% 20
66% 22
75% 24
80% 25
90% 29
95% 33
98% 38
99% 41
100% 47 (longest request)

Compiled: 100000 => 100
-——————————
Server Software:
Server Hostname: 127.0.0.1
Server Port: 8080

Document Path: /admin/login
Document Length: 2788 bytes

Concurrency Level: 100
Time taken for tests: 296.289 seconds
Complete requests: 100000
Failed requests: 0
Write errors: 0
Total transferred: 295500000 bytes
HTML transferred: 278800000 bytes
Requests per second: 337.51 [#/sec] (mean)
Time per request: 296.289 [ms] (mean)
Time per request: 2.963 [ms] (mean, across all concurrent requests)
Transfer rate: 973.96 [Kbytes/sec] received

Connection Times (ms)
min mean[+/-sd] median max
Connect: 0 4 75.3 0 13934
Processing: 2 292 619.7 230 12374
Waiting: 2 292 619.7 230 12374
Total: 3 296 647.0 231 14449

Percentage of the requests served within a certain time (ms)
50% 231
66% 278
75% 308
80% 327
90% 407
95% 512
98% 614
99% 681
100% 14449 (longest request)

-——————————————

Uncompiled: 1000 => 1
-—————————-
Server Software:
Server Hostname: 127.0.0.1
Server Port: 8080

Document Path: /admin/login
Document Length: 2788 bytes

Concurrency Level: 1
Time taken for tests: 10.396 seconds
Complete requests: 1000
Failed requests: 0
Write errors: 0
Total transferred: 2955000 bytes
HTML transferred: 2788000 bytes
Requests per second: 96.19 [#/sec] (mean)
Time per request: 10.396 [ms] (mean)
Time per request: 10.396 [ms] (mean, across all concurrent requests)
Transfer rate: 277.58 [Kbytes/sec] received

Connection Times (ms)
min mean[+/-sd] median max
Connect: 0 0 0.0 0 0
Processing: 7 10 4.3 8 38
Waiting: 6 10 4.3 8 38
Total: 7 10 4.3 8 38

Percentage of the requests served within a certain time (ms)
50% 8
66% 11
75% 13
80% 14
90% 16
95% 19
98% 22
99% 24
100% 38 (longest request)

Uncompiled: 1000 => 10
-——————————
Server Software:
Server Hostname: 127.0.0.1
Server Port: 8080

Document Path: /admin/login
Document Length: 2788 bytes

Concurrency Level: 10
Time taken for tests: 9.571 seconds
Complete requests: 1000
Failed requests: 0
Write errors: 0
Total transferred: 2955000 bytes
HTML transferred: 2788000 bytes
Requests per second: 104.48 [#/sec] (mean)
Time per request: 95.709 [ms] (mean)
Time per request: 9.571 [ms] (mean, across all concurrent requests)
Transfer rate: 301.51 [Kbytes/sec] received

Connection Times (ms)
min mean[+/-sd] median max
Connect: 0 0 0.0 0 0
Processing: 41 95 22.2 92 172
Waiting: 41 95 22.2 92 172
Total: 42 95 22.2 93 173

Percentage of the requests served within a certain time (ms)
50% 93
66% 104
75% 112
80% 117
90% 126
95% 134
98% 143
99% 145
100% 173 (longest request)

Uncompiled: 100000 => 100 (I gave up waiting, notice “Complete Requests”)
-———————————
Server Software:
Server Hostname: 127.0.0.1
Server Port: 8080

Document Path: /admin/login
Document Length: 2788 bytes

Concurrency Level: 100
Time taken for tests: 1066.089 seconds
Complete requests: 51515******
Failed requests: 0
Write errors: 0
Total transferred: 152226825 bytes
HTML transferred: 143623820 bytes
Requests per second: 48.32 [#/sec] (mean)
Time per request: 2069.473 [ms] (mean)
Time per request: 20.695 [ms] (mean, across all concurrent requests)
Transfer rate: 139.44 [Kbytes/sec] received

Connection Times (ms)
min mean[+/-sd] median max
Connect: 0 0 0.1 0 4
Processing: 352 2067 453.5 2131 3285
Waiting: 351 2067 453.5 2131 3285
Total: 355 2067 453.5 2131 3285

Percentage of the requests served within a certain time (ms)
50% 2131
66% 2308
75% 2391
80% 2443
90% 2624
95% 2763
98% 2859
99% 2913
100% 3285 (longest request)