27.3. Setting Up Multithreaded ModeOracle Database 10g Release 1 introduced a way for multiple sessions to share a single external procedure process. Although this feature takes a bit of effort to set up, it could pay off when you have many users running external procedures. Here are the minimum steps required for your DBA to turn on multithreaded mode:
To see if it's working, you can use the "lsnrctl services" command:
This output is what we hoped to see; the agent is listed in state "ready," and is not labeled as dedicated. This command also shows stats on the number of sessions; in the output above, everything is "0" except the maximum number of sessions, which defaults to 5. Internally, a multithreaded agent uses its own listener/dispatcher/worker bee arrangement, allowing each session request to get handed off to its own thread of execution. You can control the numbers of tasks using "agtctl set" commands. For example, to modify the maximum number of sessions, first shut down the agent:
Then set max_sessions:
Where n is the maximum number of Oracle sessions that can connect to the agent simultaneously. Finally, restart the agent:
When tuning your setup, there are several parameter settings to be aware of:
By the way, while testing this feature, I discovered that whenever I bounced the listener, afterwards I needed to bounce the agent as well. Fortunately, the agtctl utility kindly remembers any parameter adjustments you have made from the default values. Some experimentation may be needed to optimize the agent-specific parameters against the number of agent processes. While I have not experimented enough with multithreaded agents to offer any rules of thumb, let's at least take a look at the changes required to use two multithreaded agents. Follow the steps given earlier, but this time, in Step 7, you will start two agents with unique names:
You must also modify tnsnames.ora (Step 3 above) to be aware of these new agent names; because you probably want Oracle Net to "load balance" across the agents, edit the EXTPROC_CONNECTION_DATA section of tnsnames.ora to be:
You need to add the DESCRIPTION_LIST parameter and include one description section for each of the agents. With this new configuration, each time Oracle Net receives a request from PL/SQL to connect to an external procedure, Oracle Net will randomly connect to one of the agents listed; if the connection fails (for example, because it already has the maximum number of sessions connected), Oracle Net will try the other agent, until it either makes a successful connection or fails to connect to any of them. Such a failure will result in ORA-28575: unable to open RPC connection to external procedure agent. You can read more about multithreaded mode and agtctl in Oracle's Application Development GuideFundamentals and the Heterogenous Connectivity Administrator's Guide. Oracle Net's load balancing features are described in the Net Services Administrator's Guide and the Net Services Reference. One final point: when using multithreaded agents, the C program that implements an external procedure must be thread-safe, and writing such a beasty is not necessarily trivial. See the notes at the end of this chapter for a few of the caveats. |
Saturday, October 31, 2009
Section 27.3. Setting Up Multithreaded Mode
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment