add hibernate option for long lived process#101
Conversation
|
When I using hibernate for the connection process and query mongo continuously the memory of process just like: but, after disabled the hibernate option, the memory of the long lived process: Maybe |
| {_, :after_connect} -> | ||
| {timeout, backoff} = Backoff.backoff(backoff) | ||
| {:backoff, timeout, %{s | backoff: backoff}} | ||
| maybe_hibernate(hibernate?, {:backoff, timeout, %{s | backoff: backoff}}) |
There was a problem hiding this comment.
Should we wrap this one in hibernate?
There was a problem hiding this comment.
yep, this point is disconnect, so it not necessary to hibernate. Thanks
|
Thanks @redink! @fishcakez would be the best person to decide if we should merge this but I believe we would need to at least have tests. I am not sure if we can assert externally that a process is in hibernation but we need to assert that at least the code doesn't break if the hibernate flag is used. |
|
Thanks @josevalim ! As just we know, There are some example which using
In ejabberd source code, its using And in one early article https://www.metabrew.com/article/a-million-user-comet-application-with-mochiweb-part-2. The tester using hibernate.
|
|
I think that if we want to add a hibernate option it should follower a slightly smarter strategy rather than always hibernating. For example if we have a checkout or a checkin we know that its very likely that we will get another message almost immediately so hibernating is likely to impact performance there and not be beneficial. My intuition is that we should see the same benefits if we only hibernate in the following cases:
@redink could you try this approach and report back? Also could you describe the methodology you used both this time and previously? For example if just start the processes and do nothing, or you are running a small number of queries. |
|
@fishcakez hmmmm, can't agree with you more. Before, I usually use https://github.com/redink/db_connection_hibernate The data shows that smarter hibernate also could save memory. |
|
@fishcakez ping ... |
|
@redink sorry it'll be a couple of days until I can take a better look at this. |
|
If the problem is memory, maybe a better solution would be to manually trigger GC with |
|
Maybe
And |
|
any update ? |
|
@redink can you send a PR with your smarter branch with 2 changes:
|
|
Closing in favor of #103. |

could save memory as far as possible