Allocate resources to function instance

When running functions in cluster mode, you can specify the resources that can be allocated to each function instance.

The following table outlines the resources that can be allocated to function instances.

ResourceSpecified asSupported runtime
CPUThe number of coresKubernetes
RAMThe number of bytesKubernetes
Disk spaceThe number of bytesKubernetes

For example, the following command allocates 8 cores, 8GB of RAM, and 10GB of disk space to a function.

  1. bin/pulsar-admin functions create \
  2. --jar $PWD/target/my-functions.jar \
  3. --classname org.example.functions.MyFunction \
  4. --cpu 8 \
  5. --ram 8589934592 \
  6. --disk 10737418240

Allocate resources to function instance - 图1note

The resources allocated to a given function are applied to each instance of the function. For example, if you apply 8GB of RAM to a function with a parallelism of 5, you are applying 40GB of RAM for the function in total.