{"id":633,"date":"2018-06-07T03:54:44","date_gmt":"2018-06-07T03:54:44","guid":{"rendered":"http:\/\/99techpost.com\/?p=633"},"modified":"2018-06-08T04:07:19","modified_gmt":"2018-06-08T04:07:19","slug":"5-tips-and-tricks-for-managing-kafka","status":"publish","type":"post","link":"https:\/\/www.99techpost.com\/5-tips-and-tricks-for-managing-kafka\/","title":{"rendered":"5 Tips and Tricks for Managing Kafka"},"content":{"rendered":"<p><strong>What is Kafka? <\/strong><a href=\"https:\/\/www.instaclustr.com\/solutions\/managed-apache-kafka\/\" rel=\"external nofollow\" target=\"_blank\">Apache Kafka<\/a> is an open source project providing powerful distributed processing of continuous data streams \u2013 and is currently trusted in production by thousands of <a href=\"https:\/\/kafka.apache.org\/powered-by\" target=\"_blank\" rel=\"nofollow\">enterprises<\/a> globally including the likes of Netflix, Twitter, Spotify, Uber and more.<\/p>\n<p>The technology architecture and implementation makes it highly reliable and highly available, enabling stream processing applications to utilise geographically distributed data streams.\u00a0 While Kafka is not difficult to use, it\u2019s tricky to optimise.<\/p>\n<p>Here are our first 5 tips and tricks that will help you perfect your Kafka system to get ahead!<\/p>\n<ol>\n<li><strong> Logs:<\/strong><\/li>\n<\/ol>\n<p>Kafka has a lot of log configuration. The defaults are generally sane but most users will have at least a few things they will need to tweak for their particular use case. You need to think about retention on policy, clean ups, compaction, and compression.<\/p>\n<ol start=\"2\">\n<li><strong> Hardware Requirements:<\/strong><\/li>\n<\/ol>\n<p>When tech teams start playing with Kafka there is a tendency to just sort of \u2018ballpark\u2019 the hardware &#8211; just spin up a big server and hope it works. Kafka does not necessarily need a ton of resources. It is designed for horizontal scaling thus you can get away with using relatively cheap commodity hardware.<\/p>\n<p><strong>CPU<\/strong><strong>: <\/strong>Doesn\u2019t need to be very powerful unless you\u2019re using SSL and compressing logs. The more cores, the better for parallelisation. If you do need compression we recommend using LZ4 codec for best performance in most cases.<\/p>\n<p><strong>Memory:<\/strong>Kafka works best when it has at least 6 GB of memory for heap space. The rest will go to OS page cache which is key for client throughput. Kafka can run with less RAM, but don\u2019t expect it to handle much load. For heavy production on use cases go for at least 32 GB.<\/p>\n<p><strong>Disk: <\/strong>Because of Kafka\u2019s sequential disk I\/O paradigm SSD\u2019s will not offer much benefit. Do not use NAS. Multiple drives in a RAID setup can work well.<\/p>\n<p><strong>Network and File system:<\/strong>Use XFS and keep your cluster in a single datacentre if possible. The higher the network bandwidth the better.<\/p>\n<ol start=\"3\">\n<li><strong> Zookeeper:<\/strong><\/li>\n<\/ol>\n<p>We could do an entire article just on ZooKeeper. It is a versatile piece of software that works great for both service discovery and a range of distributed configuration on use cases.<\/p>\n<ul>\n<li><strong> Avoid co-locating ZooKeeper in any major production environment <\/strong><\/li>\n<\/ul>\n<p>This is a shortcut many companies take thanks to the spread of Docker.. This is fine for a development environments or even smaller production on deployments assuming you take the right precautions. The risk with larger systems is that you lose more of your infrastructure if a single server goes down. It\u2019s also suboptimal for your security setup because Kafka and ZooKeeper are likely going to have a very different set of clients and you will not be able to isolate them as well.<\/p>\n<ul>\n<li><strong> Do not use more than five ZooKeeper nodes without a really great reason <\/strong><\/li>\n<\/ul>\n<p>For a dev environment, one node is fine. For your staging environment you should use the same number of nodes as production. In general three ZooKeeper nodes will suffice for a typical Kafka cluster. If you have a very large Kafka deployment, it may be worth going to five ZooKeeper nodes to improve latency, but be aware this will put more strain on the nodes. <strong>\u2022 Tune for minimal latency <\/strong><\/p>\n<p>Use servers with really good network bandwidth. Use appropriate disks and keep logs on a separate disk. Isolate the ZooKeeper process and ensure that swap is disabled. Be sure to track latency in your instrumentation dashboards.<\/p>\n<ol start=\"4\">\n<li><strong> Replication and Redundancy <\/strong><\/li>\n<\/ol>\n<p>There are a few dimensions to consider when thinking about redundancy with Kafka. The first and most obvious is just the replica on factor. We believe Kafka defaults at 2 but for most production uses 3 is best. It will allow you to lose a broker and not freak out. If, improbably, a second broker also independently fails, your system is still running. Alongside replica on factor you also have to think about datacenter racks zones.<\/p>\n<ol start=\"5\">\n<li><strong> Topic Config <\/strong><\/li>\n<\/ol>\n<p>Your Kafka cluster\u2019s performance will depend greatly on how you configure your topics. In general you want to treat topic configuration as immutable since making changes to things like partition count or replica on factor can cause a lot of pain. If you find that you need to make a major change to a topic, often the best solution is to just create a new one. Always test new topics in a staging environment first.<\/p>\n<p>As mentioned above, start at 3 for replica on factor. If you need to handle large messages, see if you can either break them up into ordered pieces (easy to do with par on keys) or just send pointers to the actual data (links to S3 for example). If you absolutely have to handle larger messages be sure to enable compression on the producer\u2019s side. The default log segment size of 1 GB should be fine (if you are sending messages larger than 1 GB, reconsider your use case). Partition count, possibly the most important setting, is addressed in the next section.<\/p>\n<p><strong>Instaclustr\u2019s competitive edge:<\/strong><\/p>\n<p>With the addition of Manged Kafka to the suite of solutions available through Instaclustr\u2019s Open Source-as-a-Service platform, organizations using Instaclustr-managed Kafka are selecting an experienced provider distinguished by more than 20 million node hours under management and available technical teams that bring deep Kafka-specific expertise.<\/p>\n<p>The managed Kafka offering follows the robust provisioning and management patterns used to deliver other leading open source technologies provided through the Instaclustr platform \u2013 including Apache Cassandra, Apache Spark, and Elassandra. Instaclustr Managed Apache Kafka is backed by advanced data technologies designed to deliver easy scalability, high performance, and uninterrupted availability. Additionally, Instaclustr provides customers with a SOC2 certified Kafka managed service, further ensuring secure data management and safeguarding client privacy.<\/p>\n<p><strong>About Instaclustr<\/strong><\/p>\n<p>Instaclustr is the Open Source-as-a-Service company, delivering reliability at scale. We operate an automated, proven, and trusted managed environment, providing database, analytics, search, and messaging. We enable companies to focus internal development and operational resources on building cutting-edge customer-facing applications.<\/p>\n<p>For more information, visit\u00a0<a href=\"http:\/\/www.instaclustr.com\" rel=\"external nofollow\" target=\"_blank\">www.instaclustr.com<\/a><\/p>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>What is Kafka? Apache Kafka is an open source project providing powerful distributed processing of continuous data streams \u2013 and is currently trusted in production by thousands of enterprises globally &#8230; <\/p>\n<p class=\"read-more-container\"><a title=\"5 Tips and Tricks for Managing Kafka\" class=\"read-more button\" href=\"https:\/\/www.99techpost.com\/5-tips-and-tricks-for-managing-kafka\/#more-633\">Read More<span class=\"screen-reader-text\">5 Tips and Tricks for Managing Kafka<\/span><\/a><\/p>\n","protected":false},"author":14,"featured_media":641,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[54],"tags":[],"class_list":["post-633","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-tips-tricks","no-featured-image-padding"],"_links":{"self":[{"href":"https:\/\/www.99techpost.com\/wp-json\/wp\/v2\/posts\/633","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.99techpost.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.99techpost.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.99techpost.com\/wp-json\/wp\/v2\/users\/14"}],"replies":[{"embeddable":true,"href":"https:\/\/www.99techpost.com\/wp-json\/wp\/v2\/comments?post=633"}],"version-history":[{"count":0,"href":"https:\/\/www.99techpost.com\/wp-json\/wp\/v2\/posts\/633\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.99techpost.com\/wp-json\/wp\/v2\/media\/641"}],"wp:attachment":[{"href":"https:\/\/www.99techpost.com\/wp-json\/wp\/v2\/media?parent=633"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.99techpost.com\/wp-json\/wp\/v2\/categories?post=633"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.99techpost.com\/wp-json\/wp\/v2\/tags?post=633"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}