Más contenido relacionado

Similar a 2018 (codeone) Graal VM and MicroProfile a polyglot microservices solution [dev6016](20)

Más de César Hernández(20)

2018 (codeone) Graal VM and MicroProfile a polyglot microservices solution [dev6016]

  1. @radcortez @CesarHgt @tomitribehttps://www.tomitribe.com/codeone/dev6016/ Roberto Cortez, César Hernández GraalVM and MicroProfile: A Polyglot Microservices Solution
  2. @CesarHgt @ivanjunckes @tomitribetomitribe.com/codeone/dev5933/ SPEAKERS Roberto Cortez ● Blogger, Youtuber, Speaker ● +10 years of experience with Java César Hernández ● Senior Software Engineer at Tomitribe ● Java Champion ● Duke’s Choice Award 2016, 2017 ● Oracle Certified Professional ● +10 experience with Java EE ● Eclipse Committer: Jakarta EE TCK, JAX-WS and Microprofile. ● Open Source advocate, teacher and public speaker ● Senior Software Engineer at Tomitribe ● Java Champion & Oracle Groundbreaker ● JUG Leader Coimbra JUG & vJUG ● JNation Conference Founder & Organizer
  3. @radcortez @CesarHgt @tomitribehttps://www.tomitribe.com/codeone/dev6016/ Questions? As soon as you have them!
  4. @radcortez @CesarHgt @tomitribehttps://www.tomitribe.com/codeone/dev6016/ Agenda ● Microservices! ● What is GraalVM? ● What is MicroProfile? ● Demos
  5. @radcortez @CesarHgt @tomitribehttps://www.tomitribe.com/codeone/dev6016/ Microservices anyone?
  6. @radcortez @CesarHgt @tomitribehttps://www.tomitribe.com/codeone/dev6016/
  7. @radcortez @CesarHgt @tomitribehttps://www.tomitribe.com/codeone/dev6016/ Microservices ● Have you heard about Microservices? ● How big is a micro? ● Who develops Microservices? ● Who deploys Microservices? ● Who likes Microservices?
  8. @radcortez @CesarHgt @tomitribehttps://www.tomitribe.com/codeone/dev6016/ What do others think?
  9. @radcortez @CesarHgt @tomitribehttps://www.tomitribe.com/codeone/dev6016/ What do others think?
  10. @radcortez @CesarHgt @tomitribehttps://www.tomitribe.com/codeone/dev6016/ What do others think?
  11. @radcortez @CesarHgt @tomitribehttps://www.tomitribe.com/codeone/dev6016/ What do others think?
  12. @radcortez @CesarHgt @tomitribehttps://www.tomitribe.com/codeone/dev6016/ Why Microservices? ● Deliver new features quicker ● Smaller, agile teams ● Scale services independently ● Cloud
  13. @radcortez @CesarHgt @tomitribehttps://www.tomitribe.com/codeone/dev6016/ Microservice Hell? ● Supporting Multiple Languages ○ Java (and JVM Languages), Node, Python, Ruby, PHP, Go, etc, etc. ● Different libraries to cover same features ● Increased complexity ● Research time ● May need to rewrite your libraries for all languages
  14. @radcortez @CesarHgt @tomitribehttps://www.tomitribe.com/codeone/dev6016/ GraalVM
  15. @radcortez @CesarHgt @tomitribehttps://www.tomitribe.com/codeone/dev6016/ GraalVM ● Universal virtual machine ● JavaScript, Python, Ruby, R, JVM-based languages (Java, Scala, Kotlin), and LLVM-based languages (C and C++) ● Open Source Project (GPL2 /w CPE) ● https://www.graalvm.org/ ● https://github.com/oracle/graal
  16. @radcortez @CesarHgt @tomitribehttps://www.tomitribe.com/codeone/dev6016/ GraalVM Architecture
  17. @radcortez @CesarHgt @tomitribehttps://www.tomitribe.com/codeone/dev6016/ DEMO Installation and run a simple app with GraalVM
  18. @radcortez @CesarHgt @tomitribehttps://www.tomitribe.com/codeone/dev6016/ Why GraalVM? ● Native Images ● Interoperability ● Reuse Libraries ● Shared Tools ● Run Java faster
  19. @radcortez @CesarHgt @tomitribehttps://www.tomitribe.com/codeone/dev6016/ Native Image native-image -cp target/number.api.jar org.tomitribe.graalvm.microprofile.number.api.NumberResource native-image -jar target/number-api.jar
  20. @radcortez @CesarHgt @tomitribehttps://www.tomitribe.com/codeone/dev6016/ DEMO Native image Java app with GraalVM
  21. @radcortez @CesarHgt @tomitribehttps://www.tomitribe.com/codeone/dev6016/ Interoperability var fileClass = Java.type("java.io.File"); var file = new FileClass("file.txt"); file.exists(); var file = new (Java.type("java.io.File"))("file.txt"); var pathSeparator = Java.type("java.io.File").pathSeparator;
  22. @radcortez @CesarHgt @tomitribehttps://www.tomitribe.com/codeone/dev6016/ Reuse Libraries --jvm allows you to execute the application in the JVM and pass in a classpath to use libraries. node --jvm --jvm.cp=library.jar app.js ruby --jvm --jvm.cp=library.jar ruby.rb graalpython --jvm --jvm.cp=library.jar python.py
  23. @radcortez @CesarHgt @tomitribehttps://www.tomitribe.com/codeone/dev6016/ NPM module, Ruby gem or R package compatibility? https://www.graalvm.org/docs/reference-manual/compatibility/
  24. @radcortez @CesarHgt @tomitribehttps://www.tomitribe.com/codeone/dev6016/ MicroProfile
  25. @radcortez @CesarHgt @tomitribehttps://www.tomitribe.com/codeone/dev6016/ MicroProfile ● http://microprofile.io ● Enterprise Java for MicroServices ● Open Source (Eclipse) ● Implemented by different vendors. ● Application portability across runtimes.
  26. @radcortez @CesarHgt @tomitribehttps://www.tomitribe.com/codeone/dev6016/ MicroProfile 2.1 MicroProfile 2.1 JAX-RS 2.1JSON-P 1.1CDI 2.0 Config 1.3 Fault Tolerance 1.1 JWT Propagation 1.1 Health Check 1.0 Metrics 1.1 Open Tracing 1.2 Open API 1.0 Rest Client 1.1 JSON-B 1.0
  27. @radcortez @CesarHgt @tomitribehttps://www.tomitribe.com/codeone/dev6016/ MicroProfile Implementations ● Apache TomEE ● Payara Micro ● Thorntail ● WebSphere Liberty ● KumuluzEE ● SmallRye
  28. @radcortez @CesarHgt @tomitribehttps://www.tomitribe.com/codeone/dev6016/ What is TomEE? ● Tomcat + Jakarta EE = TomEE ● Built within the OpenEJB community to offer a lightweight alternative with Tomcat being the top dog. ● TomEE 8 is a MicroProfile implementation ● Supports MicroProfile 1.3. ● Planned support for MicroProfile 2.x.
  29. @radcortez @CesarHgt @tomitribehttps://www.tomitribe.com/codeone/dev6016/ Configuration ● Applications need configuration based on their running environment ● It must be possible to change configuration without repacking the application. ● Java - MicroProfile Config ● Node - Node Convict ● Ruby - dotenv?
  30. @radcortez @CesarHgt @tomitribehttps://www.tomitribe.com/codeone/dev6016/ MicroProfile Config Config config = ConfigProvider.getConfig(); String url = config.getValue("connection.url", String.class); String optionalUrl = config.getOptionalValue("connection.url", String.class).orElse("something");
  31. @radcortez @CesarHgt @tomitribehttps://www.tomitribe.com/codeone/dev6016/ Demo MicroProfile Config in Node and Ruby app
  32. @radcortez @CesarHgt @tomitribehttps://www.tomitribe.com/codeone/dev6016/ Fault Tolerance ● Guide the execution and result of some logic ● Circuit Breaker, TimeOut, Retry, Fallback and Bulkhead ● Java - MicroProfile Config ● Node - Opossum ● Ruby - CircuitBox
  33. @radcortez @CesarHgt @tomitribehttps://www.tomitribe.com/codeone/dev6016/ MicroProfile Fault Tolerance @CircuitBreaker @Fallback(NumberFallbackHandler.class) public String getNumber(); public class NumberFallbackHandler implements FallbackHandler<String> { @Override public String handle(final ExecutionContext executionContext) { ... } }
  34. @radcortez @CesarHgt @tomitribehttps://www.tomitribe.com/codeone/dev6016/ Rest Client ● Microservices typically talk REST to other services ● Consistent and easy to use ● Java - MicroProfile Rest Client (inspired by Feign) ● Node - Node Rest Client ● Ruby - Ruby Rest Client
  35. @radcortez @CesarHgt @tomitribehttps://www.tomitribe.com/codeone/dev6016/ MicroProfile Rest Client @Dependent @RegisterRestClient @Path("/number") @Produces(MediaType.TEXT_PLAIN) @Consumes(MediaType.TEXT_PLAIN) public interface NumberResourceClient { @GET @Path("/generate") String getNumber(); }
  36. @radcortez @CesarHgt @tomitribehttps://www.tomitribe.com/codeone/dev6016/ DEMO MicroProfile Rest Client and Fault Tolerance in Ruby and Python app
  37. @radcortez @CesarHgt @tomitribehttps://www.tomitribe.com/codeone/dev6016/ Security ● Security Token ● Lightweight way to propagate identities across different services ● Java - MicroProfile JWT Propagation ● Node - express-jwt ● Ruby - ruby-jwt
  38. @radcortez @CesarHgt @tomitribehttps://www.tomitribe.com/codeone/dev6016/ Health Check ● Probe the state of a computer node ● Automated processes to maintain the state of the nodes ● Java - MicroProfile Healthchecks ● Node - express-healthcheck ● Ruby - okcomputer
  39. @radcortez @CesarHgt @tomitribehttps://www.tomitribe.com/codeone/dev6016/ Metrics ● Monitor essential System Parameters ● Ensure reliable operation of Software ● Java - MicroProfile Metrics ● Node - appmetrics ● Ruby - ???
  40. @radcortez @CesarHgt @tomitribehttps://www.tomitribe.com/codeone/dev6016/ DEMO Polyglot App with Microprofile Architecture
  41. @radcortez @CesarHgt @tomitribehttps://www.tomitribe.com/codeone/dev6016/ movies-app Angular JS, Java API Gateway comments-api NodeJS number-api NodeJS, Ruby, Java libraries.jar Java number-api-client Ruby, Python
  42. @radcortez @CesarHgt @tomitribehttps://www.tomitribe.com/codeone/dev6016/ Limitations ● Dynamic Class Loading (native images) https://github.com/oracle/graal/blob/master/substratevm/LIMITATIONS.md ● Manage your own classpath (for integration) ● Lack of tooling ● Not much information around ● Python still in early support stage. No support for Rails.
  43. @radcortez @CesarHgt @tomitribehttps://www.tomitribe.com/codeone/dev6016/ Production Ready? ● OK for JVM Languages and JS ● Other languages may not work fully ● Twitter is using it in production already ● Consider performance ● Try it out!
  44. @radcortez @CesarHgt @tomitribehttps://www.tomitribe.com/codeone/dev6016/ Final Thoughts ● GraalVM could potentially improve MicroServices development ● It could help bring technologies together ● Pick one of your favorites languages (from the supported ones) ● Consistency ● No boundaries
  45. @radcortez @CesarHgt @tomitribehttps://www.tomitribe.com/codeone/dev6016/ https://www.tomitribe.com/codeone/dev6016 Slides and demo Contact us @TOMITRIBE