[feat] Pulsar Functions should provide a way to set Pulsar client memory limit #23723
Open
1 of 2 tasks
Labels
area/function
type/enhancement
The enhancements for the existing features or docs. e.g. reduce memory usage of the delayed messages
Search before asking
Motivation
I haven't found a way to tune the memory limit for the Pulsar client used in Pulsar Functions.
The memory limit is disabled in Pulsar Functions:
pulsar/pulsar-functions/instance/src/main/java/org/apache/pulsar/functions/instance/InstanceUtils.java
Line 161 in 82237d3
There's code for configuring it:
pulsar/pulsar-functions/runtime/src/main/java/org/apache/pulsar/functions/runtime/thread/ThreadRuntimeFactory.java
Lines 106 to 168 in 05e57dd
but it doesn't get called in the JavaInstanceStarter case. The JavaInstanceStarter is used when running Java functions in process / k8s / function mesh runtimes (other than thread runtime):
pulsar/pulsar-functions/runtime/src/main/java/org/apache/pulsar/functions/runtime/JavaInstanceStarter.java
Lines 236 to 245 in 567174f
Optional.empty()
is passed to memory limit.pulsar/pulsar-functions/runtime/src/main/java/org/apache/pulsar/functions/runtime/thread/ThreadRuntimeFactory.java
Lines 92 to 104 in 05e57dd
It looks like the memory limit solution has been only implemented for the ThreadRuntimeFactory in #9320. When using ThreadRuntimeFactory, it's possible to set the limit in
conf/functions_worker.yml
. This isn't helpful for other runtime types (process, k8s).Solution
Add the Pulsar client memory limit configuration to
org.apache.pulsar.common.functions.FunctionConfig
,org.apache.pulsar.functions.instance.InstanceConfig
andorg.apache.pulsar.functions.worker.WorkerConfig
and make it configurable in the same way as other instance config parameters such asmaxPendingAsyncRequests
.The default would be configured in
WorkerConfig
for all functions and the function configuration would be inInstanceConfig
and configurable withFunctionConfig
in yaml and command line.It's not fully consistent how configs should be handled. There's also the protobuf
org.apache.pulsar.functions.proto.Function.FunctionDetails
where configs are passed.Are you willing to submit a PR?
The text was updated successfully, but these errors were encountered: