如何增加 MSMQ 中可存储的消息数量

发布于 2024-12-14 10:36:32 字数 342 浏览 8 评论 0原文

我们的系统中有许多 MSMQ 队列,包括私有队列和公共队列。有时,从队列读取的 Windows 服务会崩溃,因此消息会在该队列中堆积。一旦队列达到一定大小(可能是 60K 消息),该服务器上的所有队列将停止工作,并抛出有关资源不足的错误。

我的问题是,队列在幕后是如何真正工作的,它们是将消息存储在 RAM 中还是硬盘上?当服务器内存不足时,它是否会耗尽资源并崩溃?如果它使用硬盘驱动器上的一些分配空间,有没有办法增加允许的大小?如果使用 RAM,我可以简单地向服务器添加 RAM,然后增加允许的大小吗?

我需要确保当服务出现故障时,我们可以在修复服务的同时在该队列中存储 100K 或 200K 消息,因为这些消息对我们的业务至关重要。

We have a number of MSMQ queues throughout our system, both private and public queues. Sometimes a windows service that reads from a queue will crash, and so messages will build up in that queue. Once the queue gets to a certain size (maybe 60K messages), all queues on that server will stop working, throwing errors about insufficient resources.

My question is, how are the queues really working behind the scenes, are they storing messages in RAM or on the hard drive? Does it run out of resources and crash when the server runs out of RAM? If it's using some allocated space on the hard drive, is there a way to increase the allowable size? If it's using RAM, can I simply add RAM to the servers and then that will increase the allowable size?

I need to make sure that when a service goes down, we can handle storing 100K or 200K messages in that queue while we work on fixing the service, as those messages are critical to our business.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

泅人 2024-12-21 10:36:32

这是 MSDN 上的一篇文章,似乎解决了您的问题(正如 John 在下面指出的那样,这仅适用于 Windows Server 2000,因此大多数人可能会忽略): MSMQ 应用程序中的资源管理。具体来说:

对于 MSMQ 1.0 和 MSMQ 2.0,一台计算机上能够存储的消息的总大小不限于计算机中的 RAM 数量或硬盘大小,而是取决于提供的虚拟地址空间量由操作系统连接到 MSMQ 服务(MSMQ 3.0 中已取消此限制)。 x86 计算机中的每个进程都分配有 4 GB 的虚拟可寻址内存。保留 2GB 供内核模式使用,2GB 供用户模式使用。 MSMQ 队列管理器在用户模式下运行,因此具有可寻址的 2GB 虚拟地址空间可供使用。每条消息的数据都存储在 RAM 中,并由系统的分页文件或内存映射文件进行备份。 MSMQ 使用内存映射文件来存储快速消息和可恢复消息。由于我们的可寻址内存仅限于 2GB,因此磁盘上的消息也仅限于 2GB。当您考虑到 MSMQ 代码使用的内存及其内部数据结构,以及在磁盘上存储消息文件的文件分配时,我们最终会在磁盘上存储 1.4GB 到 1.6GB 的消息。< /p>

注意   通过在 MSMQ 服务上启用 3GB 调整,可以将 1.6GB 的限制提高到大约 2.6GB。有关如何启用 3GB 的详细信息,请参阅 Q171793调整。

编辑:调整链接似乎已损坏。我相信它应该指向此处

对于 MSMQ 的更高版本,John 在 一篇博客文章

最大消息数

这个问题并不那么容易解决。从我的资源不足帖子中我们知道,每条消息需要 75 字节的内核内存来进行索引,因此,例如,200 万条消息将需要大约 150 MB。因此,您所需要做的就是添加更多 RAM。不过,在比较了 32 位和 64 位内存架构之后,您很快就必须迁移到 64 位平台才能充分利用您的投资,因为 32 位计算机的分页池内存最大为 450 MB无论安装的 RAM 数量如何。

但是,如果您想计算出需要多少 RAM 来生成容纳 10 亿个 MSMQ 消息所需的分页池内存,那么您的设计规范需要进行一些认真的审查。

Here is an article on MSDN that seems to address your question (as John points out below, this only applies to Windows Server 2000 so should probably be ignored by most people): Resource management in MSMQ applications. Specifically:

For MSMQ 1.0 and MSMQ 2.0, the combined size of messages capable of being stored on one machine is not limited to the amount of RAM in the machine or the size of the hard disk, but to the amount of virtual address space provided to the MSMQ service by the operating system (this limitation has been lifted in MSMQ 3.0). Each process in an x86 machine is allotted a virtual 4 GB of addressable memory. 2GB is reserved for use in kernel mode and 2GB for user mode. The MSMQ Queue Manager operates in user mode and therefore has an addressable 2GB of virtual address space to work with. Each message's data is stored in RAM, which is backed up by the system's paging file or memory mapped files. MSMQ uses memory mapped files to store both express and recoverable messages. Since we are limited to 2GB of addressable memory, we are limited to 2GB worth of messages on a disk. When you take into account the memory utilized by MSMQ code and its internal data structures, as well as file allocation to store message files on disk, we end up with between 1.4GB and 1.6GB worth of messages that can be stored on disk.

Note   This limitation of 1.6GB can be raised to approximately 2.6GB by enabling 3GB tuning on the MSMQ Service. See Q171793 for more information on how to enable 3GB tuning.

Edit: the tuning link seems to be broken. I believe it should be pointing here.

In terms of later versions of MSMQ, John discusses the issue in a blog post.

Maximum number of messages

This one is not as simple to work out. From my Insufficient Resources post we know that each message needs 75 bytes of kernel memory for indexing so, for example, 2 million messsages would require roughly 150 megabytes. It would seem, therefore, that all you need to do is add more RAM. After looking at a comparison of 32-bit and 64-bit memory architectures, though, you will quickly have to move to the 64-bit platform to take advantage of your investment as 32-bit machines max out at 450 MB of paged pool memory regardless of the amount of RAM fitted.

But, again, if you are trying to work out what amount of RAM will generate the paged pool memory required to accommodate a billion MSMQ messages, your design spec is up for some serious reviewing.

心凉 2024-12-21 10:36:32

不确定深入的答案,但无论如何,从表面上看,非事务性队列将消息存储在内存中,而事务性队列将消息存储在磁盘上。

更新

正如 John 在下面所述,无论使用持久队列还是非持久队列,所有消息都保存在磁盘上。

Not sure about the in-depth answer, but on a surface level anyhow, a non-transactional queue stores messages in memory, whereas a transactional queue stores messages on disk.

UPDATE

As John states below, all messages are held on disk whether durable or non-durable queues are used.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文