You can override the
conserve-sockets setting for individual threads. These methods are in
org.apache.geode.distributed.DistributedSystem:setThreadsSocketPolicySets the calling thread’s individual socket policy, overriding the policy set for the application as a whole. If set to
true, the calling thread shares socket connections with other threads. If
false, the calling thread has its own sockets.
releaseThreadsSocketsFrees any sockets held by the calling thread. Threads hold their own sockets only when
conserve-sockets is
false. Threads holding their own sockets can call this method to avoid holding the sockets until the
socket-lease-time has expired.
Example function execution usage:
public void run() {
DistributedSystem.setThreadsSocketPolicy(false);
try {
// do your work
} finally {
DistributedSystem.releaseThreadsSockets();
}
}
Finally, if you are a heavy user of GemFire functions, you likely want to consider using the system property
gemfire.MAX_FE_THREADS and set it to some high appropriate value.
If you are not doing so and you have many functions executing concurrently, you may incur some unforeseen cost due to GemFire where once you surpass the default number of concurrent function executions there is some additional cost to throttle those executions.
The default for
MAX_FE_THREADS is the greater of the number of processors * 4, or 16. This is often completely insufficient for customers that are heavy users of GemFire functions.