Currently connected clients to LiveQuery across all servers

Hi everybody,

I am using a horizontally scaled Parse/Live Query Server with a PostgreSQL and a Redis cluster. All Parse/LiveQuery Server instances connect to the same Redis instance.

We would like to know the total number of clients, and ideally deduplicated by users, currently connected throughout all the Live Query server instances. I need to display this information on the client via the SDK, in a fashion such as “currently x users are partaking this action”.

Can you please advise? I’ve seen this stackoverflow question and read the docs, but they don’t clarify whether the total number of clients is calculated across all Live Query Servers.

Thanks!
A.

1 Like

I’d try to watch the Parse.Cloud.onLiveQueryEvent event of the docs you sent and broadcast the number of clients using some class.

Ok thanks, that was exactly my idea, but I just wanted to make sure it really reflects the total sum of clients across all nodes, and not just the ones connected to the local node. I was asking before attempting implementation, just in case you knew :slight_smile:

I’ve just checked the Parse Server code and it is only the number of clients in the process receiving the connection. You will probably need a class to store an identification for this process and the total clients in that process. Then you can sum all processes and show up the information to the users.

Thank you for checking @davimacedo, do you think it is an interesting feature for submitting a PR while I’m at it?

2 Likes

I think so. I’ve seen other guys with similar need. I’d be happy to review a PR regarding that.

1 Like

Wonderful, will get to it when I have time! I’ll keep you posted!

1 Like

@andreasanta: Semi related question.

Was wondering about horizontally scaling a live query instance of Parse Server…

Did you have to do anything special to support updates getting synced across all of the nodes or is this already handled in the data layer (postgres) and scaling just works?

Thanks!