-
-
Notifications
You must be signed in to change notification settings - Fork 630
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feature/node #380
Feature/node #380
Conversation
Thanks @alleycat-at-git. I put in some questions. Reviewed 10 of 10 files at r1. lib/generators/react_on_rails/templates/base/base/Procfile.dev.tt, line 5 [r1] (raw file): lib/generators/react_on_rails/templates/base/base/config/initializers/react_on_rails.rb.tt, line 45 [r1] (raw file): lib/generators/react_on_rails/templates/base/base/lib/tasks/load_test.rake, line 8 [r1] (raw file): lib/generators/react_on_rails/templates/base/server_rendering/client/node/server.js, line 2 [r1] (raw file): lib/generators/react_on_rails/templates/base/server_rendering/client/node/server.js, line 9 [r1] (raw file): lib/generators/react_on_rails/templates/base/server_rendering/client/node/server.js, line 19 [r1] (raw file): lib/generators/react_on_rails/templates/base/server_rendering/client/node/server.js, line 27 [r1] (raw file): Are we parsing the entire server-bundle.js every time? lib/react_on_rails/server_rendering_pool.rb, line 21 [r1] (raw file): I think an if statement is probably fine. Even if we want ultimate customization, we can have an else condition. lib/react_on_rails/server_rendering_pool/exec.rb, line 3 [r1] (raw file): lib/react_on_rails/server_rendering_pool/exec.rb, line 148 [r1] (raw file): lib/react_on_rails/server_rendering_pool/node.rb, line 9 [r1] (raw file): lib/react_on_rails/server_rendering_pool/node.rb, line 10 [r1] (raw file): lib/react_on_rails/server_rendering_pool/node.rb, line 25 [r1] (raw file): lib/react_on_rails/server_rendering_pool/node.rb, line 37 [r1] (raw file): lib/react_on_rails/server_rendering_pool/node.rb, line 52 [r1] (raw file): lib/react_on_rails/server_rendering_pool/node.rb, line 69 [r1] (raw file): How many node instances should the node server be running? Does this require buying extra instances from Heroku? lib/react_on_rails/server_rendering_pool/node.rb, line 87 [r1] (raw file): Comments from Reviewable |
lib/generators/react_on_rails/templates/base/base/Procfile.dev.tt, line 5 [r1] (raw file): Comments from Reviewable |
lib/generators/react_on_rails/templates/base/base/lib/tasks/load_test.rake, line 8 [r1] (raw file): Comments from Reviewable |
lib/generators/react_on_rails/templates/base/server_rendering/client/node/server.js, line 2 [r1] (raw file): Comments from Reviewable |
lib/generators/react_on_rails/templates/base/server_rendering/client/node/server.js, line 19 [r1] (raw file): Comments from Reviewable |
Review status: all files reviewed at latest revision, 17 unresolved discussions, some commit checks failed. lib/generators/react_on_rails/templates/base/base/lib/tasks/load_test.rake, line 8 [r1] (raw file): Comments from Reviewable |
lib/react_on_rails/server_rendering_pool/exec.rb, line 3 [r1] (raw file): Comments from Reviewable |
lib/react_on_rails/configuration.rb, line 60 [r1] (raw file): Comments from Reviewable |
lib/react_on_rails/server_rendering_pool/node.rb, line 25 [r1] (raw file): Comments from Reviewable |
lib/react_on_rails/server_rendering_pool/node.rb, line 69 [r1] (raw file): Comments from Reviewable |
lib/generators/react_on_rails/templates/base/base/lib/tasks/load_test.rake, line 8 [r1] (raw file): Comments from Reviewable |
@alleycat-at-git So this is a interesting PR, but at a high level do we really want this in the core of the gem? Just curious what your reasoning is. Comments from Reviewable |
Review status: all files reviewed at latest revision, 18 unresolved discussions, some commit checks failed. lib/generators/react_on_rails/templates/base/base/Procfile.dev.tt, line 5 [r1] (raw file): The other thing is that node uses event-based async model, which is hugely more effective than rails default sync calls. So, for instance, if the JS will communicate with a 3rd party web-service, the effectiveness of one node process will be a magnitude higher than that of the rails process. As for heroku, AFAIK, you really have to spend the same money for rails and node process. lib/generators/react_on_rails/templates/base/base/lib/tasks/load_test.rake, line 8 [r1] (raw file): lib/generators/react_on_rails/templates/base/server_rendering/client/node/server.js, line 2 [r1] (raw file): lib/generators/react_on_rails/templates/base/server_rendering/client/node/server.js, line 9 [r1] (raw file): lib/generators/react_on_rails/templates/base/server_rendering/client/node/server.js, line 19 [r1] (raw file): lib/generators/react_on_rails/templates/base/server_rendering/client/node/server.js, line 27 [r1] (raw file):
lib/react_on_rails/configuration.rb, line 60 [r1] (raw file): lib/react_on_rails/server_rendering_pool.rb, line 21 [r1] (raw file): lib/react_on_rails/server_rendering_pool/exec.rb, line 3 [r1] (raw file): lib/react_on_rails/server_rendering_pool/node.rb, line 9 [r1] (raw file): lib/react_on_rails/server_rendering_pool/node.rb, line 10 [r1] (raw file): lib/react_on_rails/server_rendering_pool/node.rb, line 25 [r1] (raw file):
lib/react_on_rails/server_rendering_pool/node.rb, line 37 [r1] (raw file): lib/react_on_rails/server_rendering_pool/node.rb, line 69 [r1] (raw file):
For Heroku see my comment above lib/react_on_rails/server_rendering_pool/node.rb, line 87 [r1] (raw file): Comments from Reviewable |
lib/generators/react_on_rails/templates/base/server_rendering/client/node/server.js, line 19 [r1] (raw file): Comments from Reviewable |
Review status: 3 of 10 files reviewed at latest revision, 18 unresolved discussions. lib/react_on_rails/server_rendering_pool/exec.rb, line 3 [r1] (raw file): lib/react_on_rails/server_rendering_pool/exec.rb, line 148 [r1] (raw file): lib/react_on_rails/server_rendering_pool/node.rb, line 87 [r1] (raw file): Comments from Reviewable |
My guess why "only 5% performance improvement": node shines not in the synchronous code evaluation, but in asynchronous requests handling, so it can efficiently deal w/ multiple incoming requests at a time. But since those incoming requests are still handled by ruby server, node does only js execution job. The huge advantage of this PR is that now we have event loop and all others modern JS features, which is a BIG deal. Review status: 3 of 10 files reviewed at latest revision, 19 unresolved discussions, some commit checks failed. lib/generators/react_on_rails/templates/base/server_rendering/client/node/server.js, line 20 [r2] (raw file): Comments from Reviewable |
lib/generators/react_on_rails/templates/base/base/Procfile.dev.tt, line 5 [r1] (raw file): Comments from Reviewable |
lib/react_on_rails/configuration.rb, line 60 [r1] (raw file): Comments from Reviewable |
@alexfedoseev Thanks for clearing that up. So this would enable something like an alliterative for rails web sockets for a chat bundle? Also will this work perfectly fine in production? I was still a little confused on that. I thought the app built all the js out to a single file for production, so does that mean node can basically take a completed webpack file and run it on a server? Comments from Reviewable |
This looks pretty good. Once we have the test suite for capybara configured to do a run with this, we can probably release this as either "working" or "experimental". @alexfedoseev thoughts? Reviewed 7 of 7 files at r2. lib/generators/react_on_rails/templates/base/server_rendering/client/node/server.js, line 23 [r1] (raw file): lib/react_on_rails/server_rendering_pool.rb, line 21 [r1] (raw file): lib/react_on_rails/server_rendering_pool/node.rb, line 9 [r1] (raw file): lib/react_on_rails/server_rendering_pool/node.rb, line 37 [r1] (raw file): lib/react_on_rails/server_rendering_pool/node.rb, line 4 [r2] (raw file): Comments from Reviewable |
Review status: 8 of 10 files reviewed at latest revision, 10 unresolved discussions. lib/generators/react_on_rails/templates/base/server_rendering/client/node/server.js, line 23 [r1] (raw file): lib/generators/react_on_rails/templates/base/server_rendering/client/node/server.js, line 20 [r2] (raw file): lib/react_on_rails/server_rendering_pool.rb, line 21 [r1] (raw file): lib/react_on_rails/server_rendering_pool/node.rb, line 9 [r1] (raw file): lib/react_on_rails/server_rendering_pool/node.rb, line 37 [r1] (raw file): lib/react_on_rails/server_rendering_pool/node.rb, line 52 [r1] (raw file): lib/react_on_rails/server_rendering_pool/node.rb, line 4 [r2] (raw file): Comments from Reviewable |
Let's try to get this in by next Monday. We want to:
|
@alleycat-at-git Are we ready to merge this? Maybe squash the commits to one and rebase on top of master and I'll merge. The key is that this doesn't go on by default and that it's labelled as experimental. |
41f6564
to
95391af
Compare
@justin808 Ready to merge! Review status: 6 of 15 files reviewed at latest revision, 8 unresolved discussions. Comments from Reviewable |
@justin808 is this good to go? |
🔥 @alleycat-at-git Please add a changelog entry and then I'll merge! @jbhatab, @robwise from now on, all PRs (except for doc) need a changelog entry in the unreleased section: https://github.com/shakacode/react_on_rails/blob/master/CHANGELOG.md#unreleased Reviewed 2 of 3 files at r4, 5 of 6 files at r5, 1 of 1 files at r6, 1 of 1 files at r8. lib/react_on_rails/server_rendering_pool/node.rb, line 52 [r1] (raw file): Comments from Reviewable |
1582353
to
9951de4
Compare
@justin808 Done! Regarding tests, we need to run the whole test suite against both rendering options in the CI. It might be premature in the experimental stage, but needs to be implemented when we have full-blown feature. Right now the feature pass all the test and must be fully covered, so no problems with that. Review status: 15 of 16 files reviewed at latest revision, 4 unresolved discussions. Comments from Reviewable |
Reviewed 1 of 1 files at r9. Comments from Reviewable |
@alleycat-at-git Please rebase on top of master, and I'll merge. Review status: all files reviewed at latest revision, 2 unresolved discussions, some commit checks failed. Comments from Reviewable |
@justin808 Done! Review status: all files reviewed at latest revision, 2 unresolved discussions. Comments from Reviewable |
Review status: all files reviewed at latest revision, 2 unresolved discussions, some commit checks failed. Comments from Reviewable |
NodeJS as a backend for server-side rendering.
To switch from NodeJS to ExecJS and vice-versa
config/initializers/react_on_rails.rb
in your projectserver_render_method
param to eitherNodeJS
orExecJS
To make a simple load test, after starting the server use
rake load_test:run
in your project folder.Args:
url
- url to be tested, default -http://localhost:3000/hello_world
count
- number of requests, default - 500Before running load test, make sure that Apache Benchmark is installed on your system (installed on OSX by default)
This change is