Closed thaingo closed 8 years ago
So the first page load is usually a bit slow because the renderer has to load up the JavaScript (React, and anything else you're using), and it's just not as fast as Node. You'll probably find that the first few page loads will all be slow, because each Java thread has it's own renderer (React is not thread-safe in Java), but IIRC once every thread is initialised then performance gets better.
Bear in mind that a typical user only sees this the very first time they load a page, after that the UI will run in their browser and all calls to the server are API requests.
I suspect performance could be improved by using Webpack 2 and tree-shaking, in order to reduce the bundle size. I haven't tried that yet.
Also, I haven't examined performance over time - it's possible that rendering performance will increase over time. See http://pieroxy.net/blog/2015/06/29/node_js_vs_java_nashorn.html
Appreciate for your thoughtful reply. Have you tried this approach in production somewhere?
IMHO, this kind of approach to universal app can be viable. This is the first time I try the approach, I am worried about performance though.
What really makes me worried is we are doing universal rendering with XMLHttpRequest. We do not pass an initial props (or states) to React the first time we render a page but let it make a http request. Not sure if there is a big improvement for Nashorn in near future.
Totally agree with you on web resources optimization in general. I will look into Webpack 2 and tree-shaking in the next couple of weeks.
Thanks.
I've updated the webpack config to properly define NODE_ENV
and to use UglifyJS, and that's radically cut the bundle size. The first page load should be much quicker now, though I haven't timed it to confirm either way.
Every time I open the home page (localhost:8080) or refresh comment list, it takes me about 6s - 7s for the page to get fully loaded. Below is my configuration and environment info:
My Macbook Pro configuration: Processor: 2.4 GHz Intel Core i7 Memory: 8 GB 1600 MHz DDR3
Java: java version "1.8.0_92" Java(TM) SE Runtime Environment (build 1.8.0_92-b14) Java HotSpot(TM) 64-Bit Server VM (build 25.92-b14, mixed mode)
Browser: Chrome is of latest version (51.0.2704.103)
Did you experience such issue?
I'm so worried about the performance because we just have several comments and simple functionality so far. What do you think?