30
A new way to build microservices Luram Archanjo

Luram Archanjo - Amazon Web Services · 2019-05-16 · Moving to Microservices Feature A Feature B Feature C Monolith Microservice Microservices Microservice. Scalability Feature

  • Upload
    others

  • View
    4

  • Download
    0

Embed Size (px)

Citation preview

Page 1: Luram Archanjo - Amazon Web Services · 2019-05-16 · Moving to Microservices Feature A Feature B Feature C Monolith Microservice Microservices Microservice. Scalability Feature

A new way to build microservices

Luram Archanjo

Page 2: Luram Archanjo - Amazon Web Services · 2019-05-16 · Moving to Microservices Feature A Feature B Feature C Monolith Microservice Microservices Microservice. Scalability Feature

Who am I?

● Software Engineer at Sensedia

● MBA in java projects

● Java and microservice enthusiastic

Page 3: Luram Archanjo - Amazon Web Services · 2019-05-16 · Moving to Microservices Feature A Feature B Feature C Monolith Microservice Microservices Microservice. Scalability Feature

Agenda

● Microservices

● Java & Frameworks

● Ahead of Time (AOT) Compilation

● GraalVM

● Micronaut

● Questions

Page 4: Luram Archanjo - Amazon Web Services · 2019-05-16 · Moving to Microservices Feature A Feature B Feature C Monolith Microservice Microservices Microservice. Scalability Feature

Moving to Microservices

Feature A

Feature B

Feature C

Monolith

Microservice Microservice

Microservices

Microservice

Page 5: Luram Archanjo - Amazon Web Services · 2019-05-16 · Moving to Microservices Feature A Feature B Feature C Monolith Microservice Microservices Microservice. Scalability Feature

Scalability

Feature A

Monolith Scalability

Microservice Microservice

Microservices Scalability

Microservice

Microservice

Microservice

Microservice

Microservice

Microservice

Microservice

Microservice

Feature B Feature C

Feature A Feature B Feature C

Feature A Feature B Feature C

Page 6: Luram Archanjo - Amazon Web Services · 2019-05-16 · Moving to Microservices Feature A Feature B Feature C Monolith Microservice Microservices Microservice. Scalability Feature

Our resources are finite!

Page 7: Luram Archanjo - Amazon Web Services · 2019-05-16 · Moving to Microservices Feature A Feature B Feature C Monolith Microservice Microservices Microservice. Scalability Feature

How to use less resources using Java language?

Page 8: Luram Archanjo - Amazon Web Services · 2019-05-16 · Moving to Microservices Feature A Feature B Feature C Monolith Microservice Microservices Microservice. Scalability Feature

Our frameworks are design to low memory footprint?

Page 9: Luram Archanjo - Amazon Web Services · 2019-05-16 · Moving to Microservices Feature A Feature B Feature C Monolith Microservice Microservices Microservice. Scalability Feature

No, because we’ve tried to adapt existing legacy

technologies for Microservices

Page 10: Luram Archanjo - Amazon Web Services · 2019-05-16 · Moving to Microservices Feature A Feature B Feature C Monolith Microservice Microservices Microservice. Scalability Feature

What do Spring and Jakarta EE undertaking? What are the results about it?

Spring is an amazing technical achievement and does so many things, but does them at Runtime.

● Reads the byte code of every bean it finds.● Synthesizes new annotations for each annotation on each bean method, constructor, field etc.

to support Annotation metadata.● Builds Reflective Metadata for each bean for every method, constructor, field etc.

Page 11: Luram Archanjo - Amazon Web Services · 2019-05-16 · Moving to Microservices Feature A Feature B Feature C Monolith Microservice Microservices Microservice. Scalability Feature

The rise of Java Microframeworks

Page 12: Luram Archanjo - Amazon Web Services · 2019-05-16 · Moving to Microservices Feature A Feature B Feature C Monolith Microservice Microservices Microservice. Scalability Feature

Microframeworks

A microframework is a term used to refer to minimalistic web application frameworks:

● Without authentication and authorization● Without database abstraction via an object-relational mapping.● Without input validation and input sanitation.

Page 13: Luram Archanjo - Amazon Web Services · 2019-05-16 · Moving to Microservices Feature A Feature B Feature C Monolith Microservice Microservices Microservice. Scalability Feature

Less modules, functions and dependencies are not

enough!

Page 14: Luram Archanjo - Amazon Web Services · 2019-05-16 · Moving to Microservices Feature A Feature B Feature C Monolith Microservice Microservices Microservice. Scalability Feature

Ahead of Time (AOT) Compilation

Ahead-of-time compilation (AOT compilation) is the act of compiling a higher-level programming language, or an intermediate representation such as Java bytecode, into a native machine code so that the resulting binary file can execute natively.

Web AndroidJava

Google Dagger 2

?

Page 15: Luram Archanjo - Amazon Web Services · 2019-05-16 · Moving to Microservices Feature A Feature B Feature C Monolith Microservice Microservices Microservice. Scalability Feature

uses Ahead of Time (AOT) Compilation

Page 16: Luram Archanjo - Amazon Web Services · 2019-05-16 · Moving to Microservices Feature A Feature B Feature C Monolith Microservice Microservices Microservice. Scalability Feature

What are the results of using Ahead of Time (AOT)

Compilation?

Page 17: Luram Archanjo - Amazon Web Services · 2019-05-16 · Moving to Microservices Feature A Feature B Feature C Monolith Microservice Microservices Microservice. Scalability Feature

The results of using Ahead of Time (AOT) Compilation

Data from Micronaut website:

● Startup time around a second.

● All Dependency Injection, AOP and Proxy generation happens at compile time.

● Can be run with as little as 10mb Max Heap.

Page 18: Luram Archanjo - Amazon Web Services · 2019-05-16 · Moving to Microservices Feature A Feature B Feature C Monolith Microservice Microservices Microservice. Scalability Feature

I don't believe, show me!

Page 19: Luram Archanjo - Amazon Web Services · 2019-05-16 · Moving to Microservices Feature A Feature B Feature C Monolith Microservice Microservices Microservice. Scalability Feature

Is it possible to improve more?

Page 20: Luram Archanjo - Amazon Web Services · 2019-05-16 · Moving to Microservices Feature A Feature B Feature C Monolith Microservice Microservices Microservice. Scalability Feature

Yes, with

Page 21: Luram Archanjo - Amazon Web Services · 2019-05-16 · Moving to Microservices Feature A Feature B Feature C Monolith Microservice Microservices Microservice. Scalability Feature

GraalVM

GraalVM is an universal virtual machine:

● Runs Java, Scala, Kotlin etc.

● Native image compiled with ahead-of-time improves the startup time and reduce the memory footprint of JVM-based applications.

GraalVM works well when:

● Little or no runtime reflection is used.○ Use third party libraries selectively.

● Limited or no dynamic classloading.

Page 22: Luram Archanjo - Amazon Web Services · 2019-05-16 · Moving to Microservices Feature A Feature B Feature C Monolith Microservice Microservices Microservice. Scalability Feature

Demo

+

Page 23: Luram Archanjo - Amazon Web Services · 2019-05-16 · Moving to Microservices Feature A Feature B Feature C Monolith Microservice Microservices Microservice. Scalability Feature

What else does Micronaut do?

Page 24: Luram Archanjo - Amazon Web Services · 2019-05-16 · Moving to Microservices Feature A Feature B Feature C Monolith Microservice Microservices Microservice. Scalability Feature

Blocking or Non-Blocking HTTP server built on Netty

With a smooth learning curve, Micronaut HTTP server makes it as easy as possible to expose APIs that can be consumed by HTTP clients.

Blocking@Controller("/hello")public class HelloController {

@Get public String hello() { return "Hello Micronaut"; }

}

Non-Blocking (RxJava + Netty)

@Controller("/hello")public class HelloController {

@Get public Single<String> hello() { return Single.just("Hello Micronaut"); }

}

Page 25: Luram Archanjo - Amazon Web Services · 2019-05-16 · Moving to Microservices Feature A Feature B Feature C Monolith Microservice Microservices Microservice. Scalability Feature

Dependency Injection and Inversion of Control (IoC)

This is a similar approach taken by Spring and Google Dagger, but without reflection and proxies. All the injections are done in compile time.

@Singletonpublic class HelloService {

public String hello() { return "Hello Micronaut"; }

}

@Controller("/hello")public class HelloController {

@Injectprivate HelloService helloService;

@Get public String hello() { return helloService.hello(); }

}

Page 26: Luram Archanjo - Amazon Web Services · 2019-05-16 · Moving to Microservices Feature A Feature B Feature C Monolith Microservice Microservices Microservice. Scalability Feature

Cloud Native Features

Page 27: Luram Archanjo - Amazon Web Services · 2019-05-16 · Moving to Microservices Feature A Feature B Feature C Monolith Microservice Microservices Microservice. Scalability Feature

Distributed Tracing

When operating Microservices in production it can be challenging to troubleshoot interactions between Microservices in a distributed architecture. Micronaut features integration with both Zipkin and Jaeger (via the Open Tracing API).

@Controller("/hello")public class HelloController {

@Injectprivate HelloService helloService;

@Get("/{name}")@NewSpan("hello") public String hello(@SpanTag String name) { return helloService.hello(); }

}

Page 28: Luram Archanjo - Amazon Web Services · 2019-05-16 · Moving to Microservices Feature A Feature B Feature C Monolith Microservice Microservices Microservice. Scalability Feature

Serverless Functions

Serverless architectures where as a developer you deploy functions that are fully managed by the Cloud environment and are executed in ephemeral processes require a unique approach.

@FunctionBean("hello-function")public class HelloFunction implements Supplier<String> {

@Override public String hello() { return "Hello world"; }

}

@FunctionClientpublic interface HelloFunctionClient {

String hello();

}

Page 29: Luram Archanjo - Amazon Web Services · 2019-05-16 · Moving to Microservices Feature A Feature B Feature C Monolith Microservice Microservices Microservice. Scalability Feature

Summary

2º Place

1º Place

3º PlaceAhead of Time (AOT) Compilation

● Low memory footprint

● Fast Startup

● IoC

● Productivity with annotations

● Blocking or Non-Blocking HTTP server built on Netty

Cloud Native Features

● Service Discovery

● Distributed Tracing

● Serveless

● Distributed Configuration

Page 30: Luram Archanjo - Amazon Web Services · 2019-05-16 · Moving to Microservices Feature A Feature B Feature C Monolith Microservice Microservices Microservice. Scalability Feature

Thanks a million!Questions?

/larchanjo

/luram-archanjo