|
Startup script to set jvm memory
if "% ACTIVEMQ_OPTS%" == "" set ACTIVEMQ_OPTS = -Xms1G-Xmx1G -Djava.util.logging.config.file = logging.properties
The amount of system memory and disk space usage broker configuration
< SystemUsage>
< SystemUsage>
< MemoryUsage>
< MemoryUsagelimit = "64 mb" />
< / MemoryUsage>
< StoreUsage>
< StoreUsagelimit = "100 gb" />
< / StoreUsage>
< TempUsage>
< TempUsagelimit = "50 gb" />
< / TempUsage>
< / SystemUsage>
< / SystemUsage>
If it is embedded (embedded) manner, it can be added to new a SystemUsage BrokerService go. MemoryUsage configured here must be less than the number jvm set.
5.9.0 version, memoryUsagelimit If greater than the actual value of the available java heap size, such as the default start xmx = 1G, then the actual java heap size is about 910M,
When the broker starts up log.error prompted to set the memory error, and then forced to use actual java heap size * 70% = 637M as memoryUsagelimit.
splitSystemUsageForProducersConsumers not even lead to slow consumer spending problem
In fact, broker can also be configured individually consumerSystemUsage producerSystemUsage producers and consumers to use use the same format with systeUsage.
By default, no producerSystemUsage and consumerSystemUsage, the producers and consumers to use systemUsage.
Then it may be because the producer thread runs out of memory, leading consumers to threading issues can not even slow consumption. In this case, add the consumption side of the machine and the number of consumers might not increase the rate of consumption.
The solution is:
Setting splitSystemUsageForProducersConsumers on broker = "true", so that the producer and consumer threads each thread using each memory.
The default is the producer thread Memory: Memory consumer thread = 6: 4.
You may be provided by the following two parameters for each half of the producer and consumer threads thread memory Memory:
producerSystemUsagePortion = 50
consumerSystemUsagePortion = 50
Producer flow control
Starting from version 5.x, you can set the flow control to each producer individually. Flow control simply means that control the behavior of producers in the memory usage limits. Of course, the flow control aims to prevent the MQ explode when used as ActiveMQ when the memory MQ, the production rate is greater than the rate of consumption issues.
In two cases:
1, send a message synchronously (useAsynSend to false): The under SystemUsage limited use destinationPolicy the policyEntry of restrictions, such as:
< DestinationPolicy>
< PolicyMap>
< PolicyEntries>
< PolicyEntry queue = "queueA" producerFlowControl = "true" memoryLimit = "1mb">
< PendingQueuePolicy>
< VmQueueCursor />
< / PendingQueuePolicy>
< / PolicyEntry>
< / PolicyEntries>
< / PolicyMap>
< / DestinationPolicy>
When the memory usage limit for non-persistent queueA 1mb, directly blocking out producer reached the amount of memory used until a spare memory, the producer is allowed to send a message.
Also by setting sendFailIfNoSpace on systemUsage Configuration = "true" or sendFailIfNoSpaceAfterTimeout = "3000" to control the client and abnormal latency.
Asynchronous transmission because they do not clog producers,
By connctionFactory.setProducerWindowSize (1024000);
To control the maximum amount of data broker confirmation (byte) before receiving the message producer can send.
Consumer Flow Control
Consumer side, the sooner the better general consumption, broker backlog as small as possible.
However, taking into account the transaction and confirm the client, if a consumer to get a lot of information but do not confirm, this transaction will result in larger context, broker end of this "half-consumption status" of data increases, so ActiveMQ there is a parameter to control prefetchSize unconfirmed case, the maximum number of records to prefetch.
By default, as follows:
Persistent queue: 1000 Tiao
Non-persistent queue: 1000 Tiao
Persistence topic: 100 Tiao
Non-persistent topic: Unlimited
You can set prefetchSize way through 3
1, tcp: // localhost:? 61616 jms.prefetchPolicy.all = 50
2, tcp: // localhost: 61616 jms.prefetchPolicy.queuePrefetch = 1?
3, queue = new ActiveMQQueue ( "TEST.QUEUE consumer.prefetchSize = 10?"); |
|
|
|