wandenberg / nginx-push-stream-module

A pure stream http push technology for your Nginx setup. Comet made easy and really scalable.
Other
2.22k stars 295 forks source link

"Upstream" publisher mode #74

Closed abh closed 4 years ago

abh commented 11 years ago

This is a variation of #42.

For some use cases (lots of subscribers to the same channels) it'd be useful to have an "upstream server" so when a subscriber connects, the module will connect to the upstream and subscribe there. If thousands of users are subscribing to the same channel only one connection will be active to the upstream.

misiek08 commented 9 years ago

I use something like fanout. "It's super effective". Just one, custom server written in Go, which publishes to push-stream servers. I added fancy feature like adding and disabling servers live, so I can take anything to maintenance.

I'll try to write it in some better-looking way, because now it's trash and share if someone will contact me :)

msurguy commented 9 years ago

@misiek08 I'd be interested in details. Could you send an email to msurguy @ gmail ?

misiek08 commented 9 years ago

I suspended Go version for now. Is great, but my solution is used by 2 companies and noone there knows Go, so they required node.js version.

I set up 2 routes /add and /del/:id and I add server to array or remove it. I connect to master server, where sources are publishing, connect to all servers from array and on every message I'm sending that message async to each server from array. No logging, no error handling (only retry few times) and no tests.

msurguy commented 9 years ago

Ah, simple enough then! How does the client know which server to connect to?

misiek08 commented 9 years ago

My case have separate producers and subscribers. More like announcement not chat. Client need some way to filter chats and generate some events so user posts by ajax call and get messages by sockets, so I don't need to know which server can I send to, just connect to any slave and listen for messages.