44:40So you mentioned that you haven't
yet built larger systems with the
44:45event sourcing approach, but I
think you've still done a little
44:48bit of research on what might await
you in the event sourcing world.
44:53So could you outline a little bit
of like the potential concerns
44:57you see on the horizon when
going all in on event sourcing?
45:01Yeah, so I guess the main concern
always is if you're Sending around
45:06this log of events to clients.
45:09And if you're storing this as
your single source of truth, then
45:13storing all these events forever,
it might take up a lot of space.
45:15If you could imagine a text document, if
each text character corresponds to 100
45:20bytes of JSON, then the history of all
the events is going to be a hundred times
45:25bigger than the actual text document.
45:26Even if you've since cleared out the
entire text document, now it's empty.
45:29You still have all this state.
45:30So that's the main challenge is just how
do we store the events efficiently, how
45:35do we maybe compact them, say I don't
need these events anymore, I'm going to
45:38throw them away and replace the state,
while still making that play nicely
45:42with, you know, clients who have been
offline for a month, that sort of thing.
45:45Which sort of mechanisms do
you think will mostly help to
45:49overcome some of those issues?
45:51I'm hoping the main mechanism is just
To give up, basically say text is
45:56very small for any, the main sources
of lots of data in your app are
46:01blobs like images or videos, which
you can put somewhere else anyway.
46:05And then for the actual event describing
the fine grained changes, just store
46:08them all and it's only going to be
a few megabytes per document anyway.
46:11Got it.
46:13Yeah.
46:13And I think on top of that, there's
also the compaction use case.
46:17Now that I have a little bit
more, insight on, on that
46:21approach with building Overtone.
46:23for example, given that everything you
do within Overtone, whether it's playing
46:28a track, whether it's navigating within
the app, whether it's adding a track
46:31to your playlist or follow an artist,
all of those are an event and Adding
46:39a track to a playlist, there you do a
lot less of those than, for example,
46:45in the background, the app auto playing
the next track, which is also an event.
46:52And another kind of event is if the app
tries to authenticate with a music service
46:58such as Spotify to exchange tokens, which
it needs to do at least Once an hour.
47:05So it does so a little bit ahead of time.
47:07So, also when you reload the
app, it needs to do that.
47:11So just by the fact by, the app running
in the background over time, it Racks
47:18up quite a lot of different events.
47:21And I think they're the interesting
part is the nature of the events
47:25and the nature of those events also
allows for different trade offs.
47:28So me putting a track into a
playlist, A, there's going to be
47:33like way fewer events of those.
47:35and it's fine to keep the
entire history of this around.
47:38What's so cool about this also, the fact.
47:41That, I have this event allows me to
trivially implement a feature like that.
47:46I can hover over the track and I see
the information when was it added by
47:51whom was it added to, to the playlist.
47:53It also makes implementing things such
as undo much easier, but the other kind
47:59of events, which might be implicit or
which might just be a lot more, higher
48:05quantity, what I've seen is that, it's
not as crucial to keep those events
48:11around for eternity, but some of those
events are then also made irrelevant by
48:17follow up events of the, the same type.
48:20So for example, if your app has
authenticated and overrides sort of like
48:24an off state into the database, and.
48:27two hours later, it has
already done so 10 more times.
48:31I don't need to keep the entire history
before that, maybe besides auditing
48:35reasons, so I can just at some point
remove the old events, which keeps
48:41an otherwise always growing event
log at a, for this given event type
48:47at a much more like constant size,
which makes it much more feasible.
48:52Another thing that I, started thinking
about is like, what if you have not
48:57just like one event log, but what
if you have multiple event logs?
49:01And what if you have, a
hierarchy of event logs?
49:04This is something that I also want to
think a little bit more about, Let's
49:08say you have a, a tree of, playlists,
like a, a folder of playlists.
49:13So you have a, a playlist.
49:15And that playlist could also, possibly
be a folder of other playlists.
49:20So now what does the event log exist for?
49:23Does it exist for like,
everything in my library?
49:26Does it exist for a broken down to.
49:30only giving information about which
playlists I have, and then I need to
49:34subscribe to another playlist, but
what if that playlist is a folder?
49:38So this hierarchical aspect of
it, I think this will keep me busy
49:42for, for a little bit as well.
49:43Do you have thoughts on those problems?
49:46Yeah, I mean, this, the, what
you're saying is really interesting.
49:48It makes me think of the
problem of ephemeral presence.
49:52So, you know, in Figma, when your
collaborators are moving their
49:54mouse cursors around, you can see
where they're at it every time.
49:58I would imagine Figma is not actually
persisting those mouse movements,
50:01it's just sending them over the usual
channels so that you can see them live,
50:04but then you forget about these events
because they don't matter anymore.
50:07So I wonder if you could maybe do that
for a lot of the events that don't
50:11matter as much, or even in a text editor.
50:13So one thing that's really hard with a
collaborative text editor is you'd like it
50:17so that whenever you press a key, that key
is immediately sent to your collaborators.
50:21But if that actually creates an event
that's persisted in the log, then you have
50:24this issue of, you know, 100 times as much
storage as key presses, but maybe what
50:28you could say is when you press a key,
that's like an ephemeral presence message.
50:32It's not actually stored,
it's just sent over the same
50:34channel as the mouse movements.
50:36And this is sort of like an ephemeral mini
log that's stacked on top of the actual
50:40event log, and then every 10 seconds
or so you send a compacted version of
50:44like the entire sentence that the person
typed as a single event, and that's
50:47what's actually stored on the backend.
50:49I wonder if that could help at all, or
if this is even possible to implement.
50:52Right.
50:53I've actually implemented a
small version of that already,
50:57which I call local only events.
50:59The idea of that is that, there's kind
of like hierarchies of syncing as well.
51:05There's like syncing, just from the main
thread to the workers thread, which is
51:11responsible for persisting the data,
but also from one tab to another tab.
51:18And, those two tabs should in
some regards, Converge, and in
51:23some regards, allow divergence.
51:25so for example, if you have Notion open in
two tabs, you want to be able to navigate
51:32to different documents and those different
tabs, but if you're in the same document,
51:36you probably want to see the same thing.
51:38So it's the same that
applies to a music app.
51:41Maybe in one tab you want to have.
51:43The playback of one track and the another
one, you want to not have the same
51:48playback, otherwise you hear it twice.
51:50but you want to maybe work on a playlist.
51:53And so keeping things in sync is
important, but I don't want to,
51:58constantly as the playback progresses,
have persistent events for this.
52:02So I try to A, have like, very
Deliberately small events.
52:08And the other thing is where I have
events that are broadcasted around.
52:12But, if the app reloads, it
doesn't rehydrate from those.
52:16It either catches them midway
or it's not important enough.
52:21that it shows it so very similar
to the presence feature in Figma.
52:25So I have implemented a first version
of this, but I think there can be
52:29use cases where you might want to
keep them around for like 10 minutes
52:34or 10 seconds, like you say, and
then have a version of compaction.
52:37I think that that's really interesting.
52:40What you're describing sounds really cool.
52:41I'll be interested to
see this code someday.