Code Monkey home page Code Monkey logo

Comments (2)

edgurgel avatar edgurgel commented on September 27, 2024

Hey @heyitsjames ,

Maybe you could try writing workers that simply "synchronise" work by talking to a single process accumulating inside an ETS table?

This single process would simply hold an ETS table.

Once 500 is reached (your work adding jobs directly to this ETS table can find out if 500 was reached) or the time is up (5 seconds) then execute the work and reply back to all workers that are waiting? The jobs will be done once the batch is processed?

There are issues with this implementation as if you reach say 1500 jobs very quickly you may have a bottleneck.

This is not trivial to be solved as there's a lot of coordination. Maybe some redis scripts ? 😆 Feel free to look at the existing ones inside Verk 1.* (Verk 2.0 is coming one day and it uses Redis Streams)

from verk.

heyitsjames avatar heyitsjames commented on September 27, 2024

@edgurgel Thank you for the response!

As an update, I ended up using a Verk queue with a max of 500 jobs, and then using GenStateMachine to handle batching and timeout/flush operations.

Ended up working quite nicely, is very performant, and can scale nicely with adding more queues and linking them to their own batcher.

Each of my worker processes declares a receive block that the batcher can send success or failure, which allows me to use all the retry/requeue niceties that Verk affords me.

If I have time, it honestly doesn't seem like a stretch to add this into Verk itself. Instead of perform, there could be a batch_perform behaviour with timeout options.

Closing this now, if that's ok! Thanks for your help.

from verk.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.