Giter VIP home page Giter VIP logo

Comments (2)

arunoda avatar arunoda commented on July 19, 2024

It's very tricky to run these kind of stuff. This is not only for cores,
think what will be happen when you are running multiple servers of your app.

Here's a way to to that.

  • Inside every worker there's a env variable called CLUSTER_WORKER_ID.
    Try to create the observer when there is no such worker
  • When you are running multiple servers, expose a new env for only one
    server. And check for that env as well.
  • So, this observer runs on a single server and single core.

You can even look at some other stuffs like, doing these things as a job
queue or running different app.

On Fri, May 1, 2015 at 1:49 AM Vu Pham [email protected] wrote:

I'm running to an issue that I have an Mongo update query in startup code
of server:

if (Meteor.isServer) {
Meteor.startup(function(){
Posts.find().observeChanges({
added: function(id, fields) {
Authors.update({_id: fields.authorId}, {$inc: {count: 1}});
}
})
});
}

I run app with 4 cores server and this added event run 4 times which I
expected just 1.
Is there a way in app that we can detect current running core? Or any
other best practices to run observerChanges in multicore environment?


Reply to this email directly or view it on GitHub
#51.

from cluster.

vuhpham avatar vuhpham commented on July 19, 2024

Thanks @arunoda I think I'd better run this in a microservice then.
However that env variable is nice as well. 👍

from cluster.

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.