# Workloads & Metrics

**URL:** https://community.temporal.io/t/workloads-metrics/4002
**Category:** Community Support
**Tags:** best-practices, activity, java-sdk, performance
**Created:** [February 15, 2022, 11:41pm UTC](https://community.temporal.io/t/workloads-metrics/4002 "2022-02-15T23:41:41Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![Andrex\_17](https://sea2.discourse-cdn.com/flex016/user_avatar/community.temporal.io/andrex_17/32/727_2.png) [@Andrex\_17](https://community.temporal.io/u/Andrex_17)
#### Post date: [February 15, 2022, 11:41pm UTC](https://community.temporal.io/t/workloads-metrics/4002/1 "2022-02-15T23:41:41Z")

</div>

Hi everyone,

I would like some advice on the correct management of the options of the temporal workers.  
I have a pre production environment that needs to launch 100 (more or less) activities in parallel, but initially I was getting java heap space problem.  
After setting parameters such as **ActivityPollThreadCount** = 5, **MaxConcurrentActivityExecutionSize** = 20, **MaxTaskQueueActivitiesPerSecond** = 0.2 and **MaxWorkerActivitiesForSecond** = 0.2, now I rarely get heap space, but it’s not completely gone.  
Can I check, with some specific metrics, if the ram memory or the cpu of a microservice is usable or not before launching a scheduled activity? Otherwise, do you have any advice on this to avoid starting too many activities at the same time, based on memory usage? (each activity, based on its input, can use more or less memory based on the set of data to be processed)

Thx a lot  
A.

---

<div class="post-metadata">

### Author: ![maxim](https://sea2.discourse-cdn.com/flex016/user_avatar/community.temporal.io/maxim/32/8_2.png) [@maxim](https://community.temporal.io/u/maxim)
#### Post date: [February 16, 2022, 5:01pm UTC](https://community.temporal.io/t/workloads-metrics/4002/3 "2022-02-16T17:01:21Z")

</div>

You could implement a workflow that would manage the worker. This workflow would receive signals with requests to execute the activity and signals from the worker to indicate that there is available capacity. Then based on this information, it would be able to execute activities on that worker according to whatever policy is appropriate.

---

<div class="post-metadata">

### Author: ![Andrex\_17](https://sea2.discourse-cdn.com/flex016/user_avatar/community.temporal.io/andrex_17/32/727_2.png) [@Andrex\_17](https://community.temporal.io/u/Andrex_17)
#### Post date: [February 16, 2022, 10:31pm UTC](https://community.temporal.io/t/workloads-metrics/4002/5 "2022-02-16T22:31:03Z")

</div>

Thx for response Maxim.  
Then there isn’t any native implementation to manage it? Or i could use some grafana’s metrica to achieve it?  
Last question, in ur opinion the best way to manage it is create this mechanism that u explained or use kube metrics on pod and scale it when theshold was reached?

I appreciate ur work and tips.  
Thx a lot.  
A.

---

<div class="post-metadata">

### Author: ![maxim](https://sea2.discourse-cdn.com/flex016/user_avatar/community.temporal.io/maxim/32/8_2.png) [@maxim](https://community.temporal.io/u/maxim)
#### Post date: [February 17, 2022, 1:29am UTC](https://community.temporal.io/t/workloads-metrics/4002/6 "2022-02-17T01:29:15Z")

</div>

Filed [Add ability to dynamically limit number of parallel activities · Issue #1042 · temporalio/sdk-java · GitHub](https://github.com/temporalio/sdk-java/issues/1042)
