Nitro servers - multithreaded?

I’m seeing some unexpected behaviour in my cloud code on a new nitro server. I have afterSave code that I would expect to run in series, yet it’s running in parallel. From what I can tell, when two events are logged from the same transaction, those two events both fire off an afterSave (expected), but the two afterSaves happen in parallel, not sequentially (in previous servers, event 2 would not be saved until event 1 completes processing).

The code is async, but I was under the impression that both Parse and MongoDb ran updates sequentially on a single thread (meaning that async updates allow for reads to be interspersed, but not writes). Is the Nitro upgrade multi-threaded in some way that the previous server was not?

usually an upgraded server is multithreaded, a nitro server shouldn’t be multithreaded if is not upgraded from what I know

Ok, it’s upgraded, so that answers the question. But… that’s a completely different philosophy to code for than the regular servers.

Can you check on whether it’s possible to do an atomic increment operation on the new NumberDecimal data type somehow? My workaround is not safe on a multithreaded environment. If that’s not possible, we may have to switch away from Moralis to another solution.

You can use redis to implement an equivalent of a mutex

Do you have some docs/tutorials on that?

you can use this in cloud code: client = redis.createClient({ host: "moralis-redis", port: 6379 })