Is there a way to programmatically know how many concurrent instances of a Lambda function are executing?










0















Lets suppose, at a given time, several instances of a particular Lambda function have been invoked asynchronously,



Then, is there a way to find how many active concurrent instances of the Lambda function are currently running?



In the account level metrics in the Dashboard we can find the number of concurrent executions. Also, I think for each new Lambda container creation, Cloudwatch creates a new Log Stream for the Lambda function. Maybe it is possible to somehow use those.



But I was wondering if there exists a different way to get these numbers programmatically, for example like using boto3 api etc.?










share|improve this question


























    0















    Lets suppose, at a given time, several instances of a particular Lambda function have been invoked asynchronously,



    Then, is there a way to find how many active concurrent instances of the Lambda function are currently running?



    In the account level metrics in the Dashboard we can find the number of concurrent executions. Also, I think for each new Lambda container creation, Cloudwatch creates a new Log Stream for the Lambda function. Maybe it is possible to somehow use those.



    But I was wondering if there exists a different way to get these numbers programmatically, for example like using boto3 api etc.?










    share|improve this question
























      0












      0








      0








      Lets suppose, at a given time, several instances of a particular Lambda function have been invoked asynchronously,



      Then, is there a way to find how many active concurrent instances of the Lambda function are currently running?



      In the account level metrics in the Dashboard we can find the number of concurrent executions. Also, I think for each new Lambda container creation, Cloudwatch creates a new Log Stream for the Lambda function. Maybe it is possible to somehow use those.



      But I was wondering if there exists a different way to get these numbers programmatically, for example like using boto3 api etc.?










      share|improve this question














      Lets suppose, at a given time, several instances of a particular Lambda function have been invoked asynchronously,



      Then, is there a way to find how many active concurrent instances of the Lambda function are currently running?



      In the account level metrics in the Dashboard we can find the number of concurrent executions. Also, I think for each new Lambda container creation, Cloudwatch creates a new Log Stream for the Lambda function. Maybe it is possible to somehow use those.



      But I was wondering if there exists a different way to get these numbers programmatically, for example like using boto3 api etc.?







      aws-lambda






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Nov 15 '18 at 1:27









      Anirban DasAnirban Das

      284




      284






















          1 Answer
          1






          active

          oldest

          votes


















          1














          The short answer is no.



          You can programatically access cloudwatch metrics (see: boto3 CloudWatch.Client.get_metric_data), however these metrics lag behind by a minute. Even worse, while individual lambdas return invocations, you can only get ConcurrentExecutions across the whole of your account- which means the best you could ever do is if you put a lambda in it's own AWS account, and even then you'd still be a minute behind- which is typically longer than the average lambda lifespan.



          I should point out, though, that through 'reserved concurrency' lambda does expose a way to, atleast rudimentarily, control concurrency. The example use-case for this is if you are calling an external service/database that has a limited connection pool.






          share|improve this answer























          • Thanks a lot for the explanation. Though, I wonder why AWS would not let us access this information.

            – Anirban Das
            Nov 15 '18 at 19:11











          • I guess it's because aws wants lambda to be treated as this stateless execution resource that isn't effected by its concurrency (for example, I suspect that answering the same question for any server cluster framework world hard). As an exercise I would suggest you ask this question again in terms of what you're trying to achieve by watching concurrency to see if there's a more 'lamdaish' way of achieving it.

            – thomasmichaelwallace
            Nov 15 '18 at 22:14










          Your Answer






          StackExchange.ifUsing("editor", function ()
          StackExchange.using("externalEditor", function ()
          StackExchange.using("snippets", function ()
          StackExchange.snippets.init();
          );
          );
          , "code-snippets");

          StackExchange.ready(function()
          var channelOptions =
          tags: "".split(" "),
          id: "1"
          ;
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function()
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled)
          StackExchange.using("snippets", function()
          createEditor();
          );

          else
          createEditor();

          );

          function createEditor()
          StackExchange.prepareEditor(
          heartbeatType: 'answer',
          autoActivateHeartbeat: false,
          convertImagesToLinks: true,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: 10,
          bindNavPrevention: true,
          postfix: "",
          imageUploader:
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          ,
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          );



          );













          draft saved

          draft discarded


















          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53311165%2fis-there-a-way-to-programmatically-know-how-many-concurrent-instances-of-a-lambd%23new-answer', 'question_page');

          );

          Post as a guest















          Required, but never shown

























          1 Answer
          1






          active

          oldest

          votes








          1 Answer
          1






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes









          1














          The short answer is no.



          You can programatically access cloudwatch metrics (see: boto3 CloudWatch.Client.get_metric_data), however these metrics lag behind by a minute. Even worse, while individual lambdas return invocations, you can only get ConcurrentExecutions across the whole of your account- which means the best you could ever do is if you put a lambda in it's own AWS account, and even then you'd still be a minute behind- which is typically longer than the average lambda lifespan.



          I should point out, though, that through 'reserved concurrency' lambda does expose a way to, atleast rudimentarily, control concurrency. The example use-case for this is if you are calling an external service/database that has a limited connection pool.






          share|improve this answer























          • Thanks a lot for the explanation. Though, I wonder why AWS would not let us access this information.

            – Anirban Das
            Nov 15 '18 at 19:11











          • I guess it's because aws wants lambda to be treated as this stateless execution resource that isn't effected by its concurrency (for example, I suspect that answering the same question for any server cluster framework world hard). As an exercise I would suggest you ask this question again in terms of what you're trying to achieve by watching concurrency to see if there's a more 'lamdaish' way of achieving it.

            – thomasmichaelwallace
            Nov 15 '18 at 22:14















          1














          The short answer is no.



          You can programatically access cloudwatch metrics (see: boto3 CloudWatch.Client.get_metric_data), however these metrics lag behind by a minute. Even worse, while individual lambdas return invocations, you can only get ConcurrentExecutions across the whole of your account- which means the best you could ever do is if you put a lambda in it's own AWS account, and even then you'd still be a minute behind- which is typically longer than the average lambda lifespan.



          I should point out, though, that through 'reserved concurrency' lambda does expose a way to, atleast rudimentarily, control concurrency. The example use-case for this is if you are calling an external service/database that has a limited connection pool.






          share|improve this answer























          • Thanks a lot for the explanation. Though, I wonder why AWS would not let us access this information.

            – Anirban Das
            Nov 15 '18 at 19:11











          • I guess it's because aws wants lambda to be treated as this stateless execution resource that isn't effected by its concurrency (for example, I suspect that answering the same question for any server cluster framework world hard). As an exercise I would suggest you ask this question again in terms of what you're trying to achieve by watching concurrency to see if there's a more 'lamdaish' way of achieving it.

            – thomasmichaelwallace
            Nov 15 '18 at 22:14













          1












          1








          1







          The short answer is no.



          You can programatically access cloudwatch metrics (see: boto3 CloudWatch.Client.get_metric_data), however these metrics lag behind by a minute. Even worse, while individual lambdas return invocations, you can only get ConcurrentExecutions across the whole of your account- which means the best you could ever do is if you put a lambda in it's own AWS account, and even then you'd still be a minute behind- which is typically longer than the average lambda lifespan.



          I should point out, though, that through 'reserved concurrency' lambda does expose a way to, atleast rudimentarily, control concurrency. The example use-case for this is if you are calling an external service/database that has a limited connection pool.






          share|improve this answer













          The short answer is no.



          You can programatically access cloudwatch metrics (see: boto3 CloudWatch.Client.get_metric_data), however these metrics lag behind by a minute. Even worse, while individual lambdas return invocations, you can only get ConcurrentExecutions across the whole of your account- which means the best you could ever do is if you put a lambda in it's own AWS account, and even then you'd still be a minute behind- which is typically longer than the average lambda lifespan.



          I should point out, though, that through 'reserved concurrency' lambda does expose a way to, atleast rudimentarily, control concurrency. The example use-case for this is if you are calling an external service/database that has a limited connection pool.







          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered Nov 15 '18 at 9:38









          thomasmichaelwallacethomasmichaelwallace

          2,6901918




          2,6901918












          • Thanks a lot for the explanation. Though, I wonder why AWS would not let us access this information.

            – Anirban Das
            Nov 15 '18 at 19:11











          • I guess it's because aws wants lambda to be treated as this stateless execution resource that isn't effected by its concurrency (for example, I suspect that answering the same question for any server cluster framework world hard). As an exercise I would suggest you ask this question again in terms of what you're trying to achieve by watching concurrency to see if there's a more 'lamdaish' way of achieving it.

            – thomasmichaelwallace
            Nov 15 '18 at 22:14

















          • Thanks a lot for the explanation. Though, I wonder why AWS would not let us access this information.

            – Anirban Das
            Nov 15 '18 at 19:11











          • I guess it's because aws wants lambda to be treated as this stateless execution resource that isn't effected by its concurrency (for example, I suspect that answering the same question for any server cluster framework world hard). As an exercise I would suggest you ask this question again in terms of what you're trying to achieve by watching concurrency to see if there's a more 'lamdaish' way of achieving it.

            – thomasmichaelwallace
            Nov 15 '18 at 22:14
















          Thanks a lot for the explanation. Though, I wonder why AWS would not let us access this information.

          – Anirban Das
          Nov 15 '18 at 19:11





          Thanks a lot for the explanation. Though, I wonder why AWS would not let us access this information.

          – Anirban Das
          Nov 15 '18 at 19:11













          I guess it's because aws wants lambda to be treated as this stateless execution resource that isn't effected by its concurrency (for example, I suspect that answering the same question for any server cluster framework world hard). As an exercise I would suggest you ask this question again in terms of what you're trying to achieve by watching concurrency to see if there's a more 'lamdaish' way of achieving it.

          – thomasmichaelwallace
          Nov 15 '18 at 22:14





          I guess it's because aws wants lambda to be treated as this stateless execution resource that isn't effected by its concurrency (for example, I suspect that answering the same question for any server cluster framework world hard). As an exercise I would suggest you ask this question again in terms of what you're trying to achieve by watching concurrency to see if there's a more 'lamdaish' way of achieving it.

          – thomasmichaelwallace
          Nov 15 '18 at 22:14



















          draft saved

          draft discarded
















































          Thanks for contributing an answer to Stack Overflow!


          • Please be sure to answer the question. Provide details and share your research!

          But avoid


          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.

          To learn more, see our tips on writing great answers.




          draft saved


          draft discarded














          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53311165%2fis-there-a-way-to-programmatically-know-how-many-concurrent-instances-of-a-lambd%23new-answer', 'question_page');

          );

          Post as a guest















          Required, but never shown





















































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown

































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown







          這個網誌中的熱門文章

          How to read a connectionString WITH PROVIDER in .NET Core?

          In R, how to develop a multiplot heatmap.2 figure showing key labels successfully

          Museum of Modern and Contemporary Art of Trento and Rovereto