-
Notifications
You must be signed in to change notification settings - Fork 401
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
How to handle multiple instances in node #254
Comments
@sarink this question is better asked on [email protected] but in short, if you want to minimize the TCP handshakes, just create the PN instance so that it can be reused rather than reinstantiating every time you need it. For your server, you could just use the same UUID each time or create multiple instances each with a different UUID. It really depends on your requirements. |
hey @pubnubcraig , thanks for your response, but I'm not sure that really answers my questions.
|
Curious about the answer to @sarink question as well. Because seems like we are getting memory leaks here:
|
I can't find an answer to this anywhere.
It's recommended to have a different uuid for each user or device. This uuid is used in the constructor function, when calling
new PubNub
. This means that on your server there will be a zillion pubnub instances? Should creating these be memoized? Do they persist a connection which needs to be closed?Consider the following code:
is it ok to just
new
one up whenever you need it? Will it be garbage collected when the function closes, or will this create a memory leak?The text was updated successfully, but these errors were encountered: