← Back to Calculator

Kafka Retention Calculator Documentation

A minimalist web application for calculating optimal retention.bytes settings for Kafka topics based on your storage configuration and topic specifications.

Features

Storage Configuration
Input your Kubernetes storage setup (PVCs, storage size)
Topic Management
Add multiple topics with custom partition and replication settings
Real-time Calculations
Instant retention calculations as you modify inputs
Topic Weighting
Prioritize topics with custom weight allocation (1-100%)
Comprehensive Results
Detailed retention settings with storage utilization metrics
Responsive Design
Works seamlessly on desktop and mobile devices

How It Works

The calculator determines optimal retention.bytes settings by:

  1. Calculating Total Storage: Multiplies PVC count by PVC size to determine total available storage
  2. Applying Kafka Overhead: Reserves configurable percentage of total storage for Kafka internal operations, log segments, and system files
  3. Weighted Storage Distribution: Allocates remaining storage based on topic weights and partitions
  4. Accounting for Replication: Adjusts retention based on replication factor requirements
  5. Providing Metrics: Shows storage utilization, retention per partition, and summary statistics

Retention Time Calculation (Beta)

When you provide event size and volume information, the calculator can estimate how long data will be retained based on your storage configuration.

Important Notes:

Example:

If you have 400,000 events per second with 1KB event size, replication factor 2, and 2,400GB of storage allocated to a topic, the retention time would be approximately 50 minutes.

Usage

1. Storage Configuration

2. Topic Configuration

For each topic, specify:

3. Results

The application provides:

Example Configuration

Storage Setup:

Topic Setup:

Result:

Getting Started

  1. Open index.html in your web browser
  2. Configure your storage settings
  3. Add your Kafka topics with appropriate weights
  4. View the calculated retention settings
  5. Use the retention.bytes values (in bytes) in your Kafka topic configurations

Technical Details

Calculation Formula

Total Storage = PVC Count × PVC Size (GB)
Available Storage = Total Storage × 0.8 (20% overhead reserved for Kafka)
Weighted Storage per Topic = Available Storage × (Topic Weight / Total Weight)
Storage per Partition = Weighted Storage per Topic / Topic Partitions
Retention per Partition = Storage per Partition / Replication Factor
Retention Bytes = Retention per Partition × 1024³

Browser Compatibility

File Structure

kafka-kalkulator/
├── index.html          # Main application page
├── readme.html         # This documentation page
├── styles.css          # Styling and responsive design
├── script.js           # Calculation logic and interactivity
├── README.md           # GitHub documentation
├── LICENSE             # MIT License
└── package.json        # Project metadata

Contributing

This is a simple, single-page application designed for Kafka administrators. Feel free to fork and modify for your specific needs.

License

MIT License - feel free to use and modify as needed. See the LICENSE file for details.