Win a copy of The Journey To Enterprise Agility this week in the Agile and Other Processes forum! And see the welcome thread for 20% off.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Jeanne Boyarsky
  • Liutauras Vilda
  • Campbell Ritchie
  • Tim Cooke
  • Bear Bibeault
Sheriffs:
  • Paul Clapham
  • Junilu Lacar
  • Knute Snortum
Saloon Keepers:
  • Ron McLeod
  • Ganesh Patekar
  • Tim Moores
  • Pete Letkeman
  • Stephan van Hulst
Bartenders:
  • Carey Brown
  • Tim Holloway
  • Joe Ess

Optimizing Java: microservices  RSS feed

 
Greenhorn
Posts: 20
Fedora IntelliJ IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all authors of this book,

At first I would like to thank you for writing of this book and I must read this book because I feel it is "required reading" for all Java developers who want to do the best work in Java world.

And my question is if there is any part or paragraph about performance tuning of containerized Java applications? Of course we have to tune our applications for the best performance and the lowest memory and CPU consumption but what about tuning of the JVM itself?
For example there was added experimental support for Docker CPU and memory limits in Java 8u131 and 9. So now I can run Java application with flags -XX:+UnlockExperimentalVMOptions -XX:+UseCGroupMemoryLimitForHeap inside of the container and limit memory externally (Kubernetes manifests, Docker run commands, ...).
But is there something else what can help me to have smaller JVM instances?
Microservices are perfect for scaling and separating of business logic but each microservice eats another memory for JVM :-(

Thanks a lot,
Lukas
 
author
Ranch Hand
Posts: 51
5
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Lukas,

We don't specifically talk about microservices - but the general advice given in the book definitely still applies to microservices as well as more traditional Java apps.

One area that you should definitely keep an eye on is the development of the Graal-based Ahead-Of-Time (AOT) compiler. This allows simple Java applications to be compiled to native code, which can give much smaller memory footprint and code size.

The technology is still experimental, but is present in Java 10 (Note: Java 9 is now end-of-life and no longer supported - the current versions are 8 & 10 - at least until September when the new LTS release - 11 - comes out).

AOT compilation has some restrictions - currently reasonablt severe - but they should be eased over time as the tech develops. The biggest limitation at the moment is the "Closed World" assumption that jaotc requires.
 
Lukas Machacek
Greenhorn
Posts: 20
Fedora IntelliJ IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Ben,

Thank you. This is exactly what I was asking for.
So I'll look on Graal-based AOT compiler and try to reduce the JVM overhead in our microservices.

Anyway, I'll read your book to improve the knowledge I already have ;-)
 
Ben Evans
author
Ranch Hand
Posts: 51
5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Lukas,

Hope it's useful - I'm just finishing off a new article for infoq.com all about Graal - should be coming out in the next week, so keep an eye out for it - I'll be covering a few bits about aotc in it!
 
author
Greenhorn
Posts: 14
5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Lukas,

Another topic of conversation around microservices is related to deployment in containers e.g. Docker. Java hasn't traditionally worked well in containers, as often it ends up looking outside the container to find the available resources - often leading to it blowing up the heap and making false assumptions about the available amount of resources the container has.

There are ways around this in pre Java 10, but Java 10 specifically introduced some features to improve Javas ability to run inside containers. You might find this article interesting.

You may also wish to look at OpenJ9, which is the open source IBM JVM. There's some really interesting Ahead of Time compilation techniques being experimented with there that can significantly reduce footprint.
 
Lukas Machacek
Greenhorn
Posts: 20
Fedora IntelliJ IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Jim,

Thank you very much for your input and links.

I'm glad to hear that new versions of Java are more container friendly because I have felt more and more that Java is not the right platform for really small and lightweight microservices.

I'm going to rebuild all containers in at least development environment with Java 10 and will see what will monitoring show.

And I hope that I'll have time to look on OpenJ and also Graal AOT as soon as possible. My TODO query still grows and grows ...

Do you have any personal experience with OpenJ9? Is it fully compatible with Oracle JVM and Open JVM or should I be aware of any pitfalls?

Thanks,
Lukas
 
Don't get me started about those stupid light bulbs.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!