Can you define the task priority?

278 views Asked by At

I want to give an higher priority to some tasks that I perform on my Meteor application. I don't want to scale the application at this point.

I want to be able to process online payments and I've to insert related data on the database, I don't want to wait too long for this operation (assuming that the server as a constant high load). I want to write a function that will get an higher execution priority over the rest AND the same applies to database operation.

So when I try to save to Mongo: Payments.insert(paymentData), this method is sync but it's not the point, I want this insert to have top priority over any database operations.

How can I do it with a single instance Meteor application?

1

There are 1 answers

0
Keith Nicholas On

Node is single threaded. Meteor is built on that, and it uses a thing called 'Fibers' which semi simulates multithreading for singled threaded applications.

have a read of https://meteorhacks.com/fibers-eventloop-and-meteor.html

First thing you will see is that there is no concept of execution priority. You may be able to change how many requests a single client will process vs another client based on whether its handling payment.

However, if node is under high load as you claim, I don't think you can really help it too much if it can't keep up.