Looking for reviews on MSK in production

Hi!

Working at an early stage startup and we currently run a home-baked Kafka setup on EC2. Long story short… it’s a real pain.

I’m hoping to migrate our existing Kafka infrastructure to MSK so that we don’t have to worry about Kafka scaling / management and instead focus our resources on business problems.

I’m wondering if anyone has reviews on running MSK in production. Any pain points? Cost considerations? Scaling issues? I know a lot of people were annoyed that you couldn’t update the broker size after the cluster was created, but it seems that it is now a feature of MSK.

Tried finding some medium articles on experiences, but can only find articles from when it was in beta.

Thanks!

MSK would be my last option to run prod workloads as there are lot of limitations vs other Kafka implementations. Mainly from the monitoring standpoint, they don’t expose all the metrics like consumer lag etc, which are really helpful when running prod workloads. I would recommend Aiven/ confluent Kafka instead

I’ve been using it for production workloads for the past year. To me, it’s way better than doing it home-baked on ec2s. They have a sizing calculator that takes the guesswork out of picking the broker instance/number of brokers to some degree, but note the caveat “this spreadsheet was the result of running a test workload with three producers and three consumers”. That doesn’t resemble our workload at all, so we need many more brokers to handle the added load from additional producer/consumer connections.

Things I wish they had:

  • The broker dns names are auto-generated, so if you create a new cluster (e.g., to change instance type), you get new names. If you have a bunch of consumers/producers, this can involve a lot of extra communication/confusion about “which brokers should i be using”. I’m not really sure how they could do it (we’re using NLBs that have persistent DNS names to direct producers/consumers to the active cluster; presumably there are more intelligent ways).
  • Ability to choose the maintenance window time. While the rolling reboot required to patch the brokers shouldn’t impact the workload if replication/etc is correctly configured, on the off chance that it does, it sucks if it ruins your weekend…
  • PCA is expensive. But it’s also easy (i.e., there are other options, but I haven’t had a chance to explore them.).

So, if choosing a non-AWS alternative is not an option for you (it’s not for us), I would definitely recommend it.

It works well, but you’ll pay well for it also.

In my last company, it was cheaper to roll our own on AWS, and maintain it, than use MSK.

We ran a “2.5” stretch cluster - 2 AZs, 3 brokers in each AZ, 2 ZKs in each AZ, and a single ZK in a 3rd AZ to maintain quorum if we lost an AZ. It was handling 30 TB or so of data a day (before compression), and our biggest topic was receiving 45MB/s at peak, IIRC.

MSK has some definite limitations - you can only configure a subset of broker properties, you can’t SSH into brokers and do terrible things to logs if needed (rare, but it does become handy at times), etc. I’m unsure if you can set a topic to have a replica count lower than the hard-coded MSK “num.replicas = number of AZs” but I know you can’t change that property on the broker level.

On the cost front, while MSK’s pricing includes inter-broker replication traffic for free, if you’re running it across 3 AZs (the default, other option is 2 AZs, but given how MSK works, if you lose an AZ you’ll lose ZK quorum and your cluster is broken), your applications producing and consuming from it will incur significant inter-AZ traffic costs.

In terms of scaling, MSK can increase your storage size automatically, but once increased, it can’t be decreased. If you need to add another broker, it’s still manual, but it’s just clicking a button or running a single CLI command.

I’m curious what your scaling issues were? We might be able to help you get your current cluster humming over in /r/apachekafka :slight_smile: Some general tips:

  1. Use rack (AZ) awareness to ensure Kafka is distributing leaders evenly across racks.
  2. Use rack-aware consuming so that consumers in AZ A can consumer from in-sync replicas (ISRs) in their own AZ to reduce inter-AZ traffic costs.
  3. Make sure that your `num.replicas` and `min.insync.replicas` are configured so that losing an AZ doesn’t drop your topic partitions below min-ISR - MSK’s defaults generally manage this - unless you’re running a 2-AZ cluster then the default value of minISR (2) will bork you, but as I mentioned earlier, due to ZK quorum requiring a majority of members remaining, losing an AZ will bork you anyway. Also be aware that having minISR = num.replicas can cause temporary issues, as sometimes a replica may be out of sync for a bit under heavy load scenarios. So definitely keep minISR at num.replicas - 1, at least.
  4. Use Cruise Control to ensure that replicas are distributed across racks/AZs so that rack-aware consumers can be fully utilised. MSK now supports Cruise Control, which is nice.
  5. You can often avoid having to scale a cluster by tuning your producers, and to a lesser extent, consumers, to minimise load on the cluster. Critical producer properties in this area are `linger.ms`, and `batch.size` - the fewer batches a producer sends to the cluster, the better for cluster load.
  6. Also, consider using compression to reduce size on disk.
  7. Make sure your partition counts for topics are actually relevant - partition count generally limits the number of concurrent consumers in one consumer group - a topic with 20 partitions means 20 concurrent consumers in one consumer group. If you have 100 partitions for a topic only consumed by 50 concurrent consumers in a group, you’re increasing overhead on your brokers unnecessarily. It’s always possible to add more partitions later (assuming you’re not relying on absolute ordering based on message key), but removing partitions requires deleting a topic and recreating it - or as I prefer, creating a new topic, migrating producers first, and then consumers to it (consumers can consume multiple topics, which is a nice way to migrate topics), and then dropping an old topic, so as to avoid data loss.

HTH, and as I said, if you have any further questions, come join us at /r/apachekafka, we’ve got members from Aiven, Confluent, Red Hat etc. who can help :slight_smile:

It’s come a long way in the last year. I have run production workloads on it, and it’s nice not having to worry about as much as rolling your own. Confluent’s offering still is a bit head, but also more costly (in our use case anyway, by quite a bit).

The main thing with scaling that I don’t think has been fixed yet is once you scale up the number of nodes, you can’t scale it back down - where you can scale up or down the broker node size, as long as it doesn’t exceed the partitions per broker recommendations by downsizing.

For the comment saying they don’t expose all the metrics, such as being unable to monitor consumer lag - you can, by calculating it from the component metrics that are provided, such as EstimatedMaxTimeLag. There are way more metrics available for it now, than there were a while back.

They support ways of exposing consumer lag now :slight_smile: https://docs.aws.amazon.com/msk/latest/developerguide/consumer-lag.html

“fuck no”.

if you need kafka, pay confluent for it. you can not, for example, upgrade MSK.

presumably it’s changed since you used it. there’s an upgrade button in the gui…

You can definitely do upgrades

ah they added it last year after several years of being shitty

You can scale it down since January - https://aws.amazon.com/about-aws/whats-new/2021/01/amazon-msk-now-supports-the-ability-to-change-the-size-or-family/

can understand your feelings toward it since that’s a pretty basic feature… but since we’re stuck in aws, it’s better than nothing

oh i love AWS. i just think their random services on the periphery are not as good.

i think i’d still go with confluent absent a good reason, like data transfer.

I spent some time working with MSK over the past year and it’s come a long way. I’ve run Kafka at scale in another role (dozens of brokers) and until this year I wouldn’t have said it’s ready for any real prod work. But with the ability to resize clusters, connections to DMS, Lambda, with automatic upgrades, easy support for metrics from Prometheus, I think everything is there to use it in prod.

I would, however, suggest you look at why you need Kafka, and why something like SQS won’t work for you. Kafka is amazing - it love it and the community and Confluent and everything Kafka has done to move technology and architecture forward - but it’s still a beast to get right.

If you’re a small startup it’s better to focus your engineering efforts on features that get you customers/money, so sinking more time and energy into Kafka may not be the right road for you.

If you are going to stick with Kafka and pick msk, I would strongly suggest you reach out to your account team and tell them you want a product roadmap review. See what features are coming, you may save yourself a lot of work if something you need is going to be released like tomorrow.

Yes, but you can’t scale down the quantity. If you up from, say, 3 brokers to 6 (it has to be a multiple of the AZs you deploy in), you can’t reduce back to 3. Yet.

MSK sucked until about a year ago, when it began to be decent. You can do rolling upgrades now, and resize the broker instance types.

For the comment saying they don’t expose all the metrics, such as being unable to monitor consumer lag - you can, by calculating it from the component metrics that are provided, such as EstimatedMaxTimeLag. There are way more metrics available for it now, than there were a while back.

You don’t even have to calculate it, they give it to you if you enable per-topic, per-partition monitoring. It ends up costing a few bucks a month in CloudWatch metrics but it’s negligible compared to the cost of running the cluster. You can even enable open monitoring for Prometheus and turn on the JMX and node exporters so you don’t have to subject yourself to CloudWatch.

Do that and you’ll have all the metrics you could possibly care about. On my team, we scrape the exporters with an ephemeral Prometheus deployment that we use to apply our own recording rules, then forward to AMP. We were shipping so many samples that the AMP bill outpaced the MSK bill and we had to be very selective about which metrics we actually cared about.

I think it’s great most of time, but there are still a few gotchas. My current issues with it are:

  • Inflexible (albeit punctual) maintenance windows, and because of this
  • lack of failover support
  • lack of HEY THIS IS THE MAINTENANCE WINDOW interface hints

When the backbone of your event-sourced architecture goes down for an immovable maintenance window, you’re gonna have a bad time.

Have you looked into Red Panda as a possible alternative? https://vectorized.io/redpanda/

I wouldn’t recommend it, really, in one year we’ve had two outages caused by hardware failures in MSK underlying infrastructure that weren’t detected or fixed automatically by AWS until a few days of manual troubleshooting by their support team. We haven’t had this type of issue with any other AWS service.