Adam Bien's Weblog

Load Balancing Java EE Microservices

In this screencast I implemented a minimalistic, load balanced Java EE 7 application comprising two identical nodes and a ha-proxy:

See you at Java EE Workshops at Munich Airport, Terminal 2 or Virtual Dedicated Workshops / consulting. Is Munich's airport too far? Learn from home: airhacks.io.


NEW workshop: Building HTML 5 Applications With Angular 2
Full week in December 2016: from Java EE 7 Bootstrap, Effective, Architectures over Testing to Microservices
On demand workshops: Java EE 7: Bootstrap, Effective, Testing and Microservices available for streaming.

Newsletter: airhacksnews.com

A book about rethinking Java EE Patterns

The Ingredients and Roadmap of Rebooted Java EE 8 and 9

After one year vacations Java EE 8 was rebooted and is going to be optimised to run on hypervisors and / or container environments. Java EE 8 will focus on the following areas below -- it is a proposal and very likely to change in the JCP process:

Programming Model
  1. Extend for reactive programming
  2. Unified event model
  3. Event messaging API
  4. JAX-RS, HTTP/2, Lambda, JSON-B, (...)
Packaging
  1. Package applications, runtimes into services
  2. Standalone immutable executable binary
  3. Multi-artifact archives
Key Value/Doc Store
  1. Persistence and query interface for key value and document DB
Eventual Consistency
  1. Automatically event out changes to observed data structures
Serverless
  1. New spec - interfaces, packaging format, manifest
  2. Ephemeral instantiation
Configuration
  1. Externalize configuration
  2. Unified API for accessing configuration
Multitenancy
  1. Increased density
  2. Tenant-aware routing and deployment
State
  1. API to store externalized state
Resiliency
  1. Extension to support client-side circuit breakers
  2. Resilient commands
  3. Standardize on client-side format for reporting health
Security
  1. Secret management
  2. OAuth
  3. OpenID

The choices are pragmatic and will make Java EE an even more productive platform. I'm only missing a slightly extended and modernized "Concurrency Utilities for Java EE" (jcp.org/ja/jsr/detail?id=236). Particularly the ThreadPool configuration and Backpressure could be easily standardized just by agreeing on features from https://docs.oracle.com/javase/7/docs/api/java/util/concurrent/ThreadPoolExecutor.html. Particularly useful would be the integration of the statistics (e.g. Bulkheads) with the Health Check API.

Also a standardized management API (not proposed) would simplify the creation of application images through a unified API.

Java EE 8 and 9 will come at light speed to an application server vendor near you. Java EE 8 is expected to be delivered in 2017 and Java EE 9 in 2018.

Oracle is listening now, take the chance and participate at the survey (takes a few mins): glassfish.org/survey

See you at Java EE Workshops at Munich Airport, Terminal 2 or Virtual Dedicated Workshops / consulting. Is Munich's airport too far? Learn from home: airhacks.io.


NEW workshop: Building HTML 5 Applications With Angular 2
Full week in December 2016: from Java EE 7 Bootstrap, Effective, Architectures over Testing to Microservices
On demand workshops: Java EE 7: Bootstrap, Effective, Testing and Microservices available for streaming.

Newsletter: airhacksnews.com

A book about rethinking Java EE Patterns

JavaOne: Live Coding "No Ceremony" Java EE Microservices Session and Screencast

In the screencast below I created Java EE 7 projects with maven, developed and build them, created and build docker images, created a user defined network and finally launched the WARs on payara and wildfly and let them communicate:

In the first part of the JavaOne 2016 session in San Francisco I did the same. For unknown reasons docker was unbelievably slow during the presentation (I guess caused by network timeouts), so I re-recorded the first part. Now you can fast-forward over "boring" parts in the JavaOne presentation:

Any questions left? The next http://airhacks.tv is around the corner. Ask now: https://gist.github.com/AdamBien/e6e20c129e673ad558be495dd4f3afc4 or wait a month. See you at Java EE Workshops at Munich Airport, Terminal 2 and particularly at Java EE 7 Microservices. Is MUC too far? Checkout: javaeemicro.services.


NEW workshop: Building HTML 5 Applications With Angular 2
Full week in December 2016: from Java EE 7 Bootstrap, Effective, Architectures over Testing to Microservices
On demand workshops: Java EE 7: Bootstrap, Effective, Testing and Microservices available for streaming.

Newsletter: airhacksnews.com

A book about rethinking Java EE Patterns

My One And Only Microservices Live Hacking JavaOne Session

This year I was more cautious and only proposed a single session:

Live-Coding No-Ceremony Microservices [CON3436]

Java EE is productive and easy to learn and runs smoothly on containers such as Docker and rkt. It has become the perfect microservices platform. Unfortunately, no one in the enterprise is interested in managing thousands of nanoservices “just for fun.” In this session, the presenter hacks on stage a couple of Java EE 7/8 “rightsized” services, links them together, runs them on Docker, and explains the architectural decisions and best practices in real time.

This session is already available for: streaming.

Tuesday, Sep 20, 2:30 p.m. - 3:30 p.m. | Parc 55 - Embarcadero

Is San Francisco too far? See you at Java EE Workshops at Munich Airport, Terminal 2 and particularly at Java EE 7 Microservices.


NEW workshop: Building HTML 5 Applications With Angular 2
Full week in December 2016: from Java EE 7 Bootstrap, Effective, Architectures over Testing to Microservices
On demand workshops: Java EE 7: Bootstrap, Effective, Testing and Microservices available for streaming.

Newsletter: airhacksnews.com

A book about rethinking Java EE Patterns

Java EE: Accessing Resources In Docker In Stage Environment

"How to change a e.g. JDBC URI in the configuration of a Java EE application server running in docker and staged environment?"
...is one of the recurring airhacks.com, airhacks.io and airhacks.tv questions.

The answer is: don't change it:

See you at Java EE Workshops at Munich Airport, Terminal 2 and particularly at Java EE 7 Microservices Is MUC too far? Checkout: javaeemicro.services.


NEW workshop: Building HTML 5 Applications With Angular 2
Full week in December 2016: from Java EE 7 Bootstrap, Effective, Architectures over Testing to Microservices
On demand workshops: Java EE 7: Bootstrap, Effective, Testing and Microservices available for streaming.

Newsletter: airhacksnews.com

A book about rethinking Java EE Patterns

Building Integrated Messaging Solutions For Banks With Java EE Microservices

Grzegorz, please introduce yourself

My name is Grzegorz Huber and I'm a software developer at www.consdata.com. There are other titles that change depending on my current role in different projects, but I prefer the down-to-earth description instead.

What are you currently building?

We're building a mailbox application for one of the banks here in Poland. The idea is to give clients a better tooling for their needs to contact the bank whether it's a support question or a complaint. Obviously this also means integrating with internal bank mechanisms and now clients are receiving their bank statements in a much more convenient way. It probably sounds boring because we've all been using emails for years. However, designing your own messaging application turns out to be quite a challenge especially when everyone just keeps on saying just do it like Google does ;-). The domain is simple, yes, but the scale of the system make things much more challenging. Plus it's not only for messaging. We're currently integrating our mailbox application with some of our other products that add more functionalities like internet forms and automated workflow. Most of the features have already been implemented and I'm still in awe that our whole backend is under 20k lines of code. And people say Java makes your systems big.

After the Java EE Microservices workshop at MUC Airport in January you decided to refactor your current application towards pure Java EE Microservices. What is the progress?

Actually, It was a brand new application and we started in late February so the timing was perfect for us. The current progress is 10 microservices. I guess that's one way to describe our "advancement". Using other metrics we're currently in performance testing and getting closer to the production stage. That's for my current project. The side effect is a very small change within our organization that's about to take it's ripple effect to a whole new level.

How many microservices comprise your application / system?

Currently ten, but it was our first time and there were some disbelievers, who were skeptical at first, plus the learning curve so we definitely see there could be more closer to 15.

Which application servers, tools or IDEs are you using?

The most interesting is probably the Java EE part of the whole architecture where we decided to use Payara, Payara Micro, Embedded Payara for testing. Obviously is many ways inspired by the training in Munich. On top of that we developed our own installation platform based on Docker, which help us manage different parts of our application.

How big is your WAR?

It's between 3 and 8 MB. We're not super light, but we're very happy with the final result. Some compromises had to be made. For example we decided to use lombok, which adds almost 2MB to each war. Logback and its dependencies add another 700KB. Plus our db backends use mybatis, which adds almost 2MB as well. We like this strategy anyway... we try to keep these values in check and we consciously select what should be provided by the Jave EE container and what should be included with our application. I would like to be able to go with the javaee-api alone, but that's not possible ;-).

Here's the full report ;-)

3,7M lip 18 15:15 statics.war
7,0M lip 18 15:15 messages.war
8,0M lip 18 15:15 integration.war
7,0M lip 18 15:15 messages-sendmass.war
5,7M lip 18 15:15 users.war
3,4M lip 18 15:15 facade.war
5,5M lip 18 15:15 templates.war
3,8M lip 18 15:15 ecm.war
3,9M lip 18 15:15 crypto.war
3,6M lip 18 15:15 accounts.war

How fast is the build?

The whole microservice backend without tests is like 20-30 seconds. I normally don't divide build time with and without tests, but we did something here that should be mentioned. We write basic JUnit test cases in 3 layers... sort of. Layer one are basic junit tests based on mockito for simple business logic tests. Layer two includes real bean tests using CDI injection and everything that's possible within one microservice and using specialization beans that serve as mocks to other microservices. Layer three is the most expensive, but I think the pros are much more important than the disadvantage of extra added time. Our layer 3 test use the embedded Payara Micro, which takes the target wars and tests the real application stuff and including communication between microservices. We have Junit tests that use up to 6 microservice modules depending on the user story. I think that's one of the bigger challenges awaiting those who adopt this architecture so it was really handy to have Payara ready for that. The whole build, the one we use to build upon every commit for pull requests, takes up to 5 minutes at the moment.

Does "stock" Java EE fit well with the microservices idea?

Yep! It seems that it was designed this way and it's asking to be used this way. I really don't know why this approach wasn't picked up faster by developers around the world :).

You are using the porcupine as Bulkhead. Which problem does it solve?

Well, even though Glassfish (and Payara) have built-in monitoring it wasn't what we wanted it to be. Instead with a proper application design and splitting code across different microservices and different executors we were able to get our own dedicated monitoring service via REST plus other small things like named threads for each module. Additionally there's this feeling that you're in complete control over how different modules have different configurations for their own executor services. The added benefit of using Porcupine right away is that when you think about stuff like thread pools at the beginning of your application it's much easier to scale your system in the future.

Are you still happy with Boundary Control Entity?

I don't think we use that in the direct way. We definitely don't use technical names for organizing the core within our microservices and our approach is still based on the business responsibilities of the classes.

Any major challenges so far?

Apart from different approach to testing, which I think we tackled head on, the biggest challenge is probably some sort of microservice registry that's we're still missing in our project. Using Docker helps here a little bit, but when you get 10+ microservices and you really want to use them independently it's good to have something this figured out. One of the main reason why I came across your training was an idea to replace OSGi with something lighter. Microservices are indeed lighter, but you still have to manage them on your own. There are many solution that help with that, but I feel we need to be careful here, cause adding a registry is a good idea, but it can't become a single point of failure for us.

Any closing thoughts on Java EE and microservices?

It's nice to be able to design modules in such way that the main application operation is designed to work 24hrs per day and other heavy operation, which may bring instability to the system are in separate modules on different servers with different boundaries.

That's nearly impossible with a monolith and usually it's too late. In our case we had 9 microservices at one point and the 10th was brought to life when we realized that our core business logic is so fast and small that it runs smoothly on 1GB of RAM and the other module is doing this big batch operations and needs additional 6-8GB of RAM. It would be ill-advised to run them both together on a 8GB RAM system.

Business-wise both modules send messages. The microservice way of thinking let's you split code not only using domains but ever further when there are other benefits like performance and stability.

Is you company hiring Java (EE) developers?

Yes, checkout: kariera.consdata.pl/

Can you share any resources with us?

Here you can learn more about our software www.consdata.com. Feel free to contact me at ghuber@consdata.pl if you have any questions.


NEW workshop: Building HTML 5 Applications With Angular 2
Full week in December 2016: from Java EE 7 Bootstrap, Effective, Architectures over Testing to Microservices
On demand workshops: Java EE 7: Bootstrap, Effective, Testing and Microservices available for streaming.

Newsletter: airhacksnews.com

A book about rethinking Java EE Patterns

React, Angular 2, Microservices, High Performance Java EE, Q & A -- Early Autumn Events, Conferences and JUGs

  • Mission Impossible: From HTML 5 to Native Applications, Workshop for Java EE developers, Rapperswil, Tuesday, 13th September. My goal is a (code) walk through the current JavaScript / HTML 5 / CSS eco system. This course is targeted to Java EE developers -- at least I will provide as many as possible relevant samples from the Java EE ecosystem to explain HTML 5 && Co.
  • Live Q&A streaming: October, 3rd, 6 pm CET: www.ustream.tv/channel/adambien Any questions left? Ask now: https://gist.github.com/AdamBien/e6e20c129e673ad558be495dd4f3afc4
  • Live Coding "No-Ceremony" Microservices, CON3436, September, 20th, 14:30, 15:30, JavaOne Conference, San Francisco. Last year I got too many questions and there was no time left for coding. This year I plan to code, build and deploy as many cycles as only possible. Docker, Java EE, Networking, Configuration & Co. topics included. I will answer the questions from the audience concurrently -- without any breakpoints.
  • Live streaming session, Internet Mobile World, "Building Backend Services -- Fast and Straight" imworld.ro
  • Live streaming session, High Load Conf, October, 15th, "Lightning Java EE -- What Is Possible With Stock Servers", hdconf.by
  • October, 19th, JUG Poznan session: "Microservices in 2016 — What Worked Well (this time completely without slides)". This session is about lessons learned and the most frequently asked questions about Microservices and Java EE. This time I plan to spend 99,99% of the time in the IDE. The more questions -- the better.
  • airhacks.com workshop: MUC airport, October, 24th Building React Apps. From setup, over build, to "hot deployment" with the JavaScript "Framework" react. After several React project I would like to present some "working practices".
  • airhacks.com workshop: MUC airport, October, 25th Building Angular 2 Apps. In this workshop I will focus on Angular 2 and will cover the typical project lifecycle - from setup over deployment. This workshop is similar to the "Building React Apps", but only covers Angular 2.

Coming this winter: 5 days Java EE Airhacks: from Bootstrap, over best practices, architectures, testing to microservices: http://workshops.adam-bien.com

Also checkout workshops on-demand: airhacks.io.


NEW workshop: Building HTML 5 Applications With Angular 2
Full week in December 2016: from Java EE 7 Bootstrap, Effective, Architectures over Testing to Microservices
On demand workshops: Java EE 7: Bootstrap, Effective, Testing and Microservices available for streaming.

Newsletter: airhacksnews.com

A book about rethinking Java EE Patterns

Java EE 8 Is Coming, Docker Hub, Configuration, AMQP, DTO Not Dead or 30th airhacks.tv

117 live attendees, 13+ questions, or the 30th airhacks.tv is available:

Any questions left? Ask now: https://gist.github.com/AdamBien/e6e20c129e673ad558be495dd4f3afc4.

The questions above are going to be answered during the next "Airhacks Q & A" http://airhacks.tv live. You can subscribe to the channel and / or for the next event: http://www.ustream.tv/channel/adambien (both is optional, no registration required to watch this event live).

See you at Java EE Workshops at Munich Airport, Terminal 2 or Virtual Dedicated Workshops / consulting. Is Munich's airport too far? Learn from home: airhacks.io.


NEW workshop: Building HTML 5 Applications With Angular 2
Full week in December 2016: from Java EE 7 Bootstrap, Effective, Architectures over Testing to Microservices
On demand workshops: Java EE 7: Bootstrap, Effective, Testing and Microservices available for streaming.

Newsletter: airhacksnews.com

A book about rethinking Java EE Patterns

Running A Stock Java EE 7 Thin WAR On Docker

Java EE separation of plumbing and pure business logic (aka Thin Wars) makes Docker builds fast and the images small:

The Payara and WildFly images in this screencast were taken from: https://github.com/AdamBien/docklands and hosted on: https://hub.docker.com/u/airhacks/

Interested in productive microservices? Checkout: javaeemicro.services, or visit MUC's airport: Java EE 7 Microservices.


NEW workshop: Building HTML 5 Applications With Angular 2
Full week in December 2016: from Java EE 7 Bootstrap, Effective, Architectures over Testing to Microservices
On demand workshops: Java EE 7: Bootstrap, Effective, Testing and Microservices available for streaming.

Newsletter: airhacksnews.com

A book about rethinking Java EE Patterns

Docklands: Java EE Docker Images In "Docker Central"

Docklands comprises Java EE-relevant (Wildfly, Payara, TomEE, WebSphere Liberty, WLS, Tomcat (...)) Dockerfiles, directly available from hub.docker.com/u/airhacks/.

Docklands images are heavily relying on image layering.

A typical Java EE application comprises the following layers:

  1. airhacks/java: the OS + Java layer. Only serves as a base, "abstract" layer. Changes on OS and Java releases and patches.
  2. airhacks/[appserver]: this layer inherits from airhacks/java and only contains the application server installation. Only changes on new application server releases.
  3. airhacks/[appserver]-configured: inherits from 2. and contains project-specific configuration like e.g. JMS Queues, JDBC DataSources etc. Has to be rebuilt on projects-specific configuration changes like e.g. -Xmx or -Xms changes. This layer is optional
  4. airhacks/[project-name]: inherits from 2. or 3. Only contains a Thin War. Is rebuilt with each mvn package

Fortunately the base images are big, but have to rebuilt only a few times in year. The application / project images change several times a day, but are tiny. The creation of a full docker image with https://github.com/AdamBien/docklands takes usually: ~100ms and only adds the WAR size (usually a few MB) to the total size.

The base images exist only once at your hard drive and are shared across different application servers and applications (aka microservices).

Try it: docker run -d -p 8080:8080 --name payara-ping airhacks/payara-ping

Checkout docklands for the sources, or docklands at hub.docker.com for ready to use images.

Docklands in action:

See you at Java EE Workshops at Munich Airport, Terminal 2 and particularly at Java EE 7 Microservices. Is MUC too far? Checkout: javaeemicro.services.


NEW workshop: Building HTML 5 Applications With Angular 2
Full week in December 2016: from Java EE 7 Bootstrap, Effective, Architectures over Testing to Microservices
On demand workshops: Java EE 7: Bootstrap, Effective, Testing and Microservices available for streaming.

Newsletter: airhacksnews.com

A book about rethinking Java EE Patterns

realworldpatterns.com
Online Workshops
...the last 150 posts
...the last 10 comments
License