[Oracle] Shared Server Mode explanation and Configuration

Source: Internet
Author: User

I. Shared Server Mode working mechanism:

Shared server mode (also called MTS Multi-Threaded Server ):

After the database is started, there will be two more processes than the dedicated server mode. One is the scheduling process (dispatcher) and the other is the shared server process. The Request from the client is accepted by the dispatcher, and then the dispatcher puts the Request into the Request queue. Idle Server Process processes requests in the queue according to the request queue. The processed result is put into the Response queue. Finally, the DIspatcher will return the final result to the client.

In Shared Server mode, after the client connects to the dispatcher through the listener, the dispatcher will randomly allocate a port. In this case, the client is disconnected from the listener and connected to the dispatcher through the allocated port. The connection to the listener is short.

Compared with the dedicated Server mode, the UGA of Server Process is in SGA, while the UGA of dedicated Server mode is in PGA, if large_pool_size is set in Shared Server mode, the user's UGA will be in large_pool. The memory reduced by MTS is actually the memory required by each user to connect to the operating system Process in dedicated Server mode. The Shared Server Mode limits the number of Server processes, reduces the memory required to establish the Server Process, and removes the need to create and delete processes frequently when the concurrency is large, reducing the corresponding overhead and increasing the concurrency. Therefore, the Shared Server model is suitable for business systems with high concurrency and small processing capacity.

However, compared with the dedicated server mode, the Shared Server Mode also has many problems:

1) The shared server code path is longer than the dedicated server, so it is inherently slower than the dedicated server.
2) there is a possibility of a human deadlock because it is serial. As long as a connection is blocked, all users on the server process will be blocked and the deadlock is very likely.
3) There is a possibility of exclusive transactions, because if a session's transaction runs for too long, it exclusively shares resources, other users can only wait, while a dedicated server, each client is a session.
4) The Shared Server Mode limits some database features. For example, the instance cannot be started or closed independently, the media cannot be restored, and the Log Miner cannot be used, SQL _TRACE does not make sense (because it is shared rather than the current session ).

Because the Shared Server mode has various problems, and the middleware can fully implement the effect of the connection pool, the server mode is generally not shared. You can use the dedicated server mode.

Shared Server mode configuration

To configure the Shared Server mode, you must configure the following parameters:

Dispatchers: (required) specifies the initial number of scheduling processes for the specified protocol.

Shared_servers: Start several sharing server processes.

Max_shared_servers: Maximum number of shared server processes that can be started

Max_dispatchers: Maximum number of scheduling Processes

Shared_server_sessions: Maximum number of sessions allowed in the Shared Server mode. If the number of connections in the Shared Server Mode exceeds this setting, the dedicated server mode is used. Note that the value is smaller than the sessions setting in the database. If this value is not set, all sessions will be in the Shared Server mode,

Circuits: in Shared Server mode, oracle uses virtual circuits to record the client from which the request is sent to ensure that the correct client can be returned after the request is processed. The circuits setting limits the total number of available circuits in the Request queue and response queue. In Shared Server mode, there is only one request queue, but each dispatcher has its own response queue.

Large_pool_size: Because UGA is in large_pool, the proper size of large_pool helps improve the system performance. Just put down the UGA of all sharing server processes.

The procedure is as follows:

SYS @ ORCL> show parameter processes

NAME TYPE VALUE

-----------------------------------------------------------------------------

Aq_tm_processes integer 0

Db_writer_processes integer 1

Gcs_server_processes integer 0

Job_queue_processes integer 10

Log_archive_max_processes integer 2

Processes integer 300

SYS @ ORCL> show parameter sessions

NAME TYPE VALUE

-----------------------------------------------------------------------------

Java_max_sessionspace_size integer 0

Java_soft_sessionspace_limit integer 0

License_max_sessions integer 0

License_sessions_warning integer 0

Logmnr_max_persistent_sessions integer 1

Sessions integer 335

Shared_server_sessions integer

SYS @ ORCL> show parameter dispatcher

 

NAME TYPE VALUE

-----------------------------------------------------------------------------

Dispatchers string (PROTOCOL = TCP) (SERVICE = ORCLXD

B)

Max_dispatchers integer

SYS @ ORCL> alter system set dispatchers = '(PROTOCOL = TCP) (DISPATCHERS = 2) (PROTOCOL = IPC) (DISPATCHERS = 1 )';

-- Two scheduling processes are configured for the TCP protocol and one scheduling process is configured for the IPC protocol.

System altered.

SYS @ ORCL> alter system set max_dispatchers = 10;

-- Up to 10 scheduling programs can be started

System altered.

SYS @ ORCL> show parameter shared_server

NAME TYPE VALUE

-----------------------------------------------------------------------------

Max_shared_servers integer

Shared_server_sessions integer

Shared_servers integer 1

SYS @ ORCL> alter system set shared_servers = 10;

System altered.

SYS @ ORCL> alter system set max_shared_servers = 20;

System altered.

SYS @ ORCL> alter system set shared_server_sessions = 100;

System altered.

SYS @ ORCL> show parameter circuits

NAME TYPE VALUE

-----------------------------------------------------------------------------

Circuits integer

SYS @ ORCL> alter system set circuits = 5000;

System altered.

SYS @ ORCL> show parameter large_pool

NAME TYPE VALUE

-----------------------------------------------------------------------------

Large_pool_size big integer 0

SYS @ ORCL> alter system set large_pool_size = 200 M;

System altered.

After the configuration is complete, view the scheduling process.

SYS @ ORCL> select name from v $ dispatcher;

NAME

----

D000

D001

We can see that two scheduling processes have been started.

In Shared Server mode, you must configure tns for connection.

[Oracle @ jp ~] $ Cd/u01/app/oracle/product/10.2.0/db_1/network/admin/

[Oracle @ jp admin] $ ls

Listener. ora samples shrept. lst tnsnames. ora

[Oracle @ jp admin] $ vi tnsnames. ora

Link_test =

(DESCRIPTION =

(ADDRESS_LIST =

(ADDRESS = (PROTOCOL = TCP) (HOST = jp) (PORT = 1521 ))

)

(CONNECT_DATA =

(SERVICE_NAME = ORCL)

)

)

Orcl_s =

(Description =

(Address = (protocol = tcp) (host = jp) (port = 1521 ))

(Connect_data =

(Server = shared)

(Service_name = ORCL)

)

)

EXTPROC_CONNECTION_DATA =

(DESCRIPTION =

(ADDRESS_LIST =

(ADDRESS = (PROTOCOL = IPC) (KEY = EXTPROC0 ))

)

(CONNECT_DATA =

(SID = PLSExtProc)

(PRESENTATION = RO)

)

After the TNS configuration is complete, connect to the ECS instance in the Shared Server mode.

[Oracle @ jp admin] $ sqlplus sys/oracle @ orcl_s as sysdba

SQL * Plus: Release 10.2.0.1.0-Production on Mon Mar 3 06:57:03 2014

Copyright (c) 1982,200 5, Oracle. All rights reserved.

Connected:

Oracle Database 10g Enterprise Edition Release 10.2.0.1.0-Production

With the Partitioning, OLAP and Data Mining options

SYS @ orcl_s> select server from v $ session;

SERVER

---------

DEDICATED

DEDICATED

DEDICATED

DEDICATED

DEDICATED

DEDICATED

SHARED

DEDICATED

DEDICATED

DEDICATED

DEDICATED

SERVER

---------

DEDICATED

DEDICATED

DEDICATED

DEDICATED

DEDICATED

DEDICATED

DEDICATED

DEDICATED

DEDICATED

DEDICATED

DEDICATED

22 rows selected.

Shared exists. The shared Server mode is configured successfully.

Locate the spid corresponding to this session

SYS @ orcl_s> select p. spid from v $ session s, v $ process p where s. sid = userenv ('sid ') and s. paddr = p. addr;

SPID

------------

16929

According to the above results, we can see the corresponding shared server process.

[Root @ jp ~] # Ps-ef | grep 16929

Oracle 16929 1 0? 00:00:00 ora_s00w.orcl

Root 17750 16529 0 00:00:00 pts/2 grep 16929

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.