socket.io-kfk
v0.0.8
Published
The kafka adapter for socket.io
Downloads
9
Readme
Socket.IO-KFK
Usage
Install
npm install -S socket.io-kfk
Use Adapter
import * as IO from 'socket-io'
import { initKafkaAdapter } from 'socket.io-kfk'
// create socket.io server
const server = http.createServer()
const io = IO(server)
// init kafka adapter
const opts = {
brokerList: '127.0.0.1:9092',
group: 'socketio-group',
topic: 'socketio-topic',
}
const adapter = initKafkaAdapter(opts)
// register into socket.io instance
io.adapter(adapter)
Why not socket-io.redis?
socket.io-redis
is a easy and awesome adapter in socket.io ecology. But it use redis as its internal message queue, which have poor performance when have huge events. And redis cluster have a simple PUB/SUB implement: current implementation will simply broadcast each published message to all other nodes. It make us feel hard to expand our socket.io cluster with redis adapter.
So, for the reason of scalability, I write this kafka version to make socket.io can handle more than 100k events/s messages.