Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Lightweight Java EE for <Buzzword> Services @ JBCNconf 17

Lightweight Java EE for <Buzzword> Services @ JBCNconf 17

June 19, 2017 @ JBCNconf 17

Java EE is not a hype. It is a well known player since 1999 – a quite long time but Java EE is just about to come off age.

“Modern” developers create micro or nano services, they use “state of the art” and “lightweight” frameworks. But when is a service micro or nano? When is a framework lightweight? How does Java EE fit in this modern world of software development?

In my opinion Java EE is a perfect choice for writing micro or nano services. In this talk I try to prove my statement. Live on stage I write two services with RESTful JSON APIs with only a few lines of code which communicate with each other and run the services using a local Docker cloud where you can see how these can be scaled up and down to manage fluctuating loads. Coding, building, deploying, scaling: fast and efficient!

To fully understand this talk the attendees should have basic knowledge of Java.

Marcus Fihlon

June 19, 2017
Tweet

More Decks by Marcus Fihlon

Other Decks in Programming

Transcript

  1. Lightweight Java EE for Services
    Coding, building, deploying, scaling: fast and efficient!
    Marcus Fihlon, McPringle
    June 19, 2017
    Software Engineer | Agile Coach | Lecturer | Speaker | Author

    View Slide

  2. Disclaimer
    The following presentation has been approved for open audiences
    only. Hypersensitivity to occasional profanity requires covering ears.
    All logos, photos etc. used in this presentation are the property of
    their respective copyright owners and are used here for educational
    purposes only. Any and all marks used throughout this presentation
    are trademarks of their respective owners.
    The presenter is not acting on behalf of CSS Insurance, neither as an
    official agent nor representative. The views expressed are those
    solely of the presenter.
    Marcus Fihlon disclaims all responsibility for any loss or damage
    which any person may suffer from reliance on this information or
    any opinion, conclusion or recommendation in this presentation
    whether the loss or damage is caused by any fault or negligence on
    the part of presenter or otherwise.
    1

    View Slide

  3. Session Material
    Slides, Code, Video
    http://fihlon.ch/jbcnconf17
    2

    View Slide

  4. About Me
    Software Engineer
    CSS Insurance, Open Source Software
    Agile Coach
    CSS Insurance
    Lecturer
    TEKO Swiss Technical College
    Speaker
    Conferences, User Groups, Meetups
    Author
    Articles, Books
    www.fihlon.ch | github.com | hackergarten.net | jug.ch
    3

    View Slide

  5. Agenda
    Buzzword Bingo
    Theory of Evolution
    Live Coding
    Wrap-up
    4

    View Slide

  6. Buzzword Bingo

    View Slide

  7. Buzzword Bingo
    Monolith
    Bad by default!
    Microservices
    Solve every problem!
    Nanoservices
    Solve all other problems!
    Docker
    Just because it’s cool!
    Java EE
    Uncool and heavy framework for bloated monoliths!
    5

    View Slide

  8. Buzzword Bingo
    Monolith
    Bad by default!
    Microservices
    Solve every problem!
    Nanoservices
    Solve all other problems!
    Docker
    Just because it’s cool!
    Java EE
    Uncool and heavy framework for bloated monoliths!
    5

    View Slide

  9. Buzzword Bingo
    Monolith
    Bad by default!
    Microservices
    Solve every problem!
    Nanoservices
    Solve all other problems!
    Docker
    Just because it’s cool!
    Java EE
    Uncool and heavy framework for bloated monoliths!
    5

    View Slide

  10. Buzzword Bingo
    Monolith
    Bad by default!
    Microservices
    Solve every problem!
    Nanoservices
    Solve all other problems!
    Docker
    Just because it’s cool!
    Java EE
    Uncool and heavy framework for bloated monoliths!
    5

    View Slide

  11. Buzzword Bingo
    Monolith
    Bad by default!
    Microservices
    Solve every problem!
    Nanoservices
    Solve all other problems!
    Docker
    Just because it’s cool!
    Java EE
    Uncool and heavy framework for bloated monoliths!
    5

    View Slide

  12. Theory of Evolution

    View Slide

  13. Expensive Resources
    6

    View Slide

  14. Add Virtualization
    7

    View Slide

  15. One VM per application
    8

    View Slide

  16. Shared Resources with Docker
    9

    View Slide

  17. Microservice Hype
    10

    View Slide

  18. Fat Binaries: long build times
    11

    View Slide

  19. Use the layers: short build times
    12

    View Slide

  20. Keep it lightweight!
    13

    View Slide

  21. Live Coding

    View Slide

  22. Architecture
    14

    View Slide

  23. Prepare the Swarm
    List all available machines
    docker-machine ls
    Create a new machine as a manager
    docker-machine create -d virtualbox mgr
    Create a new machine as a worker
    docker-machine create -d virtualbox node01
    Login to the manager
    docker-machine ssh mgr
    Initialize the swarm
    docker swarm init \
    --advertise-addr 192.168.99.100
    15

    View Slide

  24. Prepare the Visualizer
    Start the visualizer service
    docker run -it -d -p 8080:8080 \
    -e HOST=192.168.99.100 -v \
    /var/run/docker.sock:/var/run/docker.sock \
    manomarks/visualizer
    Open the visualizer service in a web browser
    http://192.168.99.100:8080/
    16

    View Slide

  25. Join the Swarm
    Ask the manager node for the token to join the swarm
    docker swarm join-token worker
    Login to the worker node
    docker-machine ssh node01
    Join the worker to the swarm
    docker swarm join --token \
    192.168.99.100:237
    17

    View Slide

  26. Verify the Swarm
    Login to the manager
    docker-machine ssh mgr
    List all nodes
    docker node ls
    Show more detailed information
    docker info
    18

    View Slide

  27. Create a Network
    Login to the manager
    docker-machine ssh mgr
    Create a new overlay network
    docker network create -d overlay jbcnconf
    List all networks
    docker network ls
    19

    View Slide

  28. Deploy Services
    Login to the manager
    docker-machine ssh mgr
    Deploy the time service
    docker service create --network jbcnconf \
    --name timeservice mcpringle/timeservice
    Deploy the hello service
    docker service create --network jbcnconf \
    -p 8181:8080 \
    --name helloservice mcpringle/helloservice
    List all services
    docker service ls
    20

    View Slide

  29. Testing, Scaling and Draining
    Testing our services
    curl \
    http://192.168.99.100:8181/api/hello/jbcnconf
    Scaling services up and down
    docker service update \
    --replicas 3 helloservice
    Draining the manager node
    docker node update --availability drain mgr
    21

    View Slide

  30. Wrap-up

    View Slide

  31. Conclusion
    With Java EE and Docker you get…
    easy to understand code
    fast build times
    reproducable deployments
    easy scaling of your services
    You are fast and efficient because you have your focus on your
    business code. You create business value!
    22

    View Slide

  32. Thank You! Questions?
    Slides, Code, Video
    http://fihlon.ch/jbcnconf17
    23

    View Slide