I am doing som experimentation with spring-boot and i realized that when i use embedded Tomcat server the resulting WAR size is smaller than when i use Jetty or even Undertow servers with same rest dependencies.
How is this possible? ... it is supposed that Undertow and Jetty should be ultralight compared with tomcat.
Sizes are:
Tomcat ~18Mb
Undertow ~21Mb
Jetty ~24Mb
Any of them looks too big for me since this is dummy REST endpoint. These are my dependencies:
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
<exclusions>
<exclusion>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-tomcat</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-jersey</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
</dependency>
<!-- <dependency> -->
<!-- <groupId>org.springframework.boot</groupId> -->
<!-- <artifactId>spring-boot-starter-tomcat</artifactId> -->
<!-- </dependency> -->
<!-- <dependency> -->
<!-- <groupId>org.springframework.boot</groupId> -->
<!-- <artifactId>spring-boot-starter-undertow</artifactId> -->
<!-- </dependency> -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-jetty</artifactId>
</dependency>
<!-- <dependency> -->
<!-- <groupId>org.springframework.boot</groupId> -->
<!-- <artifactId>spring-boot-starter-test</artifactId> -->
<!-- <scope>test</scope> -->
<!-- </dependency> -->
</dependencies>
Spring Boot includes three sample applications, spring-boot-sample-jetty
, spring-boot-sample-tomcat
, and spring-boot-sample-undertow
, with minimal, and pretty much identical, functionality. With Spring Boot 1.2.2.RELEASE, the archives sizes are:
spring-boot-sample-jetty
- 12MBspring-boot-sample-tomcat
- 9.8MBspring-boot-sample-undertow
- 9.6MBAs you can see Tomcat and Undertow are pretty much the same and the Jetty artifact is ~20% larger.
One notable reason for the size difference is JSP support. Undertow doesn't support JSPs and Spring Boot doesn't include Tomcat's JSP support by default. ~1.7MB of the Jetty-based archive is taken up by the Eclipse Java compiler that's used for JSP compilation. If you want to use Jetty and aren't using JSPs, you could exclude the org.eclipse.jetty:jetty-jsp
dependency. This reduces the Jetty-based artifact's size to 8.8MB.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With