Skip to content

Instantly share code, notes, and snippets.

@bronson
Last active September 3, 2015 21:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bronson/3fd1c33e0b59b0a377b5 to your computer and use it in GitHub Desktop.
Save bronson/3fd1c33e0b59b0a377b5 to your computer and use it in GitHub Desktop.

Setup

To prepare the production database and launch the server, run these two command lines:

RAILS_ENV=production rake db:drop db:create db:migrate db:seed assets:precompile
RAILS_ENV=production RAILS_SERVE_STATIC_ASSETS=true rails server

Now, load each URL and see what Rack and Chrome Devtools show for response time.

Fair warning: this is running on a Macbook Air with 20% battery... kinda flimsy.

Results

I'm only including the client scripting result here. Chrome's other numbers are pretty noisy or too small to consider.

Client Server
no args ~118ms 4ms
?noprerender=1 ~118ms 2ms
?nojs=1 ~87ms 4ms
?nojs=1&noprerender=1 ~73ms 2ms

Caveats

It's a micro benchmark. These numbers can suggest a relative trend but, without running a proper load test, they won't contain much data.

Also, this page is too simple. Client-side, the tiny rendering time is swamped by JS parsing and page load. It's more apparent server-side, but that's just because the server isn't doing anything else.

Conclusions

Client

I don't see a clear signal. Chrome is showing large variability from run to run. If anything, pre-rendering might slow down page load slightly.

The takeaway: simple client-side rendering hardly affects page load times.

Server

Server-side rendering does add noticeably to the server's response time. Predictably, each server won't be able to handle as many simultaneous clients. Is it worth it? Almost certainly! Besides, if you have heavy traffic, you can compensate with caching.

(It would be neat to see if someone could integrate russian-doll caching with server-rendered React. It doesn't seem like it would be too hard.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment