Yandex Cloud
Search
Contact UsGet started
  • Pricing
  • Customer Stories
  • Documentation
  • Blog
  • All Services
  • System Status
    • Featured
    • Infrastructure & Network
    • Data Platform
    • Containers
    • Developer tools
    • Serverless
    • Security
    • Monitoring & Resources
    • AI Studio
    • Business tools
  • All Solutions
    • By industry
    • By use case
    • Economics and Pricing
    • Security
    • Technical Support
    • Start testing with double trial credits
    • Cloud credits to scale your IT product
    • Gateway to Russia
    • Cloud for Startups
    • Education and Science
    • Yandex Cloud Partner program
  • Pricing
  • Customer Stories
  • Documentation
  • Blog
© 2025 Direct Cursus Technology L.L.C.
Yandex Cloud Functions
  • Comparison with other Yandex Cloud services
    • Overview
    • Function
    • Invoking a function
    • Asynchronous function invocation
    • Long-lived functions
    • Function termination notifications
    • Networking
      • Overview
      • Environment
      • Execution context
      • Preloaded runtime environment
    • Mounting external resources to a function file system
    • Builder
    • Dead Letter Queue
    • Function logs
    • Backups
    • Quotas and limits
  • Tools
  • Pricing policy
  • Access management
  • Terraform reference
  • Monitoring metrics
  • Audit Trails events
  • Release notes
  • FAQ
  1. Concepts
  2. Runtime environment
  3. Execution context

Execution context

Written by
Yandex Cloud
Updated at June 11, 2025

The execution context is a temporary runtime environment that initializes the external dependencies of your function code, such as database connections and HTTP endpoints.

When calling each function, Cloud Functions starts the execution context based on the configuration parameters that the user defined when creating that function. The service provides and manages the resources required for function calls.

A function may be delayed when called for the first time or after an update, because the service sets up the execution context and initializes the function. For subsequent function calls, the service tries to reuse the execution context. This ensures better performance for subsequent calls, as there is no need to perform the entire startup process again or reinstall the dependencies.

Initialization only takes place when a new function instance is created. Cloud Functions creates a new function instance at function call if there are no function instances or not enough of them to process calls. If several function calls are processed by the same instance, initialization only takes place at the first call.

Reusing the execution contextReusing the execution context

Once a function is executed, the context is kept pending for the function to be called again. It means that:

  • Any declarations in the function code (outside the handler code) remain initialized, providing additional optimization when the function is called again.

    For example, if the function establishes a database connection, the original connection is used in subsequent calls instead of reconnecting. You can add logic to your code that will check whether a connection exists before creating a new one.

  • Each execution context provides 512 MB of additional disk space in the /tmp folder. The directory contents remain in the execution context providing a temporary cache that can be used for multiple calls. You can add extra code to check if the cache contains any data that you saved.

    Note

    The NOEXEC flag is set for the file system mounted in the /tmp folder. This disables the execution of binary files saved in this folder.

  • Background processes or callbacks initiated by your function, which were not completed before the function execution is complete, are resumed if the execution context is reused.

    There may be situations when the service needs to create a new execution context. This may lead to unexpected results, such as database connectivity failures. Make sure that any background processes or callbacks in your code have completed before the function execution is complete.

Was the article helpful?

Previous
Environment
Next
Preloaded runtime environment
© 2025 Direct Cursus Technology L.L.C.