BES 4.x Threading Model
Posted 07-31-2009 at 05:00 AM by hdawg
Tags agent stop, agent threading, bes hung thread, bes magt, bes threading model, bes threads, blackberry magt, hung agent, restart agent, restart threads
Understanding the threading model of your BES is key to properly building and scaling your environment. In addition, truly knowing how your environment works further empowers you to be confident with its support.
A server utilizing its threads in a healthy manner provides the best possible user experience, allows you to load your servers to capacity, and effectively utilizes your BES hardware. By allocating the proper amount of resources and tweaking your threading configuration to meet your environments requirements you can ensure that BES interacts with your messaging services in the most optimal manner.
RIM has already put together information on the Domino 4.x threading model, so here we'll focus on the Exchange 4.x threading model.
Here are some basics / default rules on Exchange 4.x threading:
Database Configuration
Adding Users / Messaging Agents & Users per Agent
Threads
The BlackBerry Dispatcher spawns Messaging Agents, and the Messaging Agents allocates MAPI Threads. When the BES starts up it creates MAPI sessions (also called Thread Pools) to the Exchange servers, assigning up to 50 users per MAPI session. If a given Exchange server has 225 users, it'll spawn 5 MAPI sessions allocating 50/50/50/50/25 users to those sessions.
Each Messaging Agent can have a maximum of 100 threads allocated and each thread pool (or MAPI Session) can have a maximum of 5 threads. Once the BES has started up it reallocates available threads for optimal performance as is can. Keeping the ratio of users to threads as low as possible helps ensure peak performance.
Optimizing Performance
A server utilizing its threads in a healthy manner provides the best possible user experience, allows you to load your servers to capacity, and effectively utilizes your BES hardware. By allocating the proper amount of resources and tweaking your threading configuration to meet your environments requirements you can ensure that BES interacts with your messaging services in the most optimal manner.
RIM has already put together information on the Domino 4.x threading model, so here we'll focus on the Exchange 4.x threading model.
Here are some basics / default rules on Exchange 4.x threading:
Database Configuration
- If you install BES with a local SQL Server (MSDE / SQL Express) by default only a maximum of 2 messaging agents. (Registry Key: HKLM\SOFTWARE\Research In Motion\BlackBerry Enterprise Server\Agents\NumAgents set to a value of 2 ... this is to manage limits imposed by MSDE Governor).
- If using a remote SQL server a maximum of 5 Messaging Agents will spawn by default.
Adding Users / Messaging Agents & Users per Agent
- Adding the first user to a BES spawns a single Messaging Agent
- Adding a second user (from the same Excahnge server) places the new user on that same Messaging Agent
- Adding a third user (from the same Exchange server) adds the user to the same Messaging Agent. By default this process continues up to 500 users, at which point user 501 would be allocated to a second Messaging Agent.
- If in the scenario here, after we added the second user, we added a third user from a different Exchange server a second Messaging Agent would be spawned.
- As users are added from additional Exchange servers additional Messaging Agents will be spawned, up to a maximum of 5 by default.
- If a user from a 6th Exchange server is added to the BES, the user is assigned to an existing Messaging Agent. The same process takes place as users are added from additional Exchange servers.
Threads
The BlackBerry Dispatcher spawns Messaging Agents, and the Messaging Agents allocates MAPI Threads. When the BES starts up it creates MAPI sessions (also called Thread Pools) to the Exchange servers, assigning up to 50 users per MAPI session. If a given Exchange server has 225 users, it'll spawn 5 MAPI sessions allocating 50/50/50/50/25 users to those sessions.
Each Messaging Agent can have a maximum of 100 threads allocated and each thread pool (or MAPI Session) can have a maximum of 5 threads. Once the BES has started up it reallocates available threads for optimal performance as is can. Keeping the ratio of users to threads as low as possible helps ensure peak performance.
Optimizing Performance
- Group BES users by the Exchange server that they are on. Limiting the number of Exchange servers that a BES has to communicate with is the first step to limiting or eliminating hung or non-responsive threads.
- Evenly distribute BES users across your Exchange servers. If you have 500 BES users and 2 Exchange servers, your most optimal configuration would most likely be 250 BES users per Exchange server. If you allocate the majority of your BES users from one Exchange server problems with that server would have a greater impact on your overall BES community.
- Evenly distribute Exchange users across multiple BES. If you have multiple BlackBerry servers and multiple Exchange servers, assign users from Exchange servers in a balanced method. If you have 8 Exchange servers and 2 BlackBerry servers assign users from 4 Exchange servers to each BES, rather than a split of 6 and 2.
- Remove inactive accounts. If a user account is created on the BES it is using resources. Remove it if it isn't being used!
- Locate your BESAdmin mailbox close to your BES.
- If you have multiple Exchange servers and multiple BlackBerry servers create a separate BESAdmin account / mailbox for each one. You can have multiple BESAdmin accounts sharing the same BlackBerry Configuration Database. By allocating a separate mailbox for each BES you're further removing a single point of failure if for some reason one of the Exchange servers is down. The BESAdmin mailbox can be changed at any time for a BES if needed.
- Tweak your NumAgents and MaxUsersPerAgent registry settings as you see appropriate. We all can't follow the rules and recommendations provided in every environment, so these tweaks allow you to customize your environment.
Total Comments 2
Comments
-
Excellent article H.
I especially like the suggestion to create a separate BESAdmin mailbox for each Exchange server. Just so I am clear on it, can you confirm this example:
you have a BES and two Exchange servers, with your BESAdmin1 account on Exchange1 and BESAdmin2 on Exchange2. Exchange1 has whatever type of failure; all you'd have to do is change the MAPI profile on your BES to use BESAdmin2 on Exchange2 correct? Specifically, as long as the AD account itself is fine, you don't have to change any service log ons or anything else to use BESAdmin2?Posted 07-31-2009 at 02:54 PM by jdizzle
-
Posted 08-02-2009 at 12:03 AM by hdawg












