Inactive topics -- topics with no recent message activity -- still consume resources. Identify and delete these topics to reduce the amount of occupied resources on your ApsaraMQ for Kafka instance.
Identify inactive topics
Two metrics determine whether a topic is inactive:
| Metric | What it tells you | Inactive when |
|---|---|---|
TotalCount | Total number of messages stored on the broker for this topic | In most cases, value is 0 |
LastTimeStamp | Timestamp of the most recent message | In most cases, value points to a time long ago |
IfLastTimeStampis0or a negative value, the system has not retrieved the timestamp. Do not treat the topic as inactive in this case.
Check topic status in the console
Log on to the ApsaraMQ for Kafka console. In the left-side navigation pane, click Instances.
In the top navigation bar, select the region where the 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, then click the topic name.
On the Topic Details page, click the Partition Status tab.
Review the
TotalCountandLastTimeStampvalues. If the topic meets the inactive criteria in the preceding table, note the topic name for cleanup.
Check topic status through API operations
Use the following API operations to check activity across all topics at once.
Call GetTopicList to retrieve all topics on an instance.
Call GetTopicStatus for each topic to retrieve its messaging status.
In each response, check the
TotalCountandLastTimeStampfields against the criteria in the preceding table. Skip any topic whereLastTimeStampis0or negative, because the timestamp is unavailable.Record the names of all inactive topics for cleanup.
Delete an inactive topic
After you confirm that a topic is inactive and safe to remove, delete it from the console.
You must determine whether an inactive topic is to be deleted.
We recommend that you do not automate topic deletion through API operations. Programmatic errors may cause irreversible business losses.
Log on to the ApsaraMQ for Kafka console. In the left-side navigation pane, click Instances.
In the top navigation bar, select the region where the 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, then click the topic name.
In the upper-right corner of the Topic Details page, click Delete.
In the confirmation dialog, click OK.
Confirm the information before you delete a topic.