Processing api calls with background processing #567
Replies: 1 comment 6 replies
-
I'm 100% sure we will evolve to a queue architecture with async processing as opposed to the current synchronous processing approach. The main benefit I see is reliability/uptime improvements during peak load times. Instead of crashing under heavy load, we could just fill up a queue and show a little notice on the dashboard when the queue is large enough to cause a visible delay in processing. So far we've managed without this, although as you can see on our status page we are susceptible to crashing under heavy load. Adding an intermediate interface to the pipeline will slow down development of new features though. I'm planning on this once we're a bit more stable with the product itself. |
Beta Was this translation helpful? Give feedback.
-
Hi, I have just quick idea/question/brainstorm. Why don't you process data from api calls with "background jobs"? I don't see your internal performance stats from AppSignal but this approach can really speedup JS api calls. You can use full power of Oban if your posgresql has some free resources. Or maybe better solution would be use GenStage to process them in bulks. You can even create own processor for every page with DynamicSupervisor. You don't have to care about queue persistence because you don't have sensitive data, just stats. But that can be handled with rolling update in your deployment strategy and some small optimization.
BTW: don't do this in controller
https://github.com/plausible/analytics/blob/master/lib/plausible_web/controllers/api/external_controller.ex#L67-L125
Beta Was this translation helpful? Give feedback.
All reactions