If exceptions such as message accumulation, data skew, and traffic throttling occur on an ApsaraMQ for Kafka instance, you can view the subscriptions between groups and topics and check the consumer progress of each partition and the total number of accumulated messages in each topic. This helps you adjust your business at the earliest opportunity and prevent potential risks.
Usage notes
We recommend that each group subscribes to no more than three topics to prevent message accumulation.
If you use the
assign
mode to consume messages, you must manually commit the consumer offset at the earliest opportunity to prevent the accumulation of consumed messages due to an uncommitted offset.If a large number of messages are accumulated, check the message consumption and production rates. If the message consumption rate is lower than the message production rate, we recommend that you improve the consumption capacity of consumers to resolve the issue.
View consumer groups that subscribe to a topic
Log on to the ApsaraMQ for Kafka console. In the Resource Distribution section of the Overview page, select the region where the ApsaraMQ for Kafka instance that you want to manage resides.
On the Instances page, click the name of the instance that you want to manage.
In the left-side navigation pane, click Topics.
On the Topics page, find the topic that you want to manage and choose in the Actions column.
On the Subscriptions tab of the Topic Details page, all groups that subscribe to the topic are displayed.
In the Online groups that subscribe to the topic section, find the group that you want to manage and click Consumer Details in the Actions column.
On the Consumer Details page, the consumer details of the group in each partition of the topic are displayed. The following table describes the parameters.
Parameter
Description
Partition ID
The partition ID.
Client
The ID of the connected consumer that subscribes to the topic.
NoteThe value is in the
<Client ID>_/<IP address>
format.You cannot view the IDs of disconnected consumers.
Maximum Offset
The maximum offset from which messages can be consumed in the partition.
Consumer Offset
The offset from which messages are consumed in the partition.
Messages Accumulated
The total number of messages that are accumulated in the partition. The value is equal to the maximum offset minus the consumer offset.
ImportantThis parameter is a key metric. If a large number of messages are accumulated, consumers may be blocked or the consumption rate cannot keep up with the production rate. In this case, you must analyze the status of consumers and improve the consumption rate. For more information, see Reset consumer offsets.
View topics to which a group subscribes
On the Instances page, click the name of the instance that you want to manage.
In the left-side navigation pane, click Groups.
On the Groups page, find the group that you want to manage and choose in the Actions column.
On the Consumer Status tab of the Group Details page, all topics to which the group subscribes and the accumulated messages in each topic are displayed.
In the Topic column, find the topic that you want to manage and click Consumer Details in the Actions column.
On the Consumer Details page, the consumer details of the group in each partition of the corresponding topic are displayed.
For more information about the parameters, see the preceding section.
FAQ
Why is message consumption in the downstream application unaffected by message accumulation in an ApsaraMQ for Kafka partition?
The assign
mode may be adopted by the downstream application to consume messages. In this mode, you manage the offsets. In this case, messages may be consumed. The messages are displayed as accumulated due to an uncommitted offset. We recommend that you manually commit offsets at the earliest opportunity to resolve the message accumulation issue.
How do I improve the consumption capacity of consumers if messages are accumulated because the message consumption rate is lower than the message production rate?
You can use one of the following methods to improve the consumption capacity of consumers:
Increase the number of consumers. You can add consumers in a process and make sure that each consumer corresponds to one thread. Alternatively, you can deploy multiple consumer processes. If the number of consumers exceeds the number of partitions, the consumption rate cannot be increased. Otherwise, specific consumers become idle.
Increase the number of consumption threads. For more information, see Increase consumption rate.
Does message accumulation indicate issues in the system?
No. Message accumulation indicates different things based on the situation:
If the most recent consumption time is close to the current time and the number of accumulated messages fluctuates within an expected stable range, the client is pulling new messages. In this case, message accumulation is normal.
If the number of accumulated messages gradually increases and the consumer offset remains unchanged, the consumer thread on the client is blocked, and the client stops consuming messages and committing consumer offsets to the broker. In this case, message accumulation is abnormal.
For more information, see What do I do if messages are accumulated when I use ApsaraMQ for Kafka?.
References
For information about how to call the corresponding API operation to query consumer details, see GetConsumerProgress.
If you do not want to handle accumulated messages, you can skip the accumulated messages by resetting the consumer offset. For more information, see Reset consumer offsets.