Comments (2)
You either have to disable delayed ACK on the receiving side, or disable the nagle algorithm on the sending side.
For confluent-kafka-go you have to set socket.nagle.disable
to true
in the config passed to NewProducer
to disable the nagle algorithm.
from confluent-kafka-go.
Here is how you do it with redis:
opt := &redis.Options{
Addr: "localhost:6379",
Dialer: func(ctx context.Context, network, addr string) (net.Conn, error) {
conn, err := net.DialTimeout(network, addr, 5*time.Second)
if err != nil {
return nil, err
}
tcpConn, ok := conn.(*net.TCPConn)
if !ok {
return nil, err // Optionally, replace with a more specific error
}
if err := tcpConn.SetNoDelay(true); err != nil {
return nil, err
}
return tcpConn, nil
},
}
and with RabbitMQ:
// CustomDialer connects to RabbitMQ using a custom net.Dialer to disable Nagle's algorithm.
func CustomDialer(pool *RabbitMQConnectionPool) (*amqp.Connection, error) {
//// custom dialer
dialer := &net.Dialer{
Timeout: 30 * time.Second,
KeepAlive: 30 * time.Second,
}
conn, err := amqp.DialConfig(pool.connString, amqp.Config{
Dial: func(network, addr string) (net.Conn, error) {
c, err := dialer.Dial(network, addr)
if err != nil {
return nil, err
}
// Assuming c is a *net.TCPConn, disable Nagle's algorithm.
if tcpConn, ok := c.(*net.TCPConn); ok {
if err := tcpConn.SetNoDelay(true); err != nil {
vbl.Stdout.WarnF("Failed to disable Nagle's algorithm: %v", err)
// Handle error or proceed, depending on your error handling strategy.
}
}
return c, nil
},
})
return conn, err
}
I am looking for a way to do this with Kafka as well
from confluent-kafka-go.
Related Issues (20)
- [Question] Reconnect to kafka broker.
- admin client go logs HOT 2
- [BUG] Kafka consumer stop consuming new message, and present wrong max offset and leader epoch -1, confluent-kafka-go v2.1.0
- Static subscription works incorrectly HOT 2
- Schema Registry Client: Does not support Context operations
- [schema registry] protobuf serializer inconsistency with schema registry behavior
- Azure Event Hubs Error: Disconnected while requesting ApiVersion HOT 1
- [schema registry] - unsupported protocol scheme HOT 1
- admin.AlterConsumerGroupOffsets not working for existing consumer group with multiple topics HOT 8
- runc package is not updated in the go.mod file HOT 4
- pprof shows cpu usage hotspot
- flame graph shows hotspot for reading from producer events
- Extremely slow protobuf deserialization and serialization for schema registry HOT 5
- malformed DWARF TagVariable entry HOT 5
- [Knowledge gathering question] How does librdkafka creates and sends batches over the network to the broker? HOT 2
- Do we really need the `default case` in the consumer for loop
- Can't statically build binary with vendored library on arm64 musl HOT 2
- Multiple schema registry URLs does not seem to be supported
- Serialisation poor performance due to a lack of schema caching 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 confluent-kafka-go.