Share
Embed
A comparative review of microservice frameworks
In this session we will compare some of the most popular Microservice frameworks in the Java ecosystem like SpringBoot, Quarkus, Eclipse MicroProfile, and more. We will give an overview and jumpstart for each framework. Next to this we will answer questions like:
Which features do provide all of them, what are their unique selling points?
How do I start writing microservices with the different frameworks?
Which technology stack do the different frameworks use?
How do they perform in regards to startup time, and responding with different response sizes?
How large are the resulting application containers in Docker?
Hendrik Ebbers
October 20, 2020
Transcript
55 slides
-
This is a very very very long gag @hendrikEbbers Hendrik
• Karakun Co-Founder • Founder of JUG Dortmund • JSR EG member • JavaOne Rockstar, Java Champion • AdoptOpenJDK TSC member -
This is a very very very long gag @kthoms Karsten
• Open Source Enthusiast • Committer on several Eclipse projects • Contributor on many more • Speaker -
This is a very very very long gag @hendrikEbbers @kthoms
Content • About Microservices • Spring Boot, Quarkus, Micronaut, Eclipse Microprofile • Additional Frameworks • Docker support • Conclusion -
This is a very very very long gag @hendrikEbbers @kthoms
Microservices REST SQL Microservice -
This is a very very very long gag • Microservice
architecture does not depend on Java • You can create Microservice in any language you want • We concentrate on Java today @hendrikEbbers @kthoms Microservices Ok, maybe not in COBOL -
This is a very very very long gag • Microservice
architecture does not depend on Java • You can create Microservice in any language you want • We concentrate on Java today @hendrikEbbers @kthoms Microservices Ok, maybe not in COBOL Lesson 1 : do not underestimate the power of the Internet -
This is a very very very long gag @hendrikEbbers @kthoms
Microservices • Easy to learn and start with • Stable API • Active community • Active maintainers • LTS versions -
This is a very very very long gag @hendrikEbbers @kthoms
Microservices • Small memory footprint • Deployable as container • Fast to serve request • Start-up time • Stateless & scaleable -
This is a very very very long gag @hendrikEbbers @kthoms
Microservices • REST endpoints • Messaging & events • Provide & store data • Call Functions (e.g. map-reduce) • Security (SSO) • JSON support -
"Standard based framework backed by multiple vendors with much more
flexibility than Jakarta EE" -
This is a very very very long gag @hendrikEbbers @kthoms
Initializer • Project Coordinates • Framework Version • Java Version • Build System • Extensions -
This is a very very very long gag @hendrikEbbers @kthoms
Releases - Spring Boot 2018 2019 2020 2.3.X Preview Releases Releases 2.2.X 2.4.X 2.1.X 2.0.X 1.5.X -
This is a very very very long gag @hendrikEbbers @kthoms
Releases - Eclipse MicroProfile 2018 2019 2020 1.4 Preview Releases Releases 2.0 2.1 2.2 3.0 3.1 3.2 3.3 4.0 Switch to JavaEE 8 Switch to Jakarta EE 8 -
This is a very very very long gag @hendrikEbbers @kthoms
Releases - Micronaut 2018 2019 2020 1.0.x 1.1.x 1.2.x 1.3.x 2.0.x Preview Releases Releases -
This is a very very very long gag @hendrikEbbers @kthoms
Releases - Quarkus 2018 2019 2020 Preview Releases Releases 1.0 0.1 - 0.28 1.1 1.2 1.3 1.4 1.5 1.6 1.7 1.8 -
This is a very very very long gag public class
MovieResource { public Movie getMovie( Long id) { //... } } @hendrikEbbers @kthoms REST Endpoint Produce JSON by default -
This is a very very very long gag public class
MovieResource { public Movie getMovie( Long id) { //... } } @hendrikEbbers @kthoms REST Endpoint @Path("/movies") @Produces(MediaType.APPLICATION_JSON) @GET @Path("/{id}") @PathParam("id") JAX-RS (quarkus & Microprofile) Karsten -
This is a very very very long gag public class
MovieResource { public Movie getMovie( Long id) { //... } } @hendrikEbbers @kthoms REST Endpoint @RestController @GetMapping("/movies") @RequestParam("id") Spring -
This is a very very very long gag public class
MovieResource { public } } @Controller("/movies") @Get("/{id}") Single<HttpResponse<Movie>> getMovie ( @PathVariable Long id) { //... @hendrikEbbers @kthoms REST Endpoint Micronaut RxJava 2 -
This is a very very very long gag @hendrikEbbers @kthoms
DB Access @ApplicationScoped public class MovieRepository implements PanacheRepository<MovieEntity> { public MovieEntity findByName(String name) { return find("name", name).firstResult(); } } Quarkus Repository Pattern -
This is a very very very long gag @hendrikEbbers @kthoms
DB Access @Repository public interface MovieRepository extends CrudRepository<MovieEntity, Long> { Optional<MovieEntity> findOptionalByName(String name); } Spring -
This is a very very very long gag @hendrikEbbers @kthoms
DB Access @JdbcRepository(dialect = Dialect.H2) public interface MovieRepository extends CrudRepository<MovieEntity, Long> { Optional<MovieEntity> findByName(String name); } Micronaut -
This is a very very very long gag @hendrikEbbers @kthoms
DB Access @ApplicationScoped public class MovieRepository { @Inject EntityManager manager; public Optional<MovieEntity> findByName(String name) { return manager.createNamedQuery("MovieEntity.byName", MovieEntity.class) .setParameter("name", name) .getResultList() .findAny(); } } Microprofile -
This is a very very very long gag @hendrikEbbers @kthoms
Additional Frameworks • Vert.x • Dropwizard • Spark • Helidon • Apache CXF • Jersey • RESTEasy • ... There is no concrete definition what a microservice must contain... It do not even need to contain HTTP - Think about an event based system -
This is a very very very long gag @hendrikEbbers @kthoms
Docker Container FROM adoptopenjdk/openjdk11:jdk-11.0.8_10-ubuntu-slim COPY target/demo-*.jar demo.jar EXPOSE 8080 CMD ["java","-jar", "demo.jar"] Linux JVM Application Ubuntu + JVM as Base Our application Run ! -
This is a very very very long gag @hendrikEbbers @kthoms
Docker Container $ docker build . -t my-image $ docker run -p 8080:8080 my-image Linux JVM Application Build the Image with the actual JAR Start the container -
This is a very very very long gag @hendrikEbbers @kthoms
Docker Container CREATED COMMAND SIZE 2 minutes ago /bin/sh -c #(nop) ENTRYPOINT ["java" "-jar"… 0B 2 minutes ago /bin/sh -c #(nop) COPY file:4e18e9cc0f417bc6… 16.5MB 11 minutes ago /bin/sh -c #(nop) WORKDIR /opt/app 0B 11 minutes ago /bin/sh -c #(nop) ARG JAR_FILE=target/demo-… 0B 4 days ago /bin/sh -c #(nop) CMD ["jshell"] 0B 4 days ago /bin/sh -c #(nop) ENV JAVA_HOME=/opt/java/o… 0B 4 days ago /bin/sh -c set -eux; ARCH="$(dpkg --prin… 254MB 4 days ago /bin/sh -c #(nop) COPY multi:18d710993714a6c… 16.7kB 4 days ago /bin/sh -c #(nop) ENV JAVA_VERSION=jdk-11.0… 0B 4 days ago /bin/sh -c apt-get update && apt-get ins… 35.7MB 4 days ago /bin/sh -c #(nop) ENV LANG=en_US.UTF-8 LANG… 0B 5 days ago /bin/sh -c #(nop) CMD ["/bin/bash"] 0B 5 days ago /bin/sh -c mkdir -p /run/systemd && echo 'do… 7B 5 days ago /bin/sh -c [ -z "$(apt-get indextargets)" ] 0B 5 days ago /bin/sh -c set -xe && echo '#!/bin/sh' > /… 745B 5 days ago /bin/sh -c #(nop) ADD file:84f8ddc4d76e1e867… 63.2MB -
This is a very very very long gag @hendrikEbbers @kthoms
Docker Container CREATED COMMAND SIZE 2 minutes ago /bin/sh -c #(nop) ENTRYPOINT ["java" "-jar"… 0B 2 minutes ago /bin/sh -c #(nop) COPY file:4e18e9cc0f417bc6… 16.5MB 11 minutes ago /bin/sh -c #(nop) WORKDIR /opt/app 0B 11 minutes ago /bin/sh -c #(nop) ARG JAR_FILE=target/demo-… 0B 4 days ago /bin/sh -c #(nop) CMD ["jshell"] 0B 4 days ago /bin/sh -c #(nop) ENV JAVA_HOME=/opt/java/o… 0B 4 days ago /bin/sh -c set -eux; ARCH="$(dpkg --prin… 254MB 4 days ago /bin/sh -c #(nop) COPY multi:18d710993714a6c… 16.7kB 4 days ago /bin/sh -c #(nop) ENV JAVA_VERSION=jdk-11.0… 0B 4 days ago /bin/sh -c apt-get update && apt-get ins… 35.7MB 4 days ago /bin/sh -c #(nop) ENV LANG=en_US.UTF-8 LANG… 0B 5 days ago /bin/sh -c #(nop) CMD ["/bin/bash"] 0B 5 days ago /bin/sh -c mkdir -p /run/systemd && echo 'do… 7B 5 days ago /bin/sh -c [ -z "$(apt-get indextargets)" ] 0B 5 days ago /bin/sh -c set -xe && echo '#!/bin/sh' > /… 745B 5 days ago /bin/sh -c #(nop) ADD file:84f8ddc4d76e1e867… 63.2MB -
This is a very very very long gag @hendrikEbbers @kthoms
Docker Container CREATED COMMAND SIZE 2 minutes ago Microservice & Framework 16.5MB 4 days ago JDK 11 254MB 4 days ago Some Linux updates & tools 35.7MB 5 days ago Linux basic layer 63.2MB -
This is a very very very long gag CREATED COMMAND
SIZE 2 minutes ago Microservice & Framework 16.5MB 4 days ago JDK 11 254MB 4 days ago Some Linux updates & tools 35.7MB 5 days ago Linux basic layer 63.2MB @hendrikEbbers @kthoms Docker Container -
This is a very very very long gag @hendrikEbbers @kthoms
Docker Container Application (13 MB) Linux (100 MB) JVM (250 MB) Application (16 MB) Application (10 MB) -
This is a very very very long gag @hendrikEbbers @kthoms
Docker Container - GraalVM • Micronaut and Quarkus offer GraalVM support OOTB • By using GraalVM the app can be compiled to a native executable • While the compilation takes much longer the outcome is much smaller -
This is a very very very long gag @hendrikEbbers @kthoms
Docker Container - GraalVM Linux (100 MB) Native application (30 MB) No JDK since we compiled the app 0.3 s 108 s Compile Start -
This is a very very very long gag @hendrikEbbers @kthoms
Docker Container - MicroProfile • Eclipse MicroProfile is special since it needs an application server • Application server is an additional layer between JVM and application • Application layer is much smaller App Server (230 MB) JDK (250 MB) Linux (100 MB) Application (10 KB) -
This is a very very very long gag @hendrikEbbers @kthoms
Docker Container $ docker run 16.2 s 8.6 s 3.8 s 2.3 s ( ) 2.0 s 1.9 s 0.3 s -
This is a very very very long gag @hendrikEbbers @kthoms
Docker Build Times $ docker build 108 s 35.7 s 15.4 s 10.3 s 8.5 s 8.0 s 6.3 s ( ) -
This is a very very very long gag @hendrikEbbers @kthoms
Docker Container - jlink • jlink enables to create JVMs tailored to a specific application • This allows to create much smaller images as base for applications Application (47 MB) jlink based JVM (55 MB) Alpine Linux (10 MB) -
This is a very very very long gag @hendrikEbbers @kthoms
Docker Container • You need to decide what is most important for you: • images size • image layer size • build time • start time • [memory footprint] -
This is a very very very long gag @hendrikEbbers @kthoms
Advanced Features • Tracing & monitoring • Configuration & cloud configuration • Service discovery • Support for serverless functions • Reactive APIs • Authentication strategies -
This is a very very very long gag @hendrikEbbers @kthoms
Comparison (1/3) SpringBoot MicroProfile Micronaut Quarkus License Apache 2 Apache 2 Apache 2 Apache 2 Owner Pivotal Eclipse Foundation Object Computing Red Hat Since 2013 2016 2018 2018 Release Cadence (Months) 1 4 1 1 Maintenance Releases Committers ++ + + . -
This is a very very very long gag @hendrikEbbers @kthoms
Comparison (2/3) SpringBoot MicroProfile Micronaut Quarkus REST API Spring-Web JAX-RS Own JAX-RS SQL API Pivotal Eclipse Foundation Object Computing Red Hat Dependency Injection Spring-Beans CDI Micronaut IoC + JSR 330 CDI 2.0* Security API Spring-Security Jakarta EE Security Micronaut Security + JSR 250 Open ID HTTP Infrastructure Tomcat various Netty Vert.x / Netty Java Version 8, 11 - 15 8, (11) 8 - 14 8, 11 - 14 -
This is a very very very long gag @hendrikEbbers @kthoms
Comparison (3/3) SpringBoot MicroProfile Micronaut Quarkus Container Support Graal VM Image Size Application Layer Size Startup Time Build Time + - . . . . . . + + JVM: . . - GraalVM: + + - + + + - - + + - - - - + . JVM: GraalVM: +