NavigationContentFooter
Jump toSuggest an edit

Serverless Functions

How am I billed for Serverless Functions?

Principle

Serverless Functions is billed on a pay-as-you-go basis. Three components are taken into account:

  • Monthly Request number: each time your function is invoked we increase a counter.

  • Resource consumption: this component is obtained by multiplying the memory tiers chosen (128 MB, 256 MB, 512 MB, 1024 MB, 2048 MB) by the duration of each function invocation.

  • Resources provision: in order to mitigate cold start, users can choose to keep some function Instances warm (by filing the min scale value). We then charge for the provisioned resources similarly to the Resources consumption component.

The scheme below illustrates our billing model:

Pricing

  • Monthly requests: €0.15 per million requests and we offer 1M free requests per account per month.

  • Resources consumption: €1.20 per 100 000 GB-s and we provide 400 000 GB-s free tiers per account and per month.

Memory provisionedCost per second
128 MB€0.0000015
256 MB€0.0000030
512 MB€0.0000060
1024 MB€0.0000120
2048 MB€0.0000240
3072 MB€0.0000360
4096 MB€0.0000480
  • Resources provision: €0.36 per 100 000 GB-s
Memory provisionedCost per second
128 MB€0.00000045
256 MB€0.0000009
512 MB€0.0000018
1024 MB€0.0000036
2048 MB€0.0000072
3072 MB€0.0000108
4096 MB€0.0000144

Examples

Example 1: Without resources provisioning

CriteriaValue
Number of requests30 000 000
Average request duration1 s
Allocated resources (memory)128 MB
Free tierYes
Provision/minimum instances0
  • Resources consumption

    • Service usage duration: 30 000 000 Requests x 1 s = 30 000 000 seconds used
    • Memory conversion: 128 MB = 0.125 GB
    • Resources consumed: 30 000 000 s x 0.125 GB = 3 750 000 GB-s
    • Free tier: 400 000 GB-s
    • Resourced billed: 3 750 000 - 400 000 = 3 350 000 GB-s
    • Cost: 3 350 000 x €0.0000120 = €40.20
  • Requests:

    • Free tier: 1 000 000 requests
    • Billed requests: 30 000 000 - 1 000 000 = 29 000 000 Requests
    • Cost: 29 000 000 x €0.00000015 = €4.35

Total monthly cost: €44.55

Example 2: With resources provisioning

CriteriaValue
Number of requests30 000 000
Average request duration1 s
Allocated resources (memory)128 MB
Free tierYes
Provision/minimum instances1
  • Resources consumption

    • Service usage duration: 30 000 000 Requests x 1 s = 30 000 000 seconds used
    • Memory conversion: 128 MB = 0.125 GB
    • Resources consumed: 30 000 000 s x 0.125 GB = 3 750 000 GB-s
    • Free tier: 400 000 GB-s
    • Resourced billed: 3 750 000 - 400 000 = 3 350 000 GB-s
    • Cost: 3 350 000 x €0.0000120 = €40.20
  • Provisioned functions consumption:

    • Provisioned duration: 1 month = 2 592 000 seconds, with one minimum instance → 2 592 000 seconds used
    • Provisioned resources consumed: 2 592 000 x 0.125 GB = 324 000 GB-s
    • Cost: 324 000 x €0.0000036 = €1.17
  • Requests:

    • Free tier: 1 000 000 requests
    • Billed requests: 30 000 000 - 1 000 000 = 29 000 000 Requests
    • Cost: 29 000 000 x €0.00000015 = €4.35

Total monthly cost: €45.72

How to select the right resources (vCPU/RAM) for Serverless Functions ?

Insufficient vCPU and RAM resources can lead to functions going to error status. Make sure to provision enough resources for your function.

We recommend you set high values, use metrics to monitor the resource usage of your function, then adjust the value accordingly.

How to reduce cold-start of Serverless Functions ?

  • Optimize the startup: Cold-start can be affected by a loading a large number of dependencies and opening lot of resources at startup. Ensure that your code avoid heavy computations or long-running initialization at statup and optimize the number of loaded libraries.

  • Keep your function warm: You can use CRON triggers at certain intervals to keep your function warm or set the min-scale parameter to one when required.

  • Increase resources: Adding more vCPU and RAM can help to significantly reduce the cold-starts of your function.

  • Use sandbox v2: we recommend to use sandbox v2 (advanced settings) to reduce cold start.

What are the limitations of Serverless Functions?

Refer to our dedicated page about Serverless Functions limitations and configuration restrictions for more information.

What runtimes are available on Serverless Functions?

Serverless Functions enables you to deploy functions using popular languages: Go, Node, Python, PHP, Rust

Refer to our dedicated page about Serverless Functions Runtimes Lifecycle

How can I check build errors?

Some Serverless runtimes (ex: Go, Rust) will compile your code in order to make your function executable. Compilation can fail if errors are present in the code, for example syntax errors and missing libraries.

Build errors are sent to the Observability platform on Scaleway Cockpit.

In the Serverless Functions Logs dashboard, you will then be able to read information about your log build outputs, if errors occurred during compilation.

Can I allow to list the IPs of my functions?

Serverless Functions does not yet support Private Networks. However, you can use the Scaleway IP ranges defined at https://www.scaleway.com/en/peering/ on Managed Databases and other products that allow IP filtering.

How can I deploy my Functions?

Serverless Functions use cases are wide so several ways to deploy functions are available.

How can I test my functions locally?

Local development is useful for debugging, profiling, testing etc… so we provide libraries to do this: local testing doc.

Where can I find some advanced code examples for functions?

Check out our serverless-examples repository for real world projects.

How to migrate runtimes?

There are no constraints when changing a function runtime, you simply need to choose the runtime version you want. Upgrading a runtime is highly recommended in case of deprecation, and for runtimes that have reached end-of-support or end-of-life. See the functions runtimes lifecycle documentation for more information.

Docs APIScaleway consoleDedibox consoleScaleway LearningScaleway.comPricingBlogCarreer
© 2023-2024 – Scaleway