Change oslo.messaging prefetch default

In some case, Ceilometer can consume To of RAM. If batch is not enabled
the default behavior is to fetch all messages waiting in the queue.

Since I fail to change/expose this bad oslo.messaging default for us.
This change set a correct default on our side.

Change-Id: I3f4b0ef5fa90afb965e31584b34fdc30a5f4f9f1
This commit is contained in:
Mehdi Abaakouk 2017-11-15 10:41:46 +01:00
parent 124297b283
commit d208a7117a

@ -13,7 +13,9 @@
# License for the specific language governing permissions and limitations
# under the License.
from oslo_config import cfg
import oslo_messaging
from oslo_messaging._drivers import impl_rabbit
from oslo_messaging.notify import notifier
from oslo_messaging import serializer as oslo_serializer
@ -23,6 +25,19 @@ TRANSPORTS = {}
def setup():
oslo_messaging.set_transport_defaults('ceilometer')
# NOTE(sileht): When batch is not enabled, oslo.messaging read all messages
# in the queue and can consume a lot of memory, that works for rpc because
# you never have a lot of message, but sucks for notification. The
# default is not changeable on oslo.messaging side. And we can't expose
# this option to set set_transport_defaults because it a driver option.
# 100 allow to prefetch a lot of messages but limit memory to 1G per
# workers in worst case (~ 1M Nova notification)
# And even driver options are located in private module, this is not going
# to break soon.
cfg.set_defaults(
impl_rabbit.rabbit_opts,
rabbit_qos_prefetch_count=100,
)
def get_transport(conf, url=None, optional=False, cache=True):