feathersjs-ecosystem / feathers-sync

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

Question about scalability #93

Closed ashconnell closed 5 years ago

ashconnell commented 5 years ago

Please correct me if I'm wrong but this is how I understand the implementation:

If feathers-sync sends every event to every server instance then doesn't that mean your instances get diminishing returns as you continue to scale?

As an example, say I have 2 small instances, each instance can handle around 500 active users at once. Let's say each user is creating a document every 5 seconds. This means every 5 seconds 500 events are published per instance, and 500 events are received by each instance. This seems feasible.

But now let's ramp this up to 10 instances, again with each having 500 users and each user creating a document once every 5 seconds. This time, every 5 seconds 500 events are published per instance but 4500 events are received from the other instances. This is quite a heavy load.

One option here is to then reduce the amount of users each instance handles, to allow more computational power for the incoming events. But this can only go so far before it's 1 server handling a single user and millions of events per second.

Is this an accurate depiction of how feathers would scale?

daffl commented 5 years ago

In theory, yes, feathers-sync makes sure that all events get published to every server. However, each server instance will have to make sure that events only get published to the appropriate channels. It is very unlikely that every connected client will have to know about every event.

As long as your queueing mechanism (MongoDB/Redis etc) can keep up It then comes down to

The way both those things are implemented and perform makes it a very unlikely bottleneck. You will either first run into problems with the queueing mechanism or with websockets being unable to handle that much of a load.

ashconnell commented 5 years ago

Thanks for the hasty response!

So you don't expect that a single node instance receiving millions of events per second is a bottleneck? Even if only a small amount of clients need to receive the event it still needs to process all of the incoming events to determine this.

Are there any apps in the wild using feathers at this kind of scale successfully?

daffl commented 5 years ago

There are Feathers APIs that handle several million requests a day and performing quite well. At millions of requests/events per second you would be looking at a massive scale (say Google or Facebook) so I'm not sure if I can make any statements about that. Happy to discuss specifics with a realistic application benchmark but chances are that Feathers won't be the first bottleneck you'll encounter (because it really isn't doing that much).

stale[bot] commented 5 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Apologies if the issue could not be resolved. FeathersJS ecosystem modules are community maintained so there may be a chance that there isn't anybody available to address the issue at the moment. For other ways to get help see here.