-
Notifications
You must be signed in to change notification settings - Fork 124
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
Tracker pool and dirty list #79
Tracker pool and dirty list #79
Conversation
10324f2
to
14e4512
Compare
14e4512
to
7206a18
Compare
7206a18
to
1c9ab71
Compare
Hi @chrismccord! Happy 4th! 🇺🇸 |
Hi @pzel, let me hijack this thread briefly. I have just watched your excellent ElixirConf talk. At some point in the talk you mentioned the use of phx_requests for tracking subscription and I want to be sure I understood the design. Previously, you would join a channel for every friend you had. Then you changed it to have a single channel that subscribes to the topic of every friend. Is this correct? |
I just got to the questions part of the talk and Chris mentioned fastlaning and I would like to point out you can still fastlane if you pass the proper options on subscribe. @chrismccord, it may be worth adding a |
That is what I do, prevents process-explosion. ^.^;
Ooo, I did not know about those options...
Please yes? :-) |
@josevalim I implemented this but then reverted because the clients are not aware of the fastlaned topics. Broadcasts are matched on the client via the topic, so the only way to handle fastlaned messages would be to use |
I'll also note that the "subscribe to many topics via a single channel process" is definitely a pattern we promote for different usecases. Some references to this in the guides would be nice. |
@josevalim <https://github.com/josevalim> I implemented this but then
reverted because the clients are not aware of the fastlaned topics
Does it mean the client discards them or does it mean the client is unable
to know from where it actually came from?
--
*José Valimwww.plataformatec.com.br
<http://www.plataformatec.com.br/>Founder and Director of R&D*
|
Both but there is a socket.onMessage where you could try your own handling
…Sent from my iPhone
On Sep 30, 2017, at 12:05 AM, José Valim ***@***.***> wrote:
> @josevalim <https://github.com/josevalim> I implemented this but then
reverted because the clients are not aware of the fastlaned topics
Does it mean the client discards them or does it mean the client is unable
to know from where it actually came from?
--
*José Valimwww.plataformatec.com.br
<http://www.plataformatec.com.br/>Founder and Director of R&D*
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub, or mute the thread.
|
@josevalim: Chris pretty much summed up what we ran into. We developed a This is what our setup looked like before we had to revert:
|
Hey @chrismccord, are there any plans to merge this PR? I'd love to see it released. |
Yes, it is still on my plate! |
Sorry this took so long to get merged in. Thanks so much!!! Note: I have decided to remove the |
Sweet! Hope people enjoy the speed benefits! |
@pzel do you have recommendations how to choose a pool size for the tracker? Also, I understand dirty_list was removed from the tracker API. I still see it in the Shard module. Is it possible to still use it? |
@indrekj I've been out of the loop regarding PubSub performance for a while now, so I can't make any recommendations about how to measure total system performance for your use case. However, I think that using a pool size equal to the number of CPUs on your target deployment machine is a reasonable choice. If you don't know this number, use 16 and see how the system behaves ;) Regarding |
If anyone else needs this you don't need to fork it, just implement a
|
I also made a PR #127 which removes the need for dirty_list. |
@indrekj I saw that! I was trying not to diverge from what's here, as I'm pretty new to all this. I hope they merge it! The whole thing is eventually consistent so why serialize the reads in the first place? |
Tracker Pool &
dirty_list
APISummary
This work is aimed at increasing the capacity of applications using
Phoenix Presence.
Specifically, it addresses two issues:
Tracker
server becoming a bottleneck under high throughputTracker.list
calls invokingGenServer.call
to get a list ofpresences
The first issue is resolved by starting a pool of named
Tracker.Shards
,and dispatching calls to them based on the
topic
in question. The defaultpool size is
1
, and therefore the current behavior ofPhoenix.Presence
isnot affected.
The second issue is resolved by introducing a
Tracker.dirty_list
functionwith the same API as
Tracker.list
, but with much less overhead and lessprecise results.
Comments & Caveats
This likely addresses #71.
A corresponding change will need to be made to the Phoenix Framework in order
for the default
Phoenix.Presence
handler to expose the newTracker.dirty_list
functionality. In the meantime, applications that needto use
dirty_list
can implement it directly, as shown below:Graphs from the application running under target production load
The graphs compare the same scenario with different configurations of the proposed changes, the default setting being the one of them.
Pool Size Load Test Results:
At
pool_size
= 1, the track time tail latencies are much higher than the corresponding metric atpool_size
= 36.Pool size: 1
Pool size: 36
List Function Load Test Results
List times are dramatically lower when using 'dirty_list
, due to the complete bypass of
GenServer.call`s.Tracker.list
@ pool size = 128Tracker.dirty_list
@ pool size = 128