pckrishnadas88

pckrishnadas88

A while back, I had to process millions of database updates in a legacy system that was already hitting its 64 GB RAM limit, so scaling the existing application further wasn’t practical.

I ended up moving the workload out using:

Legacy app → RabbitMQ → Go worker → batched MySQL updates

I wrote a short post about the problem and the approach I used.

Now that I’m learning Elixir/OTP, I’m curious how you would approach the same problem on the BEAM.

Showing Posts 1 to 8

halturin

halturin

you may also want to try Ergo Framework - it provides you Erlang/OTP patterns but with Golang

LostKobrakai

LostKobrakai

This sounds like a prime case for broadway. I cannot say how it would compare cpu/memory wise, but it can handle the pull from rabbitmq and batch for db update just fine.

Asd

Asd

I would just do the

query =  from(u in Users, where: u.id in ^ids)
Repo.update_all(query, set: [status: :processed])

If the list of ids is around one million of UUIDs, it is still just about 16 megabytes of memory. Sending it over to the database is fine too.

You don’t need RabbitMQ, Go worker or any other solution spanning multiple services to fix the N+1 problem. Even if I have 1GB of UUIDs, I’d just do batching in-service

chungwong

chungwong

Is it really necessary to introduce Go there? Isn’t it just converting the async job to a background task runner? I haven’t touch PHP for years but I believe PHP should be just fine to do that. What is the hidden challenge that promoted the play of Go here?

pckrishnadas88

pckrishnadas88 OP

Hi I was not part of their original team so the codebase was not familiar to me and the php on the server was outdated. What I tried was to isloate the problem. Very minimal change to their existing codebase also if my solution didn’t worked we can remove the go worker easily without major changes on the existing system. I know there are better ways thinking now but everyone was in a hurry so priority was to make it running as soon as possible. Thank you for the feedbacks.

pckrishnadas88

pckrishnadas88 OP

Thanks for the feedback. This was actually something the existing team had already tried, but the database was already under heavy load from other workloads as well. My approach was mainly to isolate the problem and reduce its impact on the existing system.

matt-savvy

matt-savvy

You might want to check out Concurrent Data Processing in Elixir: Fast, Resilient Applications with OTP, GenStage, Flow, and Broadway by Svilen Gospodinov

But really, it sounds like all that needs to happen is that this processing happen outside of the HTTP request.

— All posts loaded —

Where Next? Top

Trending in Blog Posts Top

bartblast
Hey folks, I just published a post about Hologram’s funding and where the project goes next - the short version: Curiosum as Main Spons...
New
pckrishnadas88
Hey everyone! :waving_hand: I’ve published Part 7 of the Building Distributed Systems in Elixir series, where we build core distributed ...
New
mudasobwa
So, instead of wasting my afternoon arguing with anonymous handles on X, I turned to my trusty, soulless assistant and said: “Listen, ple...
New
zorn
An educational side project in Elixir, Phoenix, and Tauri. I share what I learned while wiring Automerge into the BEAM, including how I s...
New
abreujp
New article: Elixir Project Structure — From mix new to a Growing Codebase I’ve published a new article in my Elixir learning series on d...
New
nathanl
Process labels are useful for visualization and debugging. Here’s why you should use them.
New
mudasobwa
Somewhere, right now, a senior engineer is on the verge of a nervous breakdown because his company will not let him switch from Claude to...
New

Other Trending Topics Top

JesseHerrick
Hey, I’m Jesse and I’m the main contributor behind Dexter, a full-featured, lightning-fast Elixir LSP optimized for large codebases. It s...
New
mudasobwa
I am happy to introduce the very α version of the new programming language compiled to BEAM. Welcome Cure. It has literally three kille...
New
marciok
Hi there! We created Gust: A task orchestrator inspired by Airflow. For those who have never heard about Aiflow, it’s a Python-based wor...
New
mhanberg
Hi everyone! The first release candidate for the Expert language server project is now available! We’ve published a press release detai...
New
jimsynz
Beam Bots (or just BB for short) is a framework for building fault-tolerant robotics applications in Elixir using familiar OTP patterns. ...
New
Dmk
Xamal is a deployment tool for Elixir apps that deploys native releases to bare metal servers over SSH. It’s a port of GitHub - basecamp/...
New

Latest on Elixir Forum

We're in Beta

About us Mission Statement

Options

Thread Display Mode




Thread Preview

Skip Thread Previews