Performance penalty of calling a CC function from another CC function

I have some CC functions which call other CC functions; as example let’s say I have a createAccount function which internally calls createProject, createUser etc., which in turn also might call other, more fine-grained CC functions.

I wonder if calling CC functions this way comes with a performance overhead: will those calls go through the network layer, marshalling and unmarshalling the request and response data; or will the server just call those functions directly and in-process?

Thanks :slight_smile:

How are you calling the other functions? Parse.Cloud.run? If yes, you need to make sure you have directAccess setting set true, otherwise it will go back to the network layer. Either way, I’d personally prefer to separate the cloud code function logic into a separate function, so, when calling the function, the call will go through less layers inside Parse Server. Something like this:

const myFunctionA = async (req) => {
  // ...
}

Parse.Cloud.define('myfunctionA', myfunctionA);

const myFunctionB = async (req) => {
  // ...
  myFunctionA(modifiedReq);
  // ...
}

Parse.Cloud.define('myfunctionB', myfunctionB);

Yes exactly, I’m talking about calling functions with Parse.Clound.run.

I didn’t know about directAccess, thanks for the hint! However, I couldn’t find it mentioned in the docs (except as an option for the file adapter); can you please point me to the relevant docs or some examples?

You can find directAccess Parse Server option in this page: ParseServerOptions - Documentation

Thanks! The phrase “Caution, this is an experimental feature that may not be appropriate for production” makes me a bit uneasy, but let’s see :smiley:

You may also want to try the recent beta release and see whether there is a performance improvement. Please feel free to share any feedback.