Optimizing battery usage on mobile devices for MongoDB Client

Hello there,

this question comes from an absolute beginner with Mongo and I hope anyone can help me understand a little bit more about what’s going on.

I’m currently developing a mobile application in C# that is constantly running in the background and uploads very little information every few minutes using the MongoDB Client.
I noticed when working with mobile data, the application consumes a significant amount of battery power over time (roughly 3% per hour, which is not acceptable for a 24/7 app).
And yes, I’m absolutly sure that this is caused by the MongoDB Client.

Now I was experimenting with different settings for the client (increasing the HeartbeatInterval, using really short or really long lifespans for connections), but it seems to make no difference.
Coming to the real question:
How could I change the settings of the client to have the least possible amount of network activity over time, only one upload every few minutes? I feel like it should be a constantly open connection that is idle for most of the time, but so far I’m not satisfied with my results.

I really hope that anyone has some tips for me!
Thanks a lot in advance!

this is a thing for mobile platform, not for a specific database client. there’s isn’t much you can do apart from tuning the basic config (e.g. number of min connections in the pool)

on android, you can check Battery consumption for billions  |  Build for Billions  |  Android Developers

for ios, similar should exist.

1 Like

Thanks a lot for the link, I will take a deeper look into the platform optimizations.
The reason I ask about the database client is that even when I disable the upload function, when the client is only existing without anything to do, it constantly uses mobile data and therefore battery power. It takes roughly 0.01 MB every few seconds. That’s not much, but enough to keep the mobile connection active.
It seems like open connections in the pool are doing this and I don’t know how to stop that without closing the connections.

Long live connections generally use heartbeat for various reasons (e.g. check server responsiveness).

On android, you only connect to remote network when necessary (during an allowed window etc), so outside of that necessary time window, you can simply clear all the connections as they can’t do anything but consuming powers.

There are a lot of features/utilities on android regarding when/how to access network. or when to keep the device “awake”. Check it out.