nginx-push-stream-module icon indicating copy to clipboard operation
nginx-push-stream-module copied to clipboard

Purge old messages when out of memory

Open AlexeyKupershtokh opened this issue 11 years ago • 3 comments
trafficstars

Hello.

As I can see in the push_stream_shared_memory_size description:

The size of the memory chunk this module will use to store published messages, channels and other shared structures. When this memory is full any new request for publish a message or subscribe a channel will receive an 500 Internal Server Error response.

What is supposed to do when you get 500 trying to publish a mesasge?

I would prefer to have another option of the module behavior. I think it should (optionally) free memory when it needs more by freeing old messages. This way push_stream_message_ttl would have logic more like "try to keep messages for push_stream_message_ttl but can also delete them earlier".

E.g. this policy is available in Redis ( http://oldblog.antirez.com/post/redis-as-LRU-cache.html ):

Another way to use Redis as a cache is the maxmemory directive, a feature that allows specifying a maximum amount of memory to use. When new data is added to the server, and the memory limit was already reached, the server will remove some old data deleting a volatile key, that is, a key with an EXPIRE (a timeout) set, even if the key is still far from expiring automatically.

What do you think?

AlexeyKupershtokh avatar Jan 30 '14 04:01 AlexeyKupershtokh

Hello @wandenberg @AlexeyKupershtokh! +1

joaoafrmartins avatar Feb 27 '14 03:02 joaoafrmartins

It's a must have.

Some API to delete stored messages will be great too, but it's more advanced feature, so just freeing memory as needed will be ok.

misiek08 avatar Sep 29 '15 00:09 misiek08

yes please. would be tremendously useful in my current setup.

tomquas avatar Sep 29 '15 07:09 tomquas