Kafka vs Sidekiq: What are the differences?
Developers describe Kafka as "Distributed, fault tolerant, high throughput pub-sub messaging system". Kafka is a distributed, partitioned, replicated commit log service. It provides the functionality of a messaging system, but with a unique design. On the other hand, Sidekiq is detailed as "Simple, efficient background processing for Ruby". Sidekiq uses threads to handle many jobs at the same time in the same process. It does not require Rails but will integrate tightly with Rails 3/4 to make background processing dead simple.
Kafka and Sidekiq are primarily classified as "Message Queue" and "Background Processing" tools respectively.
"High-throughput", "Distributed" and "Scalable" are the key factors why developers consider Kafka; whereas "Simple", "Efficient background processing" and "Scalability" are the primary reasons why Sidekiq is favored.
Kafka and Sidekiq are both open source tools. It seems that Kafka with 12.7K GitHub stars and 6.81K forks on GitHub has more adoption than Sidekiq with 9.68K GitHub stars and 1.66K GitHub forks.
According to the StackShare community, Kafka has a broader approval, being mentioned in 509 company stacks & 470 developers stacks; compared to Sidekiq, which is listed in 348 company stacks and 77 developer stacks.
What is Kafka?
What is Sidekiq?
Need advice about which tool to choose?Ask the StackShare community!
Sign up to add, upvote and see more prosMake informed product decisions
What are the cons of using Sidekiq?
Sign up to get full access to all the companiesMake informed product decisions
Sign up to get full access to all the tool integrationsMake informed product decisions
delayed_job is a great Rails background job library for new projects, as it only uses what you already have: a relational database. We happily used it during the company’s first two years.
But it started to falter as our web and database transactions significantly grew. Our app interacted with users via SMS texts sent inside background jobs. Because the delayed_job daemon ran every couple seconds, this meant that users often waited several long seconds before getting text replies, which was not acceptable. Moreover, job processing was done inside AWS Elastic Beanstalk web instances, which were already under stress and not meant to handle jobs.
We needed a fast background job system that could process jobs in near real-time and integrate well with AWS. Sidekiq is a fast and popular Ruby background job library, but it does not leverage the Elastic Beanstalk worker architecture, and you have to maintain a Redis instance.
We ended up choosing active-elastic-job, which seamlessly integrates with worker instances and Amazon SQS. SQS is a fast queue and you don’t need to worry about infrastructure or scaling, as AWS handles it for you.
We noticed significant performance gains immediately after making the switch.
I use Kafka because it has almost infinite scaleability in terms of processing events (could be scaled to process hundreds of thousands of events), great monitoring (all sorts of metrics are exposed via JMX).
Downsides of using Kafka are: - you have to deal with Zookeeper - you have to implement advanced routing yourself (compared to RabbitMQ it has no advanced routing)
The question for which Message Queue to use mentioned "availability, distributed, scalability, and monitoring". I don't think that this excludes many options already. I does not sound like you would take advantage of Kafka's strengths (replayability, based on an even sourcing architecture). You could pick one of the AMQP options.
I would recommend the RabbitMQ message broker, which not only implements the AMQP standard 0.9.1 (it can support 1.x or other protocols as well) but has also several very useful extensions built in. It ticks the boxes you mentioned and on top you will get a very flexible system, that allows you to build the architecture, pick the options and trade-offs that suite your case best.
For more information about RabbitMQ, please have a look at the linked markdown I assembled. The second half explains many configuration options. It also contains links to managed hosting and to libraries (though it is missing Python's - which should be Puka, I assume).
I used Kafka originally because it was mandated as part of the top-level IT requirements at a Fortune 500 client. What I found was that it was orders of magnitude more complex ...and powerful than my daily Beanstalkd , and far more flexible, resilient, and manageable than RabbitMQ.
So for any case where utmost flexibility and resilience are part of the deal, I would use Kafka again. But due to the complexities involved, for any time where this level of scalability is not required, I would probably just use Beanstalkd for its simplicity.
I tend to find RabbitMQ to be in an uncomfortable middle place between these two extremities.
We use Sidekiq to process millions of Ruby background jobs a day under normal loads. We sometimes process more than that when running one-off backfill tasks.
With so many jobs, it wouldn't really make sense to use delayed_job, as it would put our main database under unnecessary load, which would make it a bottleneck with most DB queries serving jobs and not end users. I suppose you could create a separate DB just for jobs, but that can be a hassle. Sidekiq uses a separate Redis instance so you don't have this problem. And it is very performant!
I also like that its free version comes "batteries included" with:
- A web monitoring UI that provides some nice stats.
- An API that can come in handy for one-off tasks, like changing the queue of certain already enqueued jobs.
Sidekiq is a pleasure to use. All our engineers love it!
Front-end messages are logged to Kafka by our API and application servers. We have batch processing (on the middle-left) and real-time processing (on the middle-right) pipelines to process the experiment data. For batch processing, after daily raw log get to s3, we start our nightly experiment workflow to figure out experiment users groups and experiment metrics. We use our in-house workflow management system Pinball to manage the dependencies of all these MapReduce jobs.
We turn to Sidekiq when we need to run background jobs in a Rails app, which we do for just about every Rails app we write. We especially like the ops tools that come with Sidekiq, which make it easy to monitor and maintain.
Background processing of Pushover push notifications to admins when sales occur, payments processing via Pin Payments, Campaign Monitor transaction email sending, and Intercom event API posting.
Sidekiq is used extensively for a multitude of background jobs, everything from audio/video post-processing to sending push notifications.
Building out real-time streaming server to present data insights to Coolfront Mobile customers and internal sales and marketing teams.
We offload our background processing tasks (photo sizing, watermarking, etc.) to Sidekiq to keep our app's performance optimal.