Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/joway/socket.io-kfk
Kafka adapter for socket.io
https://github.com/joway/socket.io-kfk
adapter kafka socket-io
Last synced: 3 months ago
JSON representation
Kafka adapter for socket.io
- Host: GitHub
- URL: https://github.com/joway/socket.io-kfk
- Owner: joway
- License: mit
- Created: 2019-01-26T03:54:15.000Z (almost 6 years ago)
- Default Branch: master
- Last Pushed: 2020-02-11T02:39:00.000Z (almost 5 years ago)
- Last Synced: 2024-09-14T10:50:30.250Z (4 months ago)
- Topics: adapter, kafka, socket-io
- Language: JavaScript
- Homepage:
- Size: 104 KB
- Stars: 4
- Watchers: 3
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Socket.IO-KFK
## Usage
### Install
```shell
npm install -S socket.io-kfk
```### Use Adapter
```js
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](https://redis.io/topics/cluster-spec). 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.
## License
[MIT](https://github.com/joway/socket.io-kfk/blob/master/LICENSE)