9 best practices to reduce your AWS MSK (Apache Kafka) costs

Tal Shladovsky
March 14, 2023
2
min. read
Related Resource(s)

TL;DR

Amazon MSK provides a fully managed service for Apache Kafka. Here are 9 practices to reduce MSK costs on AWS including using auto-scaling, choosing the right AWS instance type, using provisioned storage, enabling compression and 5 more.

Amazon Managed Streaming for Apache Kafka (MSK) is a fully managed service that makes it easy to build and run applications that use Apache Kafka. However, like any cloud service, optimizing costs to get the most value for your money is essential.  

Here are 9 best practices to reduce your AWS MSK costs:

  1. Use Auto Scaling: AWS MSK allows you to automatically adjust the number of Kafka brokers based on your workload. By using AWS Auto Scaling for MSK, you can ensure that you only pay for the resources you need at any time.
  1. Choose the right AWS instance type: Choosing the right instance type for your workload is critical to optimizing costs. If your instance is too large, you may be paying for resources you don't need. If it is too small, you may experience performance issues.
  1. Use Provisioned Storage: AWS MSK offers two types of storage: EBS and Provisioned IOPS (PIOPS) EBS. Provisioned storage provides a guaranteed level of I/O performance, which can be important for high-throughput workloads. However, it comes at a higher cost than EBS storage. Choose the right storage type based on your workload requirements.  
  1. Enable compression: Kafka messages can be compressed to reduce the amount of data transmitted and stored, which can reduce costs. However, enabling compression on MSK can increase CPU usage, so monitor your CPU usage to ensure it remains within acceptable limits.
  1. Optimize network traffic: You can reduce traffic by batching and compressing messages before sending them. This can help reduce costs by reducing the amount of data transmitted.
  1. Use Custom Monitoring and Logging: AWS MSK provides built-in monitoring and logging capabilities, but they come at an extra cost. You can use your monitoring and logging tools to save costs or use the native monitoring such as disk space monitoring and memory monitoring capabilities.  
  1. Delete unnecessary topics: Kafka topics can consume storage space and increase costs. Delete any unnecessary topics to free up storage and reduce costs.
  1. Limit the retention period: Limiting the retention period of Kafka messages can reduce the amount of data stored and the associated storage costs. However, ensure your retention period is long enough to meet your business requirements.
  1. Use partition reassignment only when necessary: Partition reassignment is a powerful tool for load balancing, but it can also increase costs by creating additional network traffic. Use it only when necessary.

By following these 9 tips, you can optimize your AWS MSK costs and get the most value for your money. Remember to regularly review your usage and adjust as needed to ensure that you always get the best possible value from your AWS MSK instances.

Liked this post?

Read Stav's (co-founder & CTO @Lightlytics) blog post on Democratizing cloud costs.

Read Tal's hands-on guide series on AWS cost reduction:

Read the 10 best practices to reduce AWS EC2 costs.

Read the 10 best practices to reduce your AWS RDS costs.

What's new