question

Tri avatar image
Tri asked Erick Ramirez edited

How do I optimize the schema to reduce JVM garbage collection?

DS210 course Garbage Collection at ~4:00 minute.

If you see multi-seconds GC pauses. There is likely major compaction happening. If this occurs, you need to fix your GC setting by adjusting the heap size. Also you may want to consider your data model, because something is creating a lot of garbage.

Question: what is in the data model that could create a lot of garbage? And possibly how to reduce or even to avoid?

jvm
10 |1000

Up to 8 attachments (including images) can be used with a maximum of 1.0 MiB each and 10.0 MiB total.

1 Answer

Erick Ramirez avatar image
Erick Ramirez answered Erick Ramirez edited

There isn't a quick fix but you will typically need to analyse your heap utilisation using tools like Eclipse's Memory Analyzer (MAT) or Oracle's Java Flight Recorder (JFR).

One of the usual suspects with data models is using Cassandra with a queue pattern typically for processing orders or messages. These queue-like use cases tend to have a high delete workload and can cause high heap utilisation when reading data and having to iterate over deleted rows or columns to get to the live data. If you're interested, see the blog post Cassandra anti-patterns: Queues and queue-like datasets for more information.

Another data model issue is the incorrect use of the IN() operator to query multiple partitions. See When not to use IN() in the CQL docs for details.

Data models with too many tables is also a problem since it can put pressure on memory usage. See the Anti-patterns section of the DataStax Docs for details.

These are by no means the complete list. As I said, identifying problems with the data model requires analysis of the heap utilisation. Cheers!

2 comments Share
10 |1000

Up to 8 attachments (including images) can be used with a maximum of 1.0 MiB each and 10.0 MiB total.

Tri avatar image Tri commented ·

This answer is golden. Learnt a lots of insight from the links you suggested.

@Erick Ramirez seriously, DataStax academy course materials should be reviewed/completed by you.

0 Likes 0 ·
Erick Ramirez avatar image Erick Ramirez ♦♦ Tri commented ·

Thanks, mate. I appreciate the feedback. Cheers!

0 Likes 0 ·