Posts

Showing posts with the label Java

Testing JVM resources availability in docker environment

Introduction JVM is changing over the time what makes us, Software Engineers, to periodically measure stability of our applications. JVM flag adaptations can be needed not only when upgrading JDK but also when we are changing available app cloud resources. If we pay for resources, we should use them in the most effective way. This article provides useful scripts and code to make resource control easier. All scripts and code used in this article you can find in this GitHub demo Testing JVM flags To test default JVM flags values depending on given resources I’m using script docker-jvm-flags.sh (available on github repo). You can easily modify it according to your preferences. Basically it runs JRE docker image with given memory and CPUs resources and for each of them executes command to get default JVM flags and filtering (with grep) those, which we specified on JVM_FLAGS_TO_PRINT list. docker-jvm-flags.sh JVM_IMAGE_NAME="e...

Java 21 vs. Java 11 - practical comparison

Image
Introduction This study aims to compare some metrics related to Java 11 and Java 21 applications and based on it, approximate the value of savings due to migration. In the tests I used following JDKs: - for Java 11: Coretto openjdk 11.0.19 2023-04-18 LTS - for Java 21: Oracle openjdk 21.0.1 2023-10-17 Hardware: - model: Lenovo Y50-70 - RAM: 16GB DDR3 1600MHz - CPU: Intel Core i7-4720HQ (Quad Core, 2.6GHz - 3.6GHz, 6MB Cache) - OS: Ubuntu Desktop 22.04.3 LTS Application which I've tested is available here Tested aspects Each test was done 10 times, one by one. Collected values description: - application start time – logged in application output: - application initial memory usage – RAM memory usage after application started (by PID from app logs): - application memory usage after init – RAM memory usage after sending request to application endpoint (by PID from app logs): ...

Pagination in API – why and how?

Introduction Pagination is splitting our data lists returned to the user from API into smaller parts. We can see that in many cases – i.e. changing pages of search results on Amazon or scrolling Facebook. What are benefits of pagination? Below you can see couple of them: reducing network traffic (users with poor network connection have better experience using app), making application more stable and production usable (Java apps can throw Out of Memory Error if the heap size exceeds Xmx value - it can happen when you load too much data from DB), reducing load of data processing and as a result reducing cost of maintenance our app - especially when hosting in cloud, app can handle more requests in the same period of time (cause faster responses), reducing number of returned objects which are not ...