Comments (1)
There are two basic approaches to getting more parallelism out of Kafka consumers:
- Add more partitions and group members. In theory, you can have as many consumers as you have partitions, and each will run in parallel.
- Use multiple threads in your consumers.
The second option is a bit dangerous, as you lose a bunch of guarantees that Kafka makes, such as ordering, but if you're okay with possibly reprocessing the same messages quite a few times when there's an error, this is a pretty simple approach:
class ParallelConsumer < Racecar::Consumer
subscribes_to "work"
def process_batch(batch)
threads = batch.messages.map {|message|
Thread.new { work(message) }
}
# Wait for all threads to finish before proceeding.
threads.each(&:join)
# Racecar will only checkpoint the consumer position when we return,
# so if one of the threads fail, all will be retried.
end
end
Note that this introduces concurrency, so you want to be careful and not share mutable state between the threads.
from racecar.
Related Issues (20)
- Cannot find ActiveRecord Class in Rails 6 uninitialized constant for Model in `app/models` HOT 1
- Gem with statistics_interval setting HOT 2
- Add required_ruby_version to gemspec? 2.3.0 release is broken on Ruby < 2.5 HOT 3
- Integrating Confluent kafka with racecar HOT 2
- No such configuration property "enable.ssl.certificate.verification" HOT 6
- Racecar trying to connect to 127.0.0.1:9092 regardless of configuration
- default start_from_beginning = false HOT 2
- long running processes HOT 4
- how can we mention sasl_username, sasl_password in racecar.yml for different brokers
- Maximum application poll interval (max.poll.interval.ms) exceeded (max_poll_exceeded) HOT 2
- Unable to configure producer partitioner_name HOT 2
- [question] Multi service Datadog dashboard setup HOT 1
- Consumer client ids defaulting to consumer-null-NNNN
- Consumer reset not needed on a :not_coordinator according to librdkafka HOT 1
- Allow setting King Konf's ignore_unknown_variables HOT 3
- How to do a quick health check HOT 2
- Define active_support dependencies in production.
- IAM access control HOT 1
- Configure producer using environment variables HOT 2
- Config not loaded automatically for a producer in Rails. HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from racecar.