In my application I have implemented a background task which reads a JSON file to memory and parses it into Java objects of relevant (specified in JSON) classes. I use Jackson to parse JSON. The JSON file is about 6MB in size. My JSON files look more or less like this:
{
Class_type_A: {
Entry_1: x,
Entry_2: x,
...
Entry_200000: x
},
Class_type_B: {
Entry_1: x,
Entry_2: x,
...
Entry_200000: x
}
}
My background task runs every 30 minutes, and this is also where my JVM shows significantly big (up to 2 seconds) pause for garbage collection, which unfortunately impacts live traffic to my application. I am sure garbage collection pauses are related to JSON loading, because I compared task with JSON loading to the same task without. I have never attempted debugging such a thing before and I don't quite know where to start.
I use Zulu 11 OpenJDK and G1 garbage collector.
Here are my questions:
- Is there any specific logs that I should look into, to understand what is happening?
- Why does reading JSON have such impact on GC?
- How do you suggest I can validate that JSON parsing is responsible for such long GC pauses?
- Do you think Jackson library streaming API for reading JSON could save me from garbage collection spikes? Especially so, if I have only 2 nodes in my JSON?