Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [mosquitto-dev] max system memory and mosquitto persistence file size limit

I am trying to limit memory consumed by mosquitto( in memory queue ).
The intention here is that, when running on low RAM devices ( say
512MB ), I would like mosuqitto to consume not more than half of
system memory( so as not to impact the system). Currently there is no
cap on the memory consumed by mosquitto broker.

There is a `max_queued_messages` configuration paramter. But that
limits by number of queued messages and not by memory consumption.

I assume using linux cgroups, will result in OOM killer terminating
mosquitto broker.

Is there any modification, I could do to mosquitto broker, so that I
could limit clients (publishing further messaging) by memory consumed?
Kindly suggest.

Thanks,
Kiran.

On 12/12/16, Roger Light <roger@xxxxxxxxxx> wrote:
> Hi Kiran,
>
>> 1. Mosquitto *always* maintains *all messages* in memory db.
>
> This is correct for current versions of mosquitto. It is unlikely that
> this will remain true for future versions.
>
>> 2. I would like to limit max memory used by mosquitto. I am planning
>> to do this enabling REAL_WITH_MEMORY_TRACKING in memory_mosq.c, and
>> returning NULL( ignoring errno ) from _mosquitto_*alloc, functions.
>> Any further clients requests to connect / publish will fail. Mosquitto
>> will gracefully continue to run mainloop. But client interactions will
>> be possible only after mosquitto frees some allocated memory with
>> _mosquitto_free ( possibly after a network connectivity restore ).
>
> That's an interesting idea. In principle I can see what you're trying
> to do, in practice I wouldn't want to guarantee that you'll get useful
> behaviour. For example, if the call in mosquitto_main_loop()
> allocating memory for the pollfds variable fails, the broker will
> exit.
>
> Regards,
>
> Roger
> _______________________________________________
> mosquitto-dev mailing list
> mosquitto-dev@xxxxxxxxxxx
> To change your delivery options, retrieve your password, or unsubscribe from
> this list, visit
> https://dev.eclipse.org/mailman/listinfo/mosquitto-dev
>


Back to the top