Functions

Introduction

Function-as-a-Service (FaaS) is a serverless compute model that lets you run code in response to events, without managing servers, containers, or runtime environments. With Krutrim Cloud FaaS, you can deploy small units of code called functions, and the platform automatically handles infrastructure provisioning, scaling, availability, and runtime updates. Functions execute only when triggered (such as by HTTP requests) and stop when the work is complete.

With Krutrim Cloud Functions you can remove operational complexity and accelerate development. Functions scale automatically based on demand, including scaling to zero when idle, and users pay only for actual execution rather than idle capacity. Built-in logging, metrics, and fault isolation improve reliability and observability.

Configurations

We currently offer 3 runtimes - Python, Node.js, Go

The configurations we offer are based on the maximum memory allocated to the function. Compute and storage are allocated in proportion to the amount of memory configured.

circle-info

To increase the memory, CPU power and storage allocated to your function, select a higher memory configuration.

Configuration
Memory
Use case

S (small)

256 MB

Basic APIs, lightweight tasks.

M (medium)

512 MB

Standard workloads.

L (large)

1024 MB

Data processing, ML inference.

XL (extra large)

2048 MB

Heavy computation.

2XL

4096 MB

Large-scale processing.

Billing

Functions are billed in GB-seconds.

GB-seconds = Allocated Memory (GB) × Total pod active duration (seconds)

Each function is charged at ₹0.001 per GB-second.

How billing works

  • Functions automatically scale between 1 to 10 pods based on incoming traffic.

  • Pods may remain running for a short duration after request completion to handle potential additional traffic.

  • Billing is calculated based on the total time the function pods remain active, including any idle time before they scale down.

  • You are not billed per request, but for the overall active runtime of the function infrastructure.

Example

If:

  • Memory allocated = 1 GB

  • A request executes in 2 seconds

  • The pods remained active for a total of 8 seconds before scaling down

Total usage = 1 GB × 8 seconds = 8 GB-seconds Total cost = 8 × ₹0.001 = ₹0.008

Create Function

  1. Go to 'Core Infrastructure > Compute > Functions' and click on the 'Create Function' button.

  2. Select the desired runtime for your function and add a function name.

  3. Select the memory configuration depending on your function size and needs.

  4. Add the timeout value for the function (default is set to 60 seconds). Timeout is the maximum duration a function is allowed to run. A shorter value will enable quick error detection and prevent resource leaks. Longer values are typically used to support ML and compute-heavy workloads.

  5. Add your code in the code editor. Click on the template button to add sample code to get you started.

  6. You can add environment variables in the 'Function Configuration' tab.

  7. Once you are satisfied with your function's code and settings, click on 'Create'. You can run the function to see outputs, after deployment.

  8. To test and manage your function, click on 'Manage' from the actions menu.

Manage Function

  1. You can modify your existing code from the 'Code' tab. Click on 'Save' to save your code, before building. Click on 'Build' to build your code and view build logs. Click on 'Deploy' to deploy your changes after a successful build.

  2. You can test your function on the 'Test' tab. The code here cannot be modified. In order to modify your existing code, use the 'Code' tab.

  3. Click on the 'Add test event' button, to add an event JSON. Click on 'Test' to run your function with the test event inputs.

  4. You can view your function's metrics and performance on the 'Monitor' page. They provide you with information such as duration of execution, number of invocations, error count etc. You can also view the build logs and runtime logs on this tab.

  5. You can edit your function's settings on the 'Function Configuration' tab. You can change the memory configuration, timeout value, and environment variables.

Last updated

Was this helpful?