7

As suggested in another question, we have added destination path as db and autosave_interval as 3000, but after few days memory is getting reducing automatically.

Please let me know if there is any other solution to store in only db file.

  • Even if you can persist messages on the hard drive, doing so indefinitely will at some point fill your disk. Have you considered letting those messages expire? (not sure if mosquitto provides such a thing). – bgusach Jun 5 '18 at 6:48
4

The mosquitto broker does not support offloading the persistence store to an external database and the db file is just a backup of the in memory database in case the broker crashes or is shutdown.

If you have large numbers of messages queued for offline clients or large numbers of large retained messages then memory will be consumed.

The best you can do is set the persistent_client_expiration option to remove queued messages for clients that have not logged on for a long time. Details of this option can be found in the mosquitto.conf man page.

Otherwise you will need to look at using a different broker that supports out of process storing of the persistence database. Something like mosca can be configured to use mongo or redis as a backing store.

  • Currently persitent_client_expiration is 1hour but still memory consumed. – bhuva nesh Jun 7 '18 at 6:26
  • Then the memory growth is probably not down to queued messages for offline clients. – hardillb Jun 7 '18 at 6:48
  • Is there any way to clean retained messages manually? – bhuva nesh Jun 8 '18 at 4:21
  • Not without stopping the broker, deleting the db file and restarting or publishing a null payload to the topic (with the retained flag set) – hardillb Jun 8 '18 at 7:09

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.