Upload
others
View
0
Download
0
Embed Size (px)
Citation preview
I’m an Open Source enthusiast since I got in touch with Linux back in 1994 while trying to study Mathematics in Göttingen and got tired to go to the institute or data center to compile C programs for Unix.
In 1999 I got infected by the Java virus and worked as a Java Developer at a startup company which went IPO.
While looking for another application-server I stumbled upon JBoss in 2001 and decided to write my Diploma Thesis on Computer Science at the University of Applied Science in Dortmund with and about JBoss in 2004.
I joined a Telecommunications Company in Düsseldorf by then, where I worked in various positions as Software Developer, Tester, Integration Lead, Project Manager and Operation Specialist.
In 2012 I got hired by Red Hat as a Consultant and continued my Middleware journey with JBoss and other products, but got tempted in 2015 by the dark side (they have cookies) and changed into a Pre-Sales role.
Challenges for Java(now and future)
CONTAINER JAVA // @ro14nd // k8spatterns.io
1996
CONTAINER JAVA // @ro14nd // k8spatterns.io
1999
CONTAINER JAVA // @ro14nd // k8spatterns.io
2009
CONTAINER JAVA // @ro14nd // k8spatterns.io
2019
https://www.tiobe.com/tiobe-index/
VM
CONTAINER
LIBSAPP
CONTAINER
LIBSAPP
HOST OS
SERVER
HYPERVISOR
GUEST OSLIBSAPP
VM
GUEST OS
LIBSAPP
PHYSICAL SERVER
27 HRS
CONTAINER INSTANCE
10 SECS
VIRTUAL MACHINE
12 MINS
HOST OS
SERVER
10 perServer 100 per
Server
● 1 monolith ≈ 20 microservices ≈ 200 functions● Scale to 1 vs scale to 0● Start up time
MONOLITH
MICROSERVICE
MICROSERVICE
MICROSERVICE
MICROSERVICE
MICROSERVICE
MICROSERVICE
MICROSERVICE
MICROSERVICE
MICROSERVICE
MICROSERVICE
MICROSERVICE
MICROSERVICE
MICROSERVICE
MICROSERVICE
MICROSERVICE
MICROSERVICE
MICROSERVICE
MICROSERVICE
MICROSERVICE
MICROSERVICE
F FFFFFFFFF
F FFFFFFFFF
F FFFFFFFFF
F FFFFFFFFF
F FFFFFFFFF
F FFFFFFFFF
F FFFFFFFFF
F FFFFFFFFF
F FFFFFFFFF
F FFFFFFFFF
F FFFFFFFFF
F FFFFFFFFF
F FFFFFFFFF
F FFFFFFFFF
F FFFFFFFFF
F FFFFFFFFF
F FFFFFFFFF
F FFFFFFFFF
6.1% Java
62.9% Node.js
20.8% Python
6.4% Go
6.1% Java
3.8% C#
https://serverless.com/blog/2018-serverless-community-survey-huge-growth-usage/
Agility, Scalability, Faster Business Reactivity
Container platform
App 1
Data
App 2
Data
App 3
Data
App 4 App 5
Data
Container platform
Node
NodeJS
NodeJS
NodeJS
NodeJS
NodeJS
NodeJS
NodeJS
Node
Go Go
Go Go
Go Go
Go Go
Go Go
Go Go
Go Go
Node
HotSpot Heap
HotSpot Heap
HotSpot Heap
HotSpot Heap
● Startup overhead ○ # of classes, bytecode, JIT
● Memory overhead○ # of classes, metadata, compilation
● Multi tenancy
RSS
Heap Metaspace off-heap
What is Quarkus?
Cloud Native, Microservices, Serverless
https://github.com/quarkusio/quarkus
How does it work?
Compile Provision(curate)
Wiring & Assemble(augment) AOT Native
Compilation
Hotspot Runnable & Image
Native Executable & Image
app.jar frameworks
Runnable java app
Native-app(GraalVM)
Steps
● Metadata processing, such as reading annotations, XML descriptors etc. ○ Output is recorded bytecode which is responsible for directly instantiating the relevant runtime services.○ Processed once at build time, which reduces startup time and memory consumption
● Enforce opinionated and sensible defaults based on the close world view of the application (don’t run unused services)● Dead code elimination● Send metadata to GraalVM for example classes in need of reflection
Concepts
● Favor build time work over runtime work● Unified configuration into a single file, application.properties
Java HotSpot VM
JVM CI Substrate VM
Graal Compiler
Truffle
Sulong (LLVM)
https://github.com/oracle/graal
What are the advantages?
REST + CRUDQuarkus + GraalVM 0.055 Seconds
Quarkus + OpenJDK 2.5 Seconds
Traditional Cloud-Native Stack 9.5 Seconds
REST + CRUD
Quarkus + GraalVM35 MB
Quarkus + OpenJDK130 MB
Traditional Cloud-Native Stack218 MB
A cohesive platform for optimized developer joy:
● Based on standards, but not limited● Unified configuration● Zero config, live reload in the blink of an eye● Streamlined code for the 80% common usages, flexible for the
20%● No hassle native executable generation
Eclipse Vert.x Hibernate RESTEasy Apache Camel Eclipse MicroProfile Netty
Kubernetes OpenShift Jaeger Prometheus Apache Kafka Infinispan
● Combine both Reactive and imperative development in the same application● Inject the EventBus or the Vertx context● Use the technology that fits your use-case
@InjectSayService say;
@GET@Produces(MediaType.TEXT_PLAIN)public String hello() {
return say.hello();}
@Inject @Stream(”kafka”)Publisher<String> reactiveSay;
@GET@Produces(MediaType.SERVER_SENT_EVENTS)public Publisher<String> stream() {
return reactiveSay;}
● Similar to ActiveRecord in Ruby on Rails● Works with Transactions (@Transactional)● Extendable
@Entitypublic class Todo extends PanacheEntity { @Column(unique=true) @NotBlank public String title; public String url; public boolean completed; @Column(name=”ordering”) public int order;}
@Produces("application/json")@Consumes("application/json")public class TodoResource { @GET Public List<Todo> getAll() { return Todo.listAll(Sort.by("order")); }}
@QuarkusTestpublic class GreetingResourceTest {
@Test public void testHelloEndpoint() { given() .when().get("/hello") .then() .statusCode(200) .body(is("hello")); }
@Test public void testGreetingEndpoint() { String uuid = UUID.randomUUID().toString(); given() .pathParam("name", uuid) .when().get("/hello/greeting/{name}") .then() .statusCode(200) .body(is("hello " + uuid)); }
}
Where does it fit?
● Greenfield applications● Microservice-Architectures● Serverless applications● Brownfield applications, depends on effort for migration
How to create applications
For Quarkus (current version 0.15) the following components should be installed
● IDE (f.e. CodeReady Studio)● Open JDK 8 (Download for Windows)● Apache Maven 3.5.3+ (Download) (works with Gradle, too)● GraalVM 0.16 (Download Community Edition)
Also an environment variable GRAALVM_HOME needs to be set and pointing to the GraalVM installation. For ease of use this should also be done for JAVA_HOME and MAVEN_HOME.
export JAVA_HOME=/usr/lib/jvm/java-1.8.0-openjdkexport MAVEN_HOME=/home/jcordes/Software/Maven/apache-maven-3.5.4export GRAALVM_HOME=/usr/lib/jvm/graalvm
mvn io.quarkus:quarkus-maven-plugin:0.15.0:create \ -DprojectGroupId=de.camelcasecon \ -DprojectArtifactId=getting-started \ -DclassName="de.camelcasecon.quickstart.GreetingResource" \ -Dpath="/hello"
mvn compile quarkus:dev
curl -v "http://localhost:8080/hello"
● Live-Reloading: Just change the code● List and add extensions:
mvn quarkus:list-extensionsmvn quarkus:add-extension -Dextensions="groupId:artifactId"
● Compile to native code: ./mvnw package -Pnative
How to port applications
● Register for reflection via Quarkus Processor @buildstep method (ReflectiveClassBuildItem)or @RegisterForReflection annotation on class level
● Include resources via @buildstep method (SubstrateResourceBuildItem)● Delay class initialization via @buildstep method (RuntimeInitializedClassBuildItem)● Manage Proxy Classes via @buildstep method (SubstrateProxyDefinitionBuildItem)● ...
https://quarkus.io/guides/writing-native-applications-tipshttps://developers.redhat.com/blog/2019/04/12/migrating-java-applications-to-quarkus-lessons-learned/
● Change Maven dependencies (use quarkus.io/quarkus-bom/${quarkus-version})● CDI: Replace javaee-api with quarkus-arc● EJB Timer: Replace with quarkus-scheduler● JAX-RS: Replace resteasy with quarkus-resteasy● JPA: Move persistence.xml info to application.properties, use quarkus-hibernate-orm● ...
● Augmentation step of Quarkus generates classes for various purposes, these can be viewed with
./mvnw clean install -Dquarkus.debug.generated-classes-dir=./target/app-generated-classes
CONTEXTS AND DEPENDENCY INJECTION Support Status
@ConversationScoped not supported
Decorators not supported
Portable Extensions not supported
BeanManager - only the following methods are implemented: getBeans(), createCreationalContext(), getReference(), resolve(), getContext(), getEvent() and createInstance()
partially supported
Specialization not supported
beans.xml descriptor content is ignored not supported
Passivation and passivating scopes not supported
Transitive interceptor bindings and interceptor methods on superclasses are not implemented yet
not supported
What Support Status
Dynamic Class Loading / Unloading Not supported
Reflection Mostly supported
Dynamic Proxy Mostly supported
Java Native Interface (JNI) Mostly supported
Unsafe Memory Access Mostly supported
Static Initializers Partially supported
InvokeDynamic Bytecode and Method Handles
Not supported
What Support Status
Synchronized, wait, and notify Supported
Finalizers Not supported
References Mostly supported
Threads Supported
Identity Hash Code Supported
Security Manager Not supported
JVMTI, JMX, other native VM interfaces Not supported
JCA Security Services Supported
The future
● GraalVM 0.19 support, this will also allow for native applications on Windows● Supporting more frameworks
Resources
● Quarkus Website● Quarkus Guides● Quarkus on Github● Quarkus Quickstarts● Quarkus: Supersonic, subatomic Java | DevNation Live
https://learn.openshift.com/middleware/courses/middleware-quarkus/