Description of Oracle dedicated server and Shared Server (dedicated mode and Shared Mode)

Source: Internet
Author: User
Tags dedicated server

 

I. Official Website description

When you create a database in dbca, you are prompted to select the connection type. There are two types: dedicated server mode and Shared Server mode. The dedicated mode is used by default. For example:

 

 

The Oracle official documents describe these two documents as follows:

About dedicated andshared Server Processes

Http://download.oracle.com/docs/cd/B28359_01/server.111/b28310/manproc001.htm

 

Oracledatabase creates server processes to handle the requests of user processesconnected to an instance. A server process can be either of the following:

(1) A dedicated server process, which services only one userprocess

(2) A Shared Server process, which can service multiple userprocesses

 

Oracle creates server process to process user processes requests to connect to the instance. There are two types of server process: dedicated server process and sharedserver process.

 

Yourdatabase is always enabled to allow dedicated server processes, but you mustspecifically configure and enable Shared Server by setting one ormore initialization parameters.

 

 

1.1 dedicated server processes

Figure4-1, "Oracle database dedicated server processes" extends strateshow dedicated server processes work. In this distritwo user processes areconnected to the database through dedicated server processes.

 

Ingeneral, it is better to be connected through a dispatcher and use ashared server process. this is your strated in Figure4-2, "Oracle database shared server processes ". A shared serverprocess can be more efficient because it keeps the number of processes requiredfor the running instance low.

Inthe following situations, however, users and administrators shocould explicitlyconnect to an instance using a dedicated server process:

In the preceding two cases, dedicated server process must be used to connect to the instance:

(1) to submit a batch job (for example, when a job can allow little orno idle time for the server process)

(2) to use recovery Manager (RMAN) to back up, restore, or recover a database

 

Torequest a dedicated server connection when Oracle database is configured forshared server, users must connect using a net service name that is configuredto use a dedicated server. specifically, the net service name value shouldinclude the server = dedicated clause in the connect descriptor.

If the database is configured with a shared server and you want to use the dedicated server to connect to the instance, you must specify server = dedicated in net service name (tnsnames. ora.


Figure 4-1 oracledatabase dedicated server processes

1.2 Shared Server Processes

Consideran Order Entry System with dedicated server processes. A customer phones theorder desk and places an order, and the clerk taking the call enters the orderinto the database. for most of the transaction, the clerk is on the telephonetalking to the customer. A server process is not needed during this time, sothe server process dedicated to the clerk's user process remains idle. thesystem is slower for other clerks entering orders, because the idle serverprocess is holding system resources.

Sharedserver architecture eliminates the need for a dedicated server process for eachconnection (see Figure4-2 ).

 

Figure 4-2 oracledatabase Shared Server Processes

Ina shared server configuration, client user processes connect to a dispatcher. the dispatcher can support multiple client connections concurrently. eachclient connection is bound to a virtual circuit, which is a piece ofshared memory used by the dispatcher for client database connection requestsand replies. the dispatcher places a virtual circuit on a common queue when arequest arrives.

Anidle Shared Server process picks up the virtual circuit from the common queue, services the request, and relinquishes the virtual circuit before attempting toretrieve another virtual circuit from the common queue. this approach enables a small pool of server processes to serve a largenumber of clients. A significant advantage of Shared Server ubuntureover the dedicated server model is the function of system resources, enablingthe support of an increased number of users.

Foreven better resource management, shared server can be configuredfor Connection pooling. connection Pooling lets a dispatcher support moreusers by enabling the database server to time-out protocol connections and touse those connections to service an Active session. further, Shared Server canbe configured for session multiplexing, which combines multiple sessionsfor transmission over a single network connection in order to conserve the operatingsystem's resources.

Sharedserver architecture requires Oracle Net Services. User processes targeting theshared server must connect through Oracle Net services, even if they are on thesame machine as the Oracle database instance.

 

 

Ii. Description 2.1 dedicated server description

For dedicated server configuration, Oracle will always create a new process at login, which will be dedicated to this connection service during session lifetime. A new dedicated server will appear for each session, and there is a one-to-one ing between the session and the dedicated server. As defined, this dedicated server is not part of the instance. The customer process (that is, the program that wants to connect to the database) will directly communicate with the dedicated server through a certain network channel (such as TCP/IP socket, the server process receives and executes My SQL statements. If necessary, it will read the data file and search for the data I want in the database cache. Maybe it will complete my update statement, or it may run my PL/SQL code. The main goal of this server process is to respond to the SQL call I submitted.

2.2 Shared Server description 2.2.1

A Shared Server is a multi-threaded server or MTS. If this method is used, no other thread or new Unix process will be created for each user connection.

 

On the Shared Server, Oracle uses a "shared process" pool to provide services for a large number of users. A Shared Server is actually a connection pool mechanism. With the Shared Server, we do not have to create 10,000 dedicated servers for 10,000 database sessions (in this case, there are too many processes or threads), but only a few processes/Threads need to be created. As the name suggests, these processes/threads will be shared by all sessions. In this way, Oracle can connect more users to the database, otherwise it is difficult to connect more users. If my machine manages 10,000 processes, this load will surely crush it, but it can still manage 100 or 1,000 processes. The sharing server mode is used. The sharing process is usually started with the database. You can see this process using the ps command.

There is a major difference between a shared server connection and a dedicated server connection. The client process connected to the database does not directly communicate with the shared server, but the dedicated server does not, the customer process will directly communicate with the dedicated server. The reason why you cannot directly talk to the sharing server is that the server process is shared. In order to share these processes, another mechanism is required to "talk" with the server process ". Therefore, Oracle uses one or more processes called schedulers.

The customer process communicates with a scheduler process through the network. This scheduler processes the customer's requests into the request queue in SGA (this is also one of the purposes of SGA ). The first idle Shared Server will get this request and process it (for example, the request may be update t setx = x + 5 where Y = 2 ). After the command is completed, the Shared Server places the response in the response queue of the original scheduler (the scheduler that receives the request. The scheduler process keeps listening to this queue and sends the result to the customer after the result is found. In terms of concept, the process of sharing server requests is 2-3.

 

 

 

As shown in 2-3, the client connection sends a request to the scheduler. The scheduler first places the request in the Request queue (①) in the SGA. The first available Shared Server retrieves this request from the request queue ② and processes it. After the Shared Server completes processing, place the response (return code, data, etc.) in the response queue ③. Then the scheduler obtains the response ④ and sends it back to the customer.

 

2.2.2 shared servers have the following Disadvantages:

Generally, we can use the default dedicated server mode of Oracle, and there is no need to use the Shared Server mode. One is that we use middleware (such as WebLogic) to connect to Oracle. Middleware itself has a connection pool mechanism. In addition, this sharing server method of Oracle is not good enough and has many shortcomings.

 

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 ).

 

The memory reduced by MTS is actually the memory required by each user to connect to the operating system process in dedicated server mode. However, it uses the large_pool of SGA to allocate UGA and remove the east wall to complement the west wall, the reduced memory is very small. If user sessions are frequently connected and disconnected, the overhead of database Process Creation and deletion will be very high. In this case, it is best to use the Shared Server mode (otherwise, the connection pool technology should be used ). It is of little significance to use the Shared Server mode if a client is connected for Life (within the session lifecycle. Most of the time, a session is connected to a server process, and server processes cannot be shared.

 

2.2.3 descriptions of sharing service initialization parameters

Shared_servers: specify the number of shared server processes started when the instance is started. Do not set this parameter too large. Otherwise, it will take more time to start the database instance, after oracle is started, it dynamically adjusts shared_servers Based on the load. If the value is 0, the shared service mode is not enabled for the database. This parameter is required for shared server configuration, and only this parameter is required.

Modify the parameter: Alter system set shared_servers = 1;

 

Max_shared_servers: The Shared Server process that Oracle can use at the same time. do not set this parameter to smaller than shared_servers. If the value of shared_servers is dynamically modified to be greater than that of max_shared_servers, Oracle overwrites the value of max_shared_servers. In this case, you must modify max_shared_servers. it cannot be greater than processes. This parameter is set for (batch processing) operations that occupy a large amount of resources. In order to reserve some processes for DBA tasks (RMAN backup ),

 

Shared_server_sesions: Specifies the total number of Shared Server sessions allowed. If this parameter is set, do not set this value to exceed sessions. If this value is not set, it can be used as long as there are idle sessions. Set this value to reserve user sessions for the VPC connection.

 

Dispatchers: configure the dispatcher process. If this parameter is not set, Oracle will automatically set a dispatcher Based on TCP as long as shared_servers is set. You also need to check how many connections can be processed by a dispatcher in the operating system.

SQL> select * from V $ dispatcher;

 

Max_dispatchers: set the number of dispatchers that can run simultaneously at the same time. The value must be greater than or equal to dispatchers and less than processes. This parameter will also be overwritten by dispatchers.

 

Circuits: Specifies the total number of virtual circuits.

 

2.2.4 disable Sharing Mode

If the shared_servers parameter is set to 0, all connections to the database in the Shared Mode will fail, but the unreleased shared connections will continue until they are disconnected. If both shared_servers and max_shared_servers are set to 0, the shared connection is terminated. If all the shared connections are disconnected, you can use alter system set dispatcher = ''to clear the dispatcher to prevent the shared connection from being enabled next time you start the database.

 

 

2.3 Basic Principles of TCP/IP connection

Here we will analyze the most common scenario on the Network: create a network-based connection request on a TCP/IP connection. In this case, the customer is on one machine, and the server is on another machine. The two machines are connected through a TCP/IP network. The customer took the lead in establishing a request using Oracle customer software (a set of application interfaces or APIs provided by Oracle) to connect to the database.

For example, a customer can issue the following command:

 

C: \ Users \ administrator. David Dai> sqlplus sys/Oracle @ dave2_202as sysdba;

SQL * Plus: Release 11.2.0.1.0 production onsun Aug 21 14:36:47 2011

 

Copyright (c) 1982,201 0, Oracle. All rights reserved.

 

Connected:

Oracle Database 10g enterprise editionrelease 10.2.0.1.0-Production

With the partitioning, OLAP and data miningoptions

 

SQL>

 

Here, the customer is the program SQL * Plus, and dave2_202 is a TNS service name. TNS stands for the bottom layer of the transparent network (Transparent Network Substrate). This is the "basic" software for Handling Remote connections in Oracle customers. With this software, it is possible to establish peer-to-peer communication. The TNS connection string tells the Oracle software how to connect to a remote database.

Generally, the client software running on the machine reads a tnsnames. ora file. This is a plain text configuration file, which is usually stored in the [ORACLE_HOME] \ Network \ ADMIN directory. The configuration is as follows:

 

Dave2_202 =

(Description =

(Address_list =

(Address = (Protocol = TCP) (host = 192.168.3.202) (Port = 1521 ))

)

(CONNECT_DATA =

(Server = dedicated)

(SERVICE_NAME = dave2)

)

)

 

Based on this configuration information, Oracle customer software can map the TNS connection string dave2_202 we use to some useful information, that is, the host name, And the listener process acceptance (listener) on the host) the connection port, the service name of the database connected to the host, and so on.

A service name indicates an application group with common attributes, service threshold, and priority. The number of instances that provide services is transparent to applications. Each database instance can be registered with the listener to provide multiple services. Therefore, services are mapped to physical database instances and DBA is allowed to associate the thresholds and priorities. This string (dave2_202) can be parsed in other ways. For example, you can use the Oracle Internet Directory (Oracle Internet Directory, OID), which is a distributed Lightweight Directory Access Protocol (LDAP) server, it serves to resolve the DNS of the host name. However, the tnsnames. ora file is usually only applicable to most small to medium-sized installations. In these cases, this configuration file is not too many copies and is manageable.

Since the customer software knows where to connect, it will open a TCP/IP socket connection with the server with the Host Name 192.168.3.202 on port 1521. If the server DBA has installed and configured Oracle Net, and a listener listens for connection requests on port 1521, it will receive the connection. In the network environment, we will run a process called TNS listener on the server. This listener process allows us to physically connect to the database. When it receives an inbound connection request, it checks the request using its own configuration file and may reject the request (for example, because such a database does not exist, or our IP address may be restricted and cannot be connected to the host), or the request may be accepted and the connection is established.

 

If a dedicated server connection is established, the listener process creates a dedicated server for us. On UNIX, this is done through fork () and exec () system calls (in UNIX, the only way to create a new process after Initialization is through fork ()). This new dedicated server process inherits the connection established by the listener and is now physically connected to the database.

On Windows, the listener process requests the database process to create a new thread for the connection. Once this thread is created, the customer will "Redirect" to this thread to establish a physical connection accordingly. Figure 2-4 shows the connection between the listener process on UNIX and the dedicated server.

 

On the other hand, if we send a shared server connection request, the listener performance will be different. The listener process knows which schedulers are running in the instance. After receiving the connection request, the listener selects a scheduler process from the available scheduler pool. The listener returns the connection information to the client, which explains how the client connects to the scheduler process. If possible, you can also forward the connection to the scheduler process (depending on different operating systems and database versions, but the actual effect is the same ).

After the listener sends back the connection information, its work ends, because the listener has been running on a specific port of a specific host (the host name and port number are all known ), the scheduler accepts the connection on the randomly assigned port on the server. The listener must know the random port numbers specified by the scheduler and select

Select a scheduler. The customer is disconnected from the listener and directly connected to the scheduler. Now there is a physical connection to the database. This process is shown in step 2-5.

 

 

 

 

Iii. Method 3.1. showparameter shared_server for determining whether Oracle is a shared mode or a dedicated mode;

(Note: 8i should be: showparameter mts_servers ;)
SQL> show parameter shared_server;

Name type value
-----------------------------------------------------------------------------
Max_shared_servers integer 20
Shared_server_sessions integer 330
Shared_servers integer 1

 

3.2 view the V $ session View

SQL> select username, server, program fromv $ session where username is not null;

 

Username server program

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

 

Sys dedicated rman.exe

RMAN dedicated rman.exe

Sys dedicated rman.exe

Sys dedicated sqlplus.exe

Sys dedicated rman.exe

Dave dedicated toad.exe

Sys dedicated toad.exe

 

3.3 view listener: LSNRCTL Service

C: \ Users \ administrator. David Dai> lsnrctlservice

LSNRCTL for 32-bit windows: version11.2.0.1.0-production on month 26-6-2010 copyright (c) 1991,201 0, Oracle. All rights reserved.

Connecting to (description = (address = (Protocol = IPC) (Key = extproc1521 )))

Service summary ..

The Service "orcl" contains one instance.

Instance "orcl", status ready, contains 1 handler of this service...

Handler:

"Dedicated" created: 34 rejected: 0 status: Ready

Local Server

The Service "orclxdb" contains one instance.

Instance "orcl", status ready, contains 1 handler of this service...

Handler:

"D000" created: 0 rejected: 0 current: 0 maximum: 1022 status: Ready

Dispatcher <machine: David Dai, PID: 10884>

(Address = (Protocol = TCP) (host = David Dai) (Port = 58400 ))

Command executed successfully

 

3. 4. view the tnsnames. ora file. For example:

Orcl =

(Description =

(Address_list =

(Address = (Protocol = TCP) (host = David Dai) (Port = 1521 ))

)

(CONNECT_DATA =

(Server = dedicated)

(SERVICE_NAME = orcl)

)

)

 

Here, the orcl instance is connected in dedicated private mode. Write (Server = shared) is to use the Shared Server mode, but then shared_server_process needs to be enabled, or else it will fail to connect to Oracle. If this section is left blank and not written, the system will automatically adjust it according to the server mode. However, based on the actual test results, even if the server is defined as the Shared Server mode, shared_server_process will not be enabled, the connection found in V $ session is still Server = dedicated.

So basically, we can leave it empty, but sometimes we need to connect to our database in the Shared Server mode. If we leave it empty, the system may think that we need to connect to the database through a shared server, at that time, it is necessary to declare that server = dedicated uses a dedicated server to connect.

When the database is started, if shared_servers is not specified but dispatchers is set, Oracle considers that shared server is started and shared_servers is set to 1. when the database is started, shared_servers is not set and dispatchers is not set. Even if dispatchers is modified later, Shared Server cannot be started and the database must be restarted.

In addition, background process and locally connected items can only be in the form of dedicated. For example, sqlplus user/pass. If no shared server is configured for the database, the client can only connect to the database in dedicated mode.

 

 

 

 

 

 

 

Bytes -------------------------------------------------------------------------------------------------------

Blog: http://blog.csdn.net/tianlesoftware

WEAVER: http://weibo.com/tianlesoftware

Email: dvd.dba@gmail.com

Dba1 group: 62697716 (full); dba2 group: 62697977 (full) dba3 group: 62697850 (full)

Super DBA group: 63306533 (full); dba4 group: 83829929 (full) dba5 group: 142216823 (full)

Dba6 group: 158654907 (full) chat group: 40132017 (full) chat group 2: 69087192 (full)

-- Add the group to describe the relationship between Oracle tablespace and data files in the remarks section. Otherwise, the application is rejected.

Related Article

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.