TE
科技回声
首页24小时热榜最新最佳问答展示工作
GitHubTwitter
首页

科技回声

基于 Next.js 构建的科技新闻平台,提供全球科技新闻和讨论内容。

GitHubTwitter

首页

首页最新最佳问答展示工作

资源链接

HackerNews API原版 HackerNewsNext.js

© 2025 科技回声. 版权所有。

Patterns for Building Realtime Features

161 点作者 zknill3 个月前

8 条评论

PaulDavisThe1st3 个月前
Can we not use &quot;realtime&quot; for what is just really &quot;interactive&quot; features? Or even just &quot;duplex&quot; ?<p>&quot;realtime&quot; has a long history in the computing and technology realms, and this ain&#x27;t it.
评论 #43008430 未加载
评论 #43009565 未加载
评论 #43011419 未加载
评论 #43010548 未加载
评论 #43010418 未加载
评论 #43012269 未加载
recroad3 个月前
It’s amazing how much boilerplate stuff you don’t have to worry about when you use Phoenix LiveView. I think I’m in love with it.
评论 #43006816 未加载
评论 #43006722 未加载
评论 #43006369 未加载
评论 #43006658 未加载
评论 #43006283 未加载
jtwaleson3 个月前
I&#x27;m building a simple version with horizontally scalable app servers that each use LISTEN&#x2F;NOTIFY on the database. The article says this will lead to problems and you&#x27;ll need PubSub services, but I was hoping LISTEN&#x2F;NOTIFY would easily scale to hundreds of concurrent users. Please let me know if that won&#x27;t work ;)<p>Some context: The use case is a digital whiteboard like Miro and the heaviest realtime functionality will be tracking all of the pointers of all the users updating 5x per second. I&#x27;m not expecting thousands&#x2F;millions of users as I&#x27;m planning on running each instance of the software on-prem.
评论 #43010163 未加载
评论 #43006566 未加载
评论 #43010675 未加载
评论 #43006428 未加载
calebio3 个月前
This article ended too soon :( I was having a really good time reading it, very nice work!
martinsnow3 个月前
How do you handle deployments of realtime back ends which needs state in memory?
评论 #43010253 未加载
评论 #43005849 未加载
评论 #43010410 未加载
评论 #43005756 未加载
rurban3 个月前
Polling in reactive webapps? (this is what he calls &quot;realtime&quot;)<p>Well, don&#x27;t do that. He by himself advised against it previously <a href="https:&#x2F;&#x2F;zknill.io&#x2F;posts&#x2F;how-to-adopt-realtime&#x2F;" rel="nofollow">https:&#x2F;&#x2F;zknill.io&#x2F;posts&#x2F;how-to-adopt-realtime&#x2F;</a><p>And it&#x27;s really annoying that those web nobs inflate terms. He also talks about hard realtime which has nothing to do with hard realtime. Will his webapps reboot? Ha, of course not. He is talking that reactive webapps becoming simple.
deepsun3 个月前
Isn&#x27;t this what Firebase and similar solved a long time ago?<p>Having a local copy of a database slice, and hide the sync from developer at all.
blixt3 个月前
What I found building multiplayer editors at scale is that it&#x27;s very easy to very quickly overcomplicate this. For example, once you get into pub&#x2F;sub territory, you have a very complex infrastructure to manage, and if you&#x27;re a smaller team this can slow down your product development a lot.<p>What I found to work is:<p>Keep the data you wish multiplayer to operate on atomic. Don&#x27;t split it out into multiple parallel data blobs that you sometimes want to keep in sync (e.g. if you are doing a multiplayer drawing app that has commenting support, keep comments inline with the drawings, don&#x27;t add a separate data store). This does increase the size of the blob you have to send to users, but it dramatically decreases complexity. Especially once you inevitably want versioning support.<p>Start with a simple protocol for updates. This won&#x27;t be possible for every type of product, but surprisingly often you can do just fine with a JSON patching protocol where each operation patches properties on a giant object which is the atomic data you operate on. There are exceptions to this such as text, where something like CRDTs will help you, but I&#x27;d try to avoid the temptation to make your entire data structure a CRDT even though it&#x27;s theoretically great because this comes with additional complexity and performance cost in practice.<p>You will inevitably need to deal with getting all clients to agree on the order in which operations are applied. CRDTs solve this perfectly, but again have a high cost. You might actually have an easier time letting a central server increment a number and making sure all clients re-apply all their updates that didn&#x27;t get assigned the number they expected from the server. Your mileage may vary here.<p>On that note, just going for a central server instead of trying to go fully distributed is probably the most maintainable way for you to work. This makes it easier to add on things like permissions and honestly most products will end up with a central authority. If you&#x27;re doing something that is actually local-first, then ignore me.<p>I found it very useful to deal with large JSON blobs next to a &quot;transaction log&quot;, i.e. a list of all operations in the order the server received them (again, I&#x27;m assuming a central authority here). Save lines to this log immediately so that if the server crashes you can recover most of the data. This also lets you avoid rebuilding the large JSON blob on the server too often (but clients will need to be able to handle JSON blob + pending updates list on connect, though this follows naturally since other clients may be sending updates while they connect).<p>The trickiest part is choosing a simple server-side infrastructure. Honestly, if you&#x27;re not a big company, a single fat server is going to get you very far for a long time. I&#x27;ve asked a lot of people about this, and I&#x27;ve heard many alternatives that are cloud scale, but they have downsides I personally don&#x27;t like from a product experience perspective (harder to implement features, latency&#x2F;throughput issues, possibility of data loss, etc.) Durable Objects from Cloudflare do give you the best from both worlds, you get perfect sharding on a per-object (project &#x2F; whatever unit your users work on) basis.<p>Anyway, that&#x27;s my braindump on the subject. The TLDR is: keep it as simple as you can. There are a lot of ways to overcomplicate this. And of course some may claim I am the one overcomplicating things, but I&#x27;d love to hear more alternatives that work well at a startup scale.
评论 #43006073 未加载
评论 #43009373 未加载
评论 #43045978 未加载