DEV Community

Alexander Savinykh
Alexander Savinykh

Posted on

Beware of MongoDB network compression

Recently I encountered a weird problem while working on my paid customer's project.

We have a Java service app which does basically nothing more than accept incoming data from remote senders and save the data in a time series database. Meanwhile, MongoDB is used to store related metadata, such as the list of data sources and access tokens. The Java service checks if the sender is authorized through a MongoDB collection with access tokens and then sends time series values to a different database.

The problem is, enabling MongoDB compression tripled our random access memory usage of the Java service app.

  • Compression=Off: using 1 GB of RAM and 50% CPU
  • Compression=On: using 3 GB of RAM and 100% CPU

All the excessive memory gets allocated in native, outside of Java heap, so the heap limit does not restrict this excessive memory usage

Overall, the fact that the CPU and memory both went up is not a big surprise by itself, but the sheer factor by how much they went up feels a bit much.

Triple memory usage for MongoDB compression on client side? β˜•πŸ€”πŸšΏ

Top comments (0)