3 Best Practices to Optimize Performance

This section contains the following topics:

3.1 Self-Tuning Lock Mechanism

3.1.1 Scenarios Recommended

A proper SPINCOUNT indicates a server can hold the BB lock via user level method at most time. It can significantly improve the performance in the scenarios where BB lock conflict is heavy. The typical scenario is the transactional application using Tuxedo XA mechanism. So it is recommended to enable this feature on the Oracle Exalogic by default in a Tuxedo application unless the CPU is not enough.

3.1.2 Setting the Number of Lock Spins

A process or thread locks the bulletin board through user level method or system level method. Because system level method is a costly operation, it is efficient to set a proper number of lock spins so that most lock attempts are achieved through user level method.

A process on a uniprocessor system should not spin. A SPINCOUNT value of 1 is appropriate for uniprocessors. On multiprocessors, the value of the SPINCOUNT parameter is application- and system-dependent. Self-Tuning Lock Mechanism can figure out the proper SPINCOUNT automatically.

3.2 Shared Memory Interprocess Communication

3.2.1 Scenarios Recommended

SHMQ helps you to gain higher performance in the native Tuxedo application by reducing unnecessary message copy. It can be considered to enable this feature when one or more cases are met in the following list:

  • big request/reply message
  • simple/little service

    If the service routine itself does not spend too much time, the performance should be improved with this feature by reducing the message copy.

  • IPC resource

    Not only more shared memory, but also extra semaphores are necessary if this features enabled. It is recommended to check the minimum IPC resources via tmloacf -c before using this feature.

3.2.2 Adjust SHMQMAXMEM

The default value is good enough for almost all scenarios. But, you require adjust the value of SHMQMAXMEM in UBBCONFIG if the message size is greater than 32 Kbytes, the detail is as follow:

  • SHMQMAXMEM = (Recommend_value * Message_size) / 32
  • Recommend_value: The value returned by tmloadcf -c
  • Message_size: The buffer size for one message (Kbytes)

3.2.3 Memory Usage

Given a specific shared memory used by the SHMQ, the Tuxedo would divide it into several parts for different sized buffers. In general, the bigger the buffer size is, the less the total entries for this kind of buffer are. If some sized buffer is too much, the Tuxedo will convert to use local memory although the whole shared memory for SHMQ is not full.

In this release, there are two new MIB fields, TA_SHMQSTAT and TA_MSG_SHMQNUM, which are used to get the detailed information about shared memory usage. For more details about TA_SHMQSTAT and TA_MSG_SHMQNUM, see TM_MIB(5) in Section 5 - File Formats, Data Descriptions, MIBs, and System Processes Reference.

3.2.4 Programming with SHMQ

It is a new flag of TPNOCOPY in tpcall() for using SHMQ message. A typical Tuxedo user case of zero-copy messaging:

  1. Client gets request SHMMSG buffer by tpalloc()
  2. Client sends the request to server's request SHMQ by tpcall(), and waits for reply
  3. Server receives the request from its request SHMQ, processes the request
  4. Server use the same SHMMSG buffer for reply
  5. Server sends the reply to client's reply SHMQ by tpreturn()
  6. Client receives the reply from its reply SHMQ

Zero-copy messaging is an ideal circumstance, with the pre-condition that sender and receiver cannot access the shared buffer at the same time. In the real world, to guarantee safe memory access, sender needs to do one copy and send the copy instead of original SHMMSG. However, to gain advanced performance, new flag TPNOCOPY is provided for tpcall() to avoid the copy cost. If application chooses to use this flag, it must take the responsibility to make sure no access to the SHMMSG buffer after tpcall() fails, except for tpfree().

When TPNOCOPY is set for tpcall() flags and the send buffer is SHMMSG buffer, no safe copy will be done during message sending. After tpcall() succeeds, sender application has full access of the send buffer as normal. But if tpcall() fails in any circumstance, sender application cannot access the send buffer any more. In this case the recommended action is tpfree() the buffer, and this is the only safe operation on the buffer.

TPNOCOPY cannot be set for tpacall(), or tpacall() will fail with tperrno set to TPEINVAL.

3.2.5 Exceptions

In general, the tuxedo native request/reply messages will be transferred using shared memory queue (SHMQ) if the feature is available. But the IPC queue is used instead in the following cases:

  • Encoded Tuxedo message
  • Stateful CORBA object
  • Tuxedo message associated with digital signature and encryption

    For example, tpseal() or tpsign() marks the Tuxedo message for encryption or digital signature.

  • Tuxedo messages out from a server specified with BUFTYPECONV
  • Tuxedo FML32 typed message with any field typed pointer
  • Tuxedo FML32 typed message with any field typed embedded FML32

3.3 Partial One Phase Read-Only Optimization for RAC

In general, Tuxedo will only perform a one-phase commit if only one Tuxedo group is participating in a global transaction. If more than one group is involved, Tuxedo will perform a two-phase commit. Two-phase commit indicates the Tuxedo sends a prepare request to each branch of the global transaction followed by a commit request to all non-read-only branches if all prepare requests are successful. When using RAC, if there is more than one RAC instance involved in the transaction, all prepare requests except the last will return read-only. Tuxedo uses this knowledge to try and improve the performance of the transaction by waiting to prepare one branch until all other RAC branches have been prepared. If all other branches have returned read-only, Tuxedo will then send a one-phase commit to the remaining branch. This saves a prepare call and the need to write a TLOG entry. While this may slightly increase the response time of the transaction, it will reduce the load and likely increase the throughput.

See Also:

For more information, Partial One Phase Read-Only Optimization for RAC.

If the Tuxedo application is using a RAC Database, the customer can take advantage of this feature when the application involves multiple groups. In addition, the branches must be tightly coupled for Oracle Database which is a default property of the OPENINFO.

The typical scenario is that the participated groups connect to different RAC instances or use different database service. A typical UBB configuration is as below.

Listing UBB Configuration

*RESROUCE
MODEL         SHM
OPTIONS       XPP
...

* MACHINES
"mach1"      LMID=L1
...

*GROUPS
GRP1         LMID=L1 GRPNO=10 TMSNAME="TMSORA1"
             OPENINFO="Oracle_XA:ORACLE_XA+SqlNet=orcl.tux1+ACC=P/scott/tiger +SesTM=120"
GRP2         LMID=L1 GRPNO=20 TMSNAME="TMSORA2"
             OPENINFO="Oracle_XA:ORACLE_XA+SqlNet=orcl.tux2+ACC=P/scott/tiger +SesTM=120"

*SERVERS
server1       SRVGRP=GRP1 SRVID=10 MIN=2
server2       SRVGRP=GRP2 SRVID=10 MIN=2
...

Tuxedo GRP1 and GRP2 use different net services to connect to the same Oracle RAC database, with each net service using a different database service offered by a separate RAC instance. Tuxedo server1 and server2 offer different Tuxedo services. A transactional business requires services from svc 1 and svc2. Therefore, it involves servers 1 and 2.

Enabling Read-only Optimization saves requests by ignoring TLOG writing. Perform a one-phase commit to efficiently commit the remaining branch.

Enabling the Common XID feature is recommended if the participating groups are connected to the same Oracle RAC instance and RAC database. This feature ensures that the global transaction is committed in a single phase. Common XID feature improves performance by ignoring prepare requests and TLOG writing, better than Read-only Optimization.

If read-only optimization is not used in the transactional business, do not enable it to avoid unfavorably impacting response time. In a typical scenario, it is common to use multiple resource managers simultaneously.

3.4 Single Group Multiple Branches (SGMB)

3.4.1 Scenarios Recommended

If a Tuxedo application is running on the Oracle RAC, you may want to take advantage of non-singleton database service, such as load balance, service failover, and so on. Tuxedo groups can use RAC non-singleton service by enabling this feature. Given that the business may involve multiple groups, it is better to also enable Common XID and XA Transaction Affinity to achieve good performance.

A typical UBB configuration is as follows.

Listing UBB Configuration

*RESROUCES
MODEL         SHM
OPTIONS       XPP
...
 
*MACHINES
"mach1"      LMID=L1
...
 
*GROUPS
GRP1        LMID=L1 GRPNO=10 TMSNAME="TMSORA1"
            OPENINFO="Oracle_XA:ORACLE_XA+SqlNet=orcl.tux3+ACC= 
P/scott/tiger +SesTM=120"
GRP2        LMID=L1 GRPNO=20 TMSNAME="TMSORA2"
            OPENINFO="Oracle_XA:ORACLE_XA+SqlNet=orcl.tux3+ACC= 
P/scott/tiger +SesTM=120"
 
*SERVERS
server1     SRVGRP=GRP1 SRVID=10 MIN=4
server2     SRVGRP=GRP2 SRVID=10 MIN=4
...

GRP1 and GRP2 use the same net service orcl.tux3 to connect the resource manager; orcl.tux3 is configured to database service tux3, which both RAC instance1 and instance2 support. Server1 offers Tuxedo service svc1 and server2 offers Tuxedo service svc2. The transactional business A calls svc1 and then svc2, and so involves both server1 and server2. Because orcl.tux3 is non-singleton database service, server1 copies associate with either instance1 or instance2, so do server2 copies.

SGMB can ensure business working well and ensure that business A transactions are distributed evenly on instance1 and instanc2.

Given that both Common XID and XA Transaction Affinity are enabled, all business A transactions become one-phase commit.

3.4.2 Limitations

  • Groups with multiple resource managers are not supported.
  • A transaction fails if more than 16 instances are involved in a single group.
  • Partial One Phase Read-Only Optimization for RAC does not work in a transaction if the preferred reserved group is a multi-branch group. If GWTDOMAIN is not the coordinator, the preferred reserved group is the coordinator group; otherwise, the preferred reserved group is the participated group coming next in the coordinator domain.
  • Multi-threaded servers do not provide instance information via MIB; however, SGMB still performs well on server-dispatched threads.

3.5 Common XID

Common XID shares the coordinator's instance information and branch (common XID) to all participated groups. The servers in a participated group will reuse the common XID if they have the same instance information as the coordinator does. This feature brings significant performance improvement when a global transaction involves multiple groups, especially when all participated groups associate with the same database instance through the same database service.

3.5.1 Scenarios Recommended

3.5.1.1 Scenario A

Only one Oracle Database instance is used in a Tuxedo application. A typical UBB configuration is as follows.

Listing 18 UBB Configuration

*RESROUCES
MODEL       SHM
OPTIONS     XPP
...
 
*MACHINES
"mach1"     LMID=L1
...
 
*GROUPS
GRP1       LMID=L1 GRPNO=10 TMSNAME="TMSORA1"
           OPENINFO="Oracle_XA:ORACLE_XA+SqlNet=orcl.tux1+ACC= 
P/scott/tiger +SesTM=120"
GRP2       LMID=L1 GRPNO=20 TMSNAME="TMSORA2"
           OPENINFO="Oracle_XA:ORACLE_XA+SqlNet=orcl.tux1+ACC= 
P/scott/tiger +SesTM=120"
 
*SERVERS
server1    SRVGRP=GRP1 SRVID=10 MIN=2
server2    SRVGRP=GRP2 SRVID=10 MIN=2
...

In the above configuration, GRP1 and GRP2 use the same net service (orcl.tux1, which is configured to an Oracle Database) to connect resource manager. Server1 offers Tuxedo service svc1 and server2 offers Tuxedo service svc2. The transactional business A calls svc1 followed by svc2 so it will involve server1 and server2. When Common XID is enabled, all transactions of business A become one-phase commit.

3.5.1.2 Scenario B

All participated groups associate with the same database instance via the same database service when Tuxedo application is running on Oracle RAC.

The typical UBB sample is the same as the Listing UBB Configuration (refer to this listing as described in Scenario A), while the net service orcl.tux1 is configured to Oracle RAC instance1 through database service tux1. When Common XID is enabled, all transactions of business A become one-phase commit.

3.5.1.3 Scenario C

Redundant servers or groups are configured when they are running on different Oracle RAC instances. Given this scenario, the XA Transaction Affinity feature should be enabled too. It helps the business involves the servers/groups that associate same database instance via same database service with the coordinator.

Listing 19 UBB Configuration

*RESROUCES
MODEL       SHM
OPTIONS     XPP
...
 
*MACHINES
"mach1"     LMID=L1
...
 
*GROUPS
GRP1       LMID=L1 GRPNO=10 TMSNAME="TMSORA1"
           OPENINFO="Oracle_XA:ORACLE_XA+SqlNet=orcl.tux1+ACC= 
P/scott/tiger +SesTM=120"
GRP2       LMID=L1 GRPNO=20 TMSNAME="TMSORA2"
           OPENINFO="Oracle_XA:ORACLE_XA+SqlNet=orcl.tux1+ACC= 
P/scott/tiger +SesTM=120"
GRP3       LMID=L1 GRPNO=30 TMSNAME="TMSORA3"
           OPENINFO="Oracle_XA:ORACLE_XA+SqlNet=orcl.tux2+ACC= 
P/scott/tiger +SesTM=120"
 
*SERVERS
server1    SRVGRP=GRP1 SRVID=10 MIN=2
server2    SRVGRP=GRP2 SRVID=10 MIN=2
server3    SRVGRP=GRP3 SRVID=10 MIN=2
...

GRP1 and GRP2 use the same net service orcl.tux1 to connect the resource manager; orcl.tux1 is configured to database service tux1, which RAC instance1 supports. GRP3 uses net service orcl.tux2 to connect the resource manager; orcl.tux2 is configured to database service tux2, which RAC instance2 supports. Server1 offers Tuxedo service svc1; both server2 and server3 offer Tuxedo service svc2. The transactional business A calls svc1 and then svc2.

In general, business A may involve server1 and server2, or server1 and server3, because of Tuxedo load balance. When Common XID is enabled, the transactions that involve server1 and server2 become one-phase commit; when XA Transaction Affinity feature is enabled, business A always involves server1 and server2 so that all transactions of the business A would be one-phase commit.

3.5.1.4 Scenario D

Part of participated groups associate with the same instances through the same database service with the coordinator. In this scenario, it is better to enable both common XID and Read-Only Optimization features.

A typical UBB configuration is as follows.

Listing 20 UBB Configuration

*RESROUCES
MODEL           SHM
OPTIONS         XPP
...
 
*MACHINES
"mach1"         LMID=L1
...
 
*GROUPS
GRP1           LMID=L1 GRPNO=10 TMSNAME="TMSORA1"
               OPENINFO="Oracle_XA:ORACLE_XA+SqlNet=orcl.tux1+ACC= 
P/scott/tiger +SesTM=120"
 
GRP2           LMID=L1 GRPNO=20 TMSNAME="TMSORA2"
               OPENINFO="Oracle_XA:ORACLE_XA+SqlNet=orcl.tux1+ACC= 
P/scott/tiger +SesTM=120"
 
GRP3           LMID=L1 GRPNO=30 TMSNAME="TMSORA3"
               OPENINFO="Oracle_XA:ORACLE_XA+SqlNet=orcl.tux2+ACC= 
P/scott/tiger +SesTM=120"
 
*SERVERS
server1        SRVGRP=GRP1 SRVID=10 MIN=2
server2        SRVGRP=GRP2 SRVID=10 MIN=2
server3        SRVGRP=GRP3 SRVID=10 MIN=2
...

GRP1 and GRP2 use the same net service orcl.tux1 to connect the resource manager; orcl.tux1 is configured to database service tux1, which RAC instance1 supports. GRP3 uses net service orcl.tux2 to connect the resource manager; orcl.tux2 is configured to database service tux2, which RAC instance2 supports. Server1 offers Tuxedo service svc1; server2 offers Tuxedo service svc2; server3 offers Tuxedo service svc3. The transactional business B calls svc1, then svc2, and then svc3.

The business B involves server1/GRP1, server2/GRP2, and server3/GRP3. When common XID is enabled, the prepare request to GRP2 is saved. Given that Read-Only Optimization is enabled as well, the prepare request to GRP1 is saved as well and one-phase commit is done on GRP1, avoiding TLOG writing.

3.5.2 Limitations

  • Groups with multiple resource managers are not supported.
  • Multi-threaded servers do not provide instance information via MIB; however, common XID still performs well on server-dispatched threads.
  • In two-phase commit scenarios, GWTDOMAIN is always involved to do prepare and/or commit

See Also:

3.6 XA Transaction Affinity

3.6.1 Scenarios Recommended

It is recommended to enable this feature when Tuxedo server has multiple instances running on different Oracle RAC instances via the same Oracle Database service.

In the event that XA Transaction Affinity is enabled, there is no need to utilize the rule of Oracle RAC routing specified by the environment variable TUXRACGROUPS, and this rule will be disabled.

The following picture illustrates the changes that will be made when XA Transaction Affinity is enabled.

Figure 3-1 XA Transaction Affinity Enablement

XA Transaction Affinity Enablement Diagram

3.6.2 Limitations

  • Groups with multiple resource managers are not supported.
  • The max number of affinity context (database name+instance name+service name) in one transaction is 16.
  • XA Transaction Affinity does not support multi-server single queue, multi-threaded server, or cross-domain services.

3.7 Failover/Failback across Database Instances

3.7.1 Recommendation for Configuration on Oracle Database

To benefit from Oracle FAN (Fast Application Notification), it is recommended to enable this feature anytime when Tuxedo works with Oracle RAC.

Besides UBBCONFIG, set Oracle Database properly for the following configurations:

  • ONS (Oracle Notification System)

    This feature depends on ONS (Oracle Notification System) to access FAN events. ONS daemon must be enabled on Oracle Database server side and client side if Tuxedo is taken as a native ONS client. It is recommended that Tuxedo works in remote mode.

    The ONS daemon configuration file is located in $ORACLE_HOME/opmn/conf/ons.config. This file tells the ONS daemon how to behave. Configuration information within ons.config is defined in simple name and value pairs.

    After configuring ONS, you can start it with onsctl command. Make sure that ONS daemon is running all the time.

    Note:

    On Oracle Database client side, if the Oracle version is lower than 12.1.0.1.0, ONS daemon must be enabled.
  • TAF (Transparent Application Failover)

    TAF is recommended when Oracle Tuxedo non-XA server works with Oracle RAC Fast Application Notification (FAN).

    TAF (Transparent Application Failover) is an Oracle Database client-side feature that allows clients to reconnect surviving database instances automatically in the event of database instance failure.

    • If TAF is configured, Oracle client will be responsible for re-establishing the new connection from Oracle Tuxedo to Oracle Database server.
    • If TAF is not configured, Oracle Tuxedo non-XA server will not do the re-establishment and so this feature will not work.

3.7.2 Recommendation for Non-XA Server

To monitor FAN event for the instance associated with the specific non-XA application server, $TUXDIR/lib/tuxociucb.so.1.0 should be deployed in $ORACLE_HOME/lib, and the name of this binary must be specified in ORA_OCI_UCBPKG environment variable.

To support TAF, follow the rules as below:

  • For OCI application, create OCI environment in OCI_THREADED mode.
  • For Pro*C application, run pre-compilation with threads=yes and use EXEC SQL ENABLE THREADS before creating the first executable embedded SQL statement.

-L option in servopts must be used for a non-XA server to indicate that the server will connect to the Oracle Database. Since the ECID is enabled when -L is specified, a new option -F is introduced into servopts to close ECID. The usage is -F noECID. The example is below.

Listing Example for -L Option

*SERVERS
server1
SRVGRP=GRP1 SRVID=1 ClOPT="-L libclntsh.so -F noECID"

3.7.3 Limitations

  • Groups with multiple resource managers are not supported.
  • If the customized server is going to use OCI to connect to Oracle Database, OCI_NO_UCB should not be set at OCI initialization time.

See Also:

3.8 Load Balancing across RAC Instances

3.8.1 Recommendation for Configuration on Oracle Database

To benefit from Oracle FAN (Fast Application Notification), it is recommended to enable this feature anytime when Tuxedo works with Oracle RAC.

Configure UBBCONFIG and Oracle Database the same as Failover/Failback across Database Instances, and set LBA (Load Balance Advisory) as follows.

  • LBA (Load Balance Advisory)

    Based on Oracle Database load balance advisory, Tuxedo can distribute service request across Tuxedo application server that is connected to the same Oracle Database service. To enable LBA and publication of FAN load balancing events, the service-level goal for runtime connection load balancing must be specified in Oracle Database service definition. You can use -B option to specify the goal via srvctl when creating or modifying the service.

3.8.2 Recommendation for Non-XA Server

See Recommendation for Non-XA Server for the recommendation.

3.8.3 Limitations

  • Groups with multiple resource managers are not supported.
  • If the customized server is going to use OCI to connect to Oracle Database, OCI_NO_UCB should not be set at OCI initialization time.
  • Load balance based on Oracle RAC LBA does not support multi-server single queue, multi-threaded server, or cross-domain services.

See Also: