This is a follow up task for the:Consumer threading refactor design

Objective

To ensure that our new Kafka consumer is robust, performant, and scalable by rigorously testing its capabilities in various scenarios, including different message sizes, numbers, consumer counts, and CPU throttling conditions.

Scope

  1. Consumption Rate

  2. CPU Throttling

  3. Special Scenarios

Performance Testing Strategy

Setup

Consumption Rate

  1. Varying Message Sizes: Measure the rate of message consumption across different message sizes.

  2. Varying Message Numbers: Measure how well the consumer handles varying amounts of messages.

  1. No Throttling: Baseline performance metrics.

  2. 50% and 75% Throttling: Simulate CPU constraint scenarios.

Special Scenarios

  1. High Deserialization CPU Cost: Simulate a high-CPU cost deserialization algorithm.

  2. Schema Registry: Measure the impact of using a schema registry for deserialization.

Stochastic Testing Strategy

Goal

We need to deterministically emulate all possible real-world usage of the async consumer.  Despite integration testing and unit testing cover some aspect of it, I think it is necessary for us to try to generate a large number of usage patterns and verify the consequence of these actions.  For example - offsetComit follows by consumer.subscribe should yield nothing because the consumer has not made any progress.  Consumer poll should trigger auto commit and we need to verify that the previously return data was committed to the coordinator.

The goal is to simulate a series of events in pseudo-randomly and verify the outcome of each action.  If an unexpected result is detected, we should be able to retrieve the sequence of actions so that we can debug the issue.

Components

A random action/sequence generator: We should generate the next action based on the current state of the consumer by probability.

State tracker: We record the state of the consumer and predict the consequence of the following action.

A sequence logger: The actions are logged into a sequence of events, chronologically so that we can always reproduce the actions.

Response simulator: Based on the request sent from the client, we pseudo-randomlly generate responses for a given request.  Each response can be branched into a separate consumer state for testing.