this post was submitted on 23 Jun 2023
6 points (100.0% liked)

Lemmy Support

4655 readers
28 users here now

Support / questions about Lemmy.

Matrix Space: #lemmy-space

founded 5 years ago
MODERATORS
 

When the websocket API is removed in Lemmy v0.18.0, how should applications that need constant updates about new posts, comments, etc., be designed? Should polling be used, or is there a better alternative? If not, how should it be done to minimize load on the servers? Thanks in advance!

top 3 comments
sorted by: hot top controversial new old
[–] terribleplan@lemmy.nrd.li 4 points 1 year ago* (last edited 1 year ago)

As far as I can tell here are your options:

  1. Polling. The easiest answer, and probably the only if you don't own your instance. I would suggest running your own server or at least coordinating with the admins of your server to minimize the impact since many instances are overloaded as it is.
  2. Proxy shenanigans with your own instance. You could probably implement something that sits in front of lemmy (or something your reverse proxy sends a copy of requests to) that would get federation messages and API calls in real-time. If done as a proxy this could even act as a filter for incoming messages if you wanted.
  3. Database shenanigans with your own instance. Assuming you have access to the DB of your instance you could set up logical replication and use something like pypgoutput to handle messages from the database showing every change to every table.
  4. Wait. Maybe at some point something like webhooks or writing events to some sort of message queue/stream will be added, which would be great for moderation tooling. If instances wanted to they could then provide this information over a websocket for consumers who want/need a real-time feed (ala pushshift) without even having to run on the same hardware as the lemmy instance itself.
[–] anders@rytter.me 2 points 1 year ago (1 children)

@crt0o Hm..why did they remove that?

[–] crt0o@lemm.ee 1 points 1 year ago

Apparently it has quite a few disadvantages