Starting spring boot app with Vaadin Flow 14.0.0.rc9 is very slow

Could it be that it will get better when going to Version 14.0.0.1? Is this version already officially released?

Yes, this version (14.0.1) is officially released.

Thank you, @Ronald!
I switched to Version 14.0.1 and tried the base starter project with Spring Boot from Vaadin.com as example (download and start as-it-is).
Spoiler: I don’t see any improvement in starting performance compared to 14.0.0.

First time spring-boot:run:

2019-08-21 11:54:54.832  INFO 4120 --- [  restartedMain]
 a.e.evaluation.spring.Application        : Started Application in 269.661 seconds (JVM running for 270.109)

OK, much too long, but includes also the whole “npm install” command for the frontend packages.

second time spring-boot:run:

----------------- Frontend compiled successfully. -----------------
...
Started Application in 12.904 seconds (JVM running for 13.354)

Yes, much faster than at the first time, even though the frontend compilation with webpack is there while I never changed anything, nor in Java code or the frontend.

But then, there is no way to get it faster.
It will take around 13 seconds every time I redo spring-boot:run.

It’s getting much worse when I want to start/debug the application as it is just using the IntelliJ’s “run” command (starting the Application main class…).
This seems to do the same if you look at the console, but every time takes around 32 seconds, and is slow the same every following run / stop and rerun command.
What now I see clearly: There is a really long time gap here between these two log entries in the console:

2019-08-21 13:57:20.377  INFO 11092 --- [  restartedMain]
 o.s.web.context.ContextLoader            : Root WebApplicationContext: initialization completed in 912 ms
2019-08-21 13:57:44.276  INFO 11092 --- [  restartedMain]
 c.v.f.server.startup.DevModeInitializer  : Starting dev-mode updaters in C:\development\workspace\local\Java\Vaadin14SpringBootBase folder.

So it seems that in this case it’s not the time that webpack needs for the frontend compilation, but something else is going on at this stage that takes about 24(!) seconds (and about 5 seconds in the case I use the spring-boot:run maven goal).

Well, setting vaadin.whitelisted-packages to the “root” package of the base starter (like mentioned earlier in this thread) really helps in avoiding this time gap - but you have to really reinitialize the whole project, delete all generated files including the npm packages etc. to let the application work properly afterwards.
Doing this, also starting the application the “normal” way the IDE does, in my case I come down to about 13.5 seconds, and sometimes to “just” about 9 seconds for spring-boot:run - which, unfortunately, for some unknown reason I can not use for debugging.

Of course, you can make development easier by switching on hot swap while changing Java code, but you know, hot swap in Spring is not possible on every change.
So it will quite often come to the moment you would have to wait at least 13 seconds (in my case, maybe having a slow PC) to restart the application after a change in the IDE!
That was much faster with Vaadin 13…

P.S.: Maybe we should change this thread’s title to “Starting spring boot app with Vaadin Flow 14 is very slow”

I can confirm all your observations. We have a real issues here in terms of developer productivity :frowning:

Funny fact:
Switching on the production profile in Maven results to a longer compilation time, but much faster starting time.

So, to me it seems, switching on this profile, at the moment is helping while developing in the IDE, as the application does not search for frontent changes every time it starts - something you never do when you just use the flow api!

That is a little bit weird, as you would expect to be slower in production, but it seems that to include eventual changes the developer makes for frontend costs that much more time…

Just some comparison example times for the Spring Boot Base Starter Application
(assuming NPM install has already been done before you switch profile, because that really takes time):

Maven profile Task Which time Time taken
normal mode spring-boot:run first time 44 seconds
normal mode spring-boot:run other times 11 seconds
normal mode starting for debug first time 13 seconds
normal mode starting for debug other times 12 seconds
production spring-boot:run first time 2 seconds
production spring-boot:run other times 2 seconds
production starting for debug first time 7 seconds
production starting for debug other times 6 seconds
production update/hotswap/restart while debugging other times 5 seconds

Anyway - in addition to the “tricks” already mentioned in this thread, I found out that there is a good possibility to generally make frontend installation/compilation much faster:
When you include the dependency “vaadin-core” instead of “vaadin”.
You have to use “vaadin” only when you would want to take use of all pro tools, too…

For me using the whitelist changes nothing.

I use the Eclipse spring boot run, and it takes several minutes to build the app. This was never before using vaadin 12 or 13.
I already changed the dependency vaadin to vaadin core.

This time-problem makes it impossible for me to develop something.

Which step takes so much time? Does the npm install run for each build? :frowning:

Hi,

i had the same Problem. But for me it took 600 seconds. I tried

mvn vaadin:build-frontend -X

in my project and the starting process was speeded up to 13 seconds.

Good Luck :slight_smile:

Seeing the same startup issue as well. Hesitant to go to Vaadin 14 in no compatibility mode until this gets resolved.

White listing views and components definitely made a big load performance difference.

Using Vaadin version 14.0.7 fixed it for me

Thank you for the information about Vaadin 14.0.7, @Ines!
Saw also significant performance improvements when upgrading 14.0.8 in one of our small internal applications.

But did anyone have the time to check what that means in detail?

That independent of the used Maven profile (normal/production) and independent of how you start it (with mvn spring-boot:run, with the IDE as spring application or debugging) it is always fast to compile and start up?

That it is not necessary now to go in compatibility mode?
That it is not necessary to do the whitelist thing?

Regards

Major startup performance when I upgraded to 14.0.8. I am still running in compatibility mode due to some of the addons used by the app has not transitioned to npm as of yet. Love the upgrade.

Allen Pham:
Major startup performance when I upgraded to 14.0.8. I am still running in compatibility mode due to some of the addons used by the app has not transitioned to npm as of yet. Love the upgrade.

unfortunately npm will double / triple your debug time you’ll see :frowning:

Umit,

In your opinion, why is it so?

I just started a simple new application spring boot 2.3.3, vaadin 14.3.4, java OpenJDK 14, IntelliJ 2020.1.1, nothing more then a hello world label.
I tried to use vaadin.whitelisted-packages configuration property in application.properties
but the problem is always the same: starting time is unacceptable, about 1 minute for webpack to compile frontend resources.

anything to do to solve this problem? maybe a IntelliJ issue? otherwise i have to look for a vaadin alternative.

Hi Giuseppe

In development mode all vaadin components are always compiled. I can understand that with a slow machine the compilation can be slow, but at the moment the only help we can offer is to drop the paid components by changing the dependency from vaadin to vaadin-core or to manually add dependencies for each Vaadin component that is needed in the project. (The minimum dependencies being flow-server and flow-client)

  • Mikael

Hi Mikael, thanks for your help.
My machine is a MacBook pro 16 inch with 32GB RAM and a processor 2,3 GHz Intel Core i9 8 core, i do not think it is a slow one.
I found that executing maven goal vaadin:prepare-frontend and vaadin:build-frontend application startup is very fast.
The only problem is that vaadin:build-frontend takes about 6 minutes and it is necessary to run again every time i use a new ui component in my application

Hi Giuseppe.

Yes that not what one would count as a slow machine and it should perform the work in a timely manner.

For development you do not need to execute build-frontend which will make the execution faster as build-frontend will
go through the used components and optimize the bundle also it will do it on every startup as it is intended for a production mode build, but in dev mode everything is added to the bundle making it more straightforward, also it uses the dev server which won’t be used after running build-frontend.

My windows 10 machine with a i7-8750H CPU @ 2.20GHz, 2201 Mhz, 6 Core(s), 12 Logical Processor(s)
package a production build from a clean repository in around 1 minute and after initial node_modules have downloaded it goes down to <20 seconds.
The dev mode build seems to be around 30s without node_modules which then goes down to <8 seconds to server start.

  • Mikael

Hi Mikael,

how to use only vaadin-core if you use the vaadin-spring-boot-starter maven dependency?

You can just change in the pom for a starter project the dependency

        <dependency>
            <groupId>com.vaadin</groupId>
            <artifactId>vaadin</artifactId>
        </dependency>

to be

        <dependency>
            <groupId>com.vaadin</groupId>
            <artifactId>vaadin-core</artifactId>
        </dependency>
  • Mikael

Mikael,

but I have the following in my pom.xml:

<properties>
	<java.version>1.8</java.version>
	<vaadin.version>14.3.6</vaadin.version>
</properties>
...
<dependency>
	<groupId>com.vaadin</groupId>
	<artifactId>vaadin-spring-boot-starter</artifactId>
</dependency>
...
<dependencyManagement>
	<dependencies>
		<dependency>
			<groupId>com.vaadin</groupId>
			<artifactId>vaadin-bom</artifactId>
			<version>${vaadin.version}</version>
			<type>pom</type>
			<scope>import</scope>
		</dependency>
	</dependencies>
</dependencyManagement>

Hi Marcus.

It would seem that the vaadin-spring-boot-starter only brings in the vaadin-core, vaadin-spring and spring-boot-starter-web dependencies so it’s already only with the core packages.

  • Mikael