Skip to content

u/KeytapTheProgrammer

In this archive from Aug 2012 to Oct 2025

5
posts
80
comments
1
media
527
score

Is the bottleneck in actually saving the data to your database or in downloading it from the API. I recently solved this problem myself. If it's the latter, you could look into executing the requests for multiple pages in multiple separate processes (you could use the PCNTL library to fork a single controlling process).

Of course, that will only work if the limitation is not with throughput on the API side. If it is, and either the API supports web hooks, or you have the ability to implement them in the API, you could set up a message queue and just queue the updates up as the API sends them to you, and then just process them as quickly as you can.

If your server simply can't keep up with the rate of updates to though, then you've got other issues that may require infrastructure or software updates to resolve.

1 points

The main problem withe SSE is that you have to keep a connection open for as long as the client is listening for events, and with PHP, that means about 15-50Mb is going to be tied up per connection. You do get the benefit if not having those clients constantly connecting and reconnecting to the server (because you're not polling the server), but the per connection memory usage is a little high for my tastes. 30 simultaneous connections will tie up 1.5Gb for as long as the clients are connected.

With all that being said, you can use something like NodeJS and Express to serve the events to the frontend client to mostly eliminate that memory usage problem. The base memory usage for a single process is a little higher than in PHP, but all connections are served by one process, and the memory usage only increases by about 1Mb per connection! So that same 30 connections that required 1.5Gb with PHP will only require about 70Mb using a dedicated NodeJS Express server.

3 points

Keyboard shortcuts

Move and act

jork
Next / previous post or comment
Enteroro
Open the post
f
Open the media viewer
s
Save
h
Hide (the toast has Undo)
Tab
Right after an action: the toast's Undo
x
Collapse the comment
v
Next layout: cards, compact, grid

Go to

/
Search
gthenh
Home
gthena
All
gthens
Subreddits
gthenl
Library
?
This list
Esc
Close a menu or this list

In the viewer

←or→
Previous / next file
↑or↓
Previous / next post
korj
Previous / next post
Space
Play / pause
m
Mute
z
Zoom
s
Save
o
Open the post (on its own page: back to it)
Esc
Close

Keys do nothing while you type in a box.