Skip to main content
Solved

What is included in "Duration" of a Cognite Function?


Forum|alt.badge.img

Hi,

Our project uses Cognite Function scheduling to deploy data to CDF, and we struggle to understand what the “Duration” of a Cognite Function actually represents. I have attached a screenshot showing one of our function calls, printing the duration of various function from our source code. As you see the duration of our source code takes 2+ minutes, but the call of the function itself takes less than 2 minutes (start at 7:40 and end at 7:41). Is there a distinction here between what is actually run in the backend, and overhead in terms of instantiating a call to the Cognite Function? Can anyone explain the apparent deviations?

 

Thanks.

 

 

Best answer by Ivar Stangeby

Hello @Vetle Nevland ! 

I work with the functions-team, so I can provide some insight here. 
To answer your questions:

  1. Yes, using threads should be no problem.
  2. The “duration” measures the execution time of your `handle`-function in addition to any overhead incurred by our backend. This overhead includes the time it takes for various messages to propagate around our backend, as well as any scaling of compute resources. 

Hope this helps! Let me know if you have any additional questions!

 

// Ivar Stangeby

 

 

View original

Forum|alt.badge.img

Also, our function counting alarms uses multithreading for parallel processing. Running locally takes significantly shorter time than Cognite Function calls. Have anyone experienced runtime issues when using multithreading together with Cognite Functions?


APSHANKAR Sagar
Committed

Inside CDF Functions, you can click on the function details tab and see that each function only runs on one core and 1.5 GB RAM so I don’t think parallel processing will work on CDF Functions. 


Dilini Fernando
Seasoned Practitioner
Forum|alt.badge.img+2

Hi @Vetle Nevland,

We are following up to see whether you're satisfied with the responses you've received? 


Forum|alt.badge.img

@APSHANKAR Sagar Thanks for answering. Sorry for delayed response, just returned from vacation. 

To clarify, we are counting and retrieving CDF Events concurrently using multiple threads with Python’s 

ThreadPool

class (single or multiple cores), not parallel processing with multiple cores. Can Cognite Functions handle this? 

Also, I still don’t understand why the Cognite Function executes for less than 2 minutes, while the backend code runs for more than 2 minutes. I see that multithreading is a known issue. Could this perhaps explain the observed deviations?


Hello @Vetle Nevland ! 

I work with the functions-team, so I can provide some insight here. 
To answer your questions:

  1. Yes, using threads should be no problem.
  2. The “duration” measures the execution time of your `handle`-function in addition to any overhead incurred by our backend. This overhead includes the time it takes for various messages to propagate around our backend, as well as any scaling of compute resources. 

Hope this helps! Let me know if you have any additional questions!

 

// Ivar Stangeby

 

 


Reply


Cookie Policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie Settings