shared server和dedicated server

众所周知在ORACLE中CLIENT端与SERVER端有两种连接方式,shared server方式dedicated server方式。二者各有各自的优缺点,也各有各自的用途,谁也不会取代另一个。下面是从CONCEPTS文档里摘录出来的关于描述这两种方式的内容。

 

首先我们来看一下shared server

 

Shared Server Architecture
Shared server architecture eliminates the need for a dedicated server process for each connection. A dispatcher directs multiple incoming network session requests to a pool of shared server processes. An idle shared server process from a shared pool of server processes picks up a request from a common queue, which means a small number of shared servers can perform the same amount of processing as many dedicated servers.
Also, because the amount of memory required for each user is relatively small, less memory and process management are required, and more users can be supported.


A number of different processes are needed in a shared server system:

■ A network listener process that connects the user processes to dispatchers or dedicated servers (the listener process is part of Oracle Net Services, not Oracle).
■ One or more dispatcher processes
■ One or more shared server processes

 

When an instance starts, the network listener process opens and establishes a communication pathway through which users connect to Oracle. Then, each dispatcher process gives the listener process an address at which the dispatcher listens for connection requests. At least one dispatcher process must be configured and started for each network protocol that the database clients will use.

 

这当中就涉及到另外两个概念 REQUEST QUEUE(一个)和RESPONSE QUEUE(一个或多个)

A request from a user is a single program interface call that is part of the user’s SQL statement. When a user makes a call, its dispatcher places the request on the request queue, where it is picked up by the next available shared server process.
The request queue is in the SGA and is common to all dispatcher processes of an instance. The shared server processes check the common request queue for new requests, picking up new requests on a first-in-first-out basis. One shared server process picks up one request in the queue and makes all necessary calls to the database
to complete that request.
When the server completes the request, it places the response on the calling dispatcher’s response queue. Each dispatcher has its own response queue in the SGA. The dispatcher then returns the completed request to the appropriate user process.

 

总结一下,当采用shared server这种配置方式时,当一个连接请求从客户端发起的时候,服务器端的LISTENER首先监听到该请求,然后判断其请求的连接方式,如果是SHARED SERVER这种方式,那么就把这个用户请求转发连接到一个负荷较轻的DISPATCHER上,一个DISPATCHER可以对应多个用户连接。接下来用户发出的各种请求都会被这个DISPATCHER发送到REQUEST QUEUE中,其他SHARED SERVER PROCESS就对这些请求进行处理,处理完成后把结果放到相应DISPATCHER的RESPONSE QUEUE中,这个时候DISPATCHER再从各自的RESPONSE QUEUE中取出结果返回给各个用户。

当然,如果LISTENER发现某个用户连接请求是DEDICATED方式的时候,就不会这样做了,而是启动一个dedicated server process,把用户连接到这个进程上面。

NOTE:The listener process is not part of an Oracle instance; rather, it is part of the networking processes that work with Oracle.

 

此外,ORACLE会自动调节SHARED SERVER PROCESS的数量。

Oracle dynamically adjusts the number of shared server processes based on the length of the request queue. The number of shared server processes that can be created ranges between the values of the initialization parameters SHARED_SERVERS and MAX_ SHARED_SERVERS.

 

SHARED SERVER PROCESS既然有这么些优点,当然也有相应的限制了。

Certain administrative activities cannot be performed while connected to a dispatcher process, including shutting down or starting an instance and media recovery. An error message is issued if you attempt to perform these activities while connected to a dispatcher process.

 

=================================================================================

 

Dedicated Server Configuration

 

The user and server processes are separate, distinct processes. The separate server process created on behalf of each user process is called a dedicated server process (orshadow process), because this server process acts only on behalf of the associated user process.
This configuration maintains a one-to-one ratio between the number of user processes and server processes. Even when the user is not actively making a database request, the dedicated server process remains (though it is inactive and can be paged out on some operating systems).

 

简单的说,就是一个DEDICATED SERVER PROCESS对应一个USER PROCESS。而一个SHARED SERVER PROCESS可以服务于多个USER PROCESS,其他方面DEDICATED SERVER PROCESS和SHARED SERVER PROCESS的功能几乎一样。

 

=================================================================================

还有一点就是,两种方式并不是互斥的哦,同一环境下是可以共存的。在tnsnames.ora文件里可以设置连接请求模式的(记得好像是个叫SERVER的参数)。

 

再补充一点,SHARED SERVER模式下每个用户的相关信息不是存储在PGA里的,而是SGA中。(原因很简单,因为每个用户请求不一定被那个SHARED SERVER处理,每个SHARED SERVER可能会处理不同用户的请求,所以用户相关信息当然要放在一个所有SAHRED SERVER PROCESS都可以访问到的地方啦)

而在DEDICATED SERVER模式下每个用户的相关信息就存在每个DEDICATED SERVER PROCESS各自对应的PGA里。

 

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值