feathersjs-ecosystem / feathers-sync

Synchronize service events between Feathers application instances
MIT License
222 stars 41 forks source link

Scale server on kubernetes #55

Closed kostia-official closed 7 years ago

kostia-official commented 7 years ago

I have multiple replicas of one FeathersJS app in kubernetes. I open access to it with Service NodePort. On the client side I successfully connect to one replica, but with many replicas I have xhr poll error. The client connects to the server. It can even receive events sometimes, but on polling, I have an error. As far as I see I have a problem because of round robin connection. The client connects to one container but then polls another. Maybe I'm wrong and there is another reason of this error. Have anyone an experience with kubernetes and socket scaling? How properly use it?

daffl commented 7 years ago

With your setup I would force Socket.io to only use Websockets and not polling. As outlined here on Stackoverflow this should be possible by either doing

var socket = io({transports: ['websocket'], upgrade: false});

On the client or

io.set('transports', ['websocket']);

On the server.

kostia-official commented 7 years ago

It works. Thank you.