Recycle Agents Automatically
Cause
MS-Agents use Session Memory and Overhead Memory. Session memory is allocated for ABL sessions spawned by the agent. Overhead Memory is the memory that the agent uses for overhead, to manage sessions and route requests, etc.
The memory is allocated to the ABL session. Some memory is shared with other sessions (parts of database connection information, shared procedure libraries and a few other things). When a request comes in, a thread is assigned to the memory for the session, and the .p code is run within the context of that session. When the request completes, the memory (in state-free) is left more or less as-is, and the thread is freed back into the pool for further use by the next request that needs it. If a session isn't bound to a thread, then nothing is happening with that session.
Be aware that memory freed by an application, may still reside within the memory allocated to that app by the OS. The OS may not immediately reclaim the memory. The OS itself has heuristics based on memory pressure for when the memory is actually reclaimed for use by other processes. Each OS is a bit different in how this is handled. That is to say, terminating a session won't necessarily make the memory for the agent process shrink immediately (or at all).
Once ABL session is terminated - instead of releasing the memory to the OS and asking again every time, the agent holds the memory and use it for the next requests. To release that memory to OS recycle of MS-Agents can be done.
Resolution
This is intended to work with a PAS instance configured with maxAgents >= 2. Recommendation is to have a min/initial number of 2 agents, with enough sessions/connections configured to handle typical workload on one agent, so that a “spare” is always available to begin taking requests. After stopping the agent, traffic that was originally handled by the lead agent (to stop and recycle) requests are handled by the next agent available to the PAS instance. The minAgents = 2 will assure the agent is started and available.
ProDiscoverer tools use oemanager REST APIs which gracefully stop MS-Agent (starting from OE 11.7.2) – i.e. MS-Agent completes all requests before stopping. Once the agent is terminated – only then the memory allocated to MS-Agent goes back to the OS (hint -the OS may not immediately reclaim the memory).
Recycle Agents automatically
- Configure ProDiscoverer scheduler to run “RecycleAgents” task for:
- Specific PAS instance.
- Specific ABL Application for that PAS instance.
- Time interval in milliseconds to run the task job.
- Threshold value for Total Session Manager memory to trigger agent’s recycle process.
- Start scheduler task “RecycleAgents” for the ABL Application.
- ProDiscoverer will automatically schedule jobs run per interval specified.
- Scheduled job will perform actions:
- If „spare“ MS-Agent is not already running – starts it as a new MS-Agent.
- Fetches all MS-Agents for the PAS ABL Application.
- Calculates Session Memory used by each MS-Agent.
- Evaluates Total Session Memory to the threshold value to trigger agent‘s recycle process.
- Gracefully stops the MS-Agent with the highest Session Memory usage.
- Writes action details to ProDiscoverer database for future reference.
- Actions taken by the scheduler can be viewed in “Actions” tab grid under menu option “Audit”.