limit the max count of messages in client