使用NServiceBus处理消息时,MSMQ占用大量内存 [英] MSMQ consuming large amounts of memory when processing messages with NServiceBus

查看:118
本文介绍了使用NServiceBus处理消息时,MSMQ占用大量内存的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有两个使用NserviceBus的Windows服务.一个将消息写入队列,另一个从中读取消息并进行一些处理.所有队列都是事务性队列,并且NserviceBus端点配置如下.

I have two windows services which use NserviceBus. One writes messages to the queue and the other reads from it and do some processing. All the queues are transactional and the NserviceBus endpoints are configured as below.

.IsTransactional(true)
.IsolationLevel(IsolationLevel.ReadCommitted)
.MsmqTransport()
.RunTimeoutManager()
.UseInMemoryTimeoutPersister()
.MsmqSubscriptionStorage()
.DisableRavenInstall()
.JsonSerializer()

问题是当大量消息(170,000+)排队时,MSMQ服务(mqsvc.exe)占用了相当多的内存(1.5-2.0 GB),并且该内存至少没有释放5-6小时.平均邮件大小约为5-10 KB.而且似乎您排队的消息越多,它使用的内存就越多.基于NServiceBus的Windows Services内存消耗处于完全可接受的范围内(50-100 MB),并且无论它们处理多少消息都不会增加.

The issue is when a large amount of messages (170,000+) are queued, MSMQ service (mqsvc.exe) chews up quite a bit of memory (1.5 - 2.0 GB) and that memory doesn't get released for at least 5 - 6 hours. The average message size is around 5 - 10 KB. And it seems like the more messages you queue the more memory it uses. The NServiceBus based Windows Services memory consumption are in perfectly acceptable limits (50 - 100 MB) and do not increase no matter how many messages they process.

关于MSMQ为什么要使用这么多的内存并且要花很长时间才能发布的任何想法? 谢谢你堆.

Any ideas on why MSMQ would use this much memory and takes quite long to release it? Thanks heaps.

推荐答案

这是完全正常的. MSMQ使用4MB内存块中的存储空间,这些内存块映射到存储"文件夹中的文件. 170,000条消息(每条5-10kb)为0.85-1.7GB,因此,看到如此多的虚拟内存分配不足为奇.为了减少删除或到达邮件时删除和创建文件的开销,将存储文件保留6小时.在此期间之后,将删除空文件.您可以配置它,如我的博客文章中所述:

This is perfectly normal. MSMQ uses storage in 4MB blocks of memory which map to the files in the Storage folder. 170,000 messages at 5-10kb each is 0.85-1.7GB so no surprise you're seeing so much virtual memory being allocated. To reduce the overhead of deleting and creating files as messages are removed or arrive, the storage files are kept for 6 hours. After this period, the empty files are deleted. You can configure this, as discussed in my blog post:

强制MSMQ清理其存储文件

这篇关于使用NServiceBus处理消息时,MSMQ占用大量内存的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆