Skip to Main Content
  • Questions
  • Introduction to Shared Server Performance

Breadcrumb

Question and Answer

Tom Kyte

Thanks for the question, Winston.

Asked: July 02, 2003 - 2:55 pm UTC

Last updated: September 16, 2008 - 12:05 pm UTC

Version: 9iR2

Viewed 1000+ times

You Asked

Hello Tom,

Here is the quote from
</code> http://download-west.oracle.com/docs/cd/B10501_01/server.920/a96533/features.htm#22618 <code>

<quote>
Performance of certain database features can improve when a shared server architecture is used, and performance of certain database features can degrade slightly when a shared server architecture is used. For example, a session can be prevented from migrating to another shared server while parallel execution is active.

A session can remain nonmigratable even after a request from the client has been processed, because not all the user information has been stored in the UGA. If a server were to process the request from the client, then the part of the user state that was not stored in the UGA would be inaccessible. To avoid this, individual shared servers often need to remain bound to a user session.
</quote>

What's the quickest way to experiment session migration between shared servers?
and could you please explain why 'A session can remain nonmigratable even after a request from the client has been processed, because not all the user information has been stored in the UGA.'?

Many thanks in advance,
Winston




and Tom said...

I guess the quickest way to see a migration would be to open two shared server sessions -- one each in a window.

Making sure you have max shared servers greater then one, run this query in session 1:

1 select server, paddr,
2 (select name from v$shared_server c where c.paddr = b.paddr ),
3 (select 'Me' from v$mystat where sid = b.sid and rownum=1)
4 from v$session b
5* where b.username = user
scott@ORA920> /

SERVER PADDR (SEL (S
--------- -------- ---- --
SHARED 57124F48 S000 Me
NONE 571252F8



That shows you have two sessions -- one is active and flagged as "me". It is using shared server S000 right now. Now, in the second session -- leaving this one idle -- execute:


scott@ORA920> exec dbms_lock.sleep(30)

That'll grab a shared server and it'll tend to grab S000. It'll hold it for 30 seconds. go back to session 1 and hit slash and you might see

scott@ORA920> /

SERVER PADDR (SEL (S
--------- -------- ---- --
SHARED 57125E08 S001 Me
SHARED 57124F48 S000

there, you have a "migrated session"


Now, there are some operations -- like a hash join for example -- that prevent migration. It used to be that these operations were not permitted via shared server -- but now they are.

If anything remains in the PGA after a call -- that session will be non-migratable, we need THAT specific shared server. If the remaining bits of data are safely in the UGA, that'll be in the SGA and we can migrate.

It is for that reason for example that PGA_AGGREGATE_TARGET is *not* used with shared server in 9i with shared server, sort_area_size/hash_area_size are, regardless of the workarea size policy setting.

Rating

  (9 ratings)

Is this answer out of date? If it is, please let us know via a Comment

Comments

Excellent...

Kamal Kishore, July 06, 2003 - 4:57 pm UTC

Hi Tom,
In your reply above you said:
<quote>
It used to be that these operations were not permitted via shared
server -- but now they are.
</quote>

Which version(s) of Oracle dd not permit this kind of operation(s)?

Was this restriction removed in Oracle9i? (meaning that up untill Oracle8i this was an issue with shared server config).

What used to happen when these operations were not permitted? Was it generating runtime error or it was silently ignored and query proceeded anyway.

Are there any other issuses like this that we may still have to lookout for even with Oracle9i?
Thanks,


Tom Kyte
July 06, 2003 - 5:31 pm UTC

bits and pieces, here and there, over time. The optimizer would not use that technique if the client was a shared server (eg: you can and still will get different plans for the same exact query based on part on the fact you have a shared server connect versus a dedicated server)

Strategy?

Kamal Kishore, July 06, 2003 - 7:32 pm UTC

Hi Tom,
At our client site we are currently running databases in DEDICATED server mode. The client site is planning to switch over to SHARED server mode.

Based upon your response above, it looks like that this seemingly simple switch might cause our query plans to suddenly change. What should be our strategy after the switch to the SHARED server mode? How should we make sure that our query performance is similar or better compared to before?

Would you equate this change to the database version upgrade? Would you apply the same rules as applied when a database version upgrade is carried out?
Or, there are alternate strategies to consider?
Thanks,


Tom Kyte
July 06, 2003 - 7:53 pm UTC

It'll mostly only affect large DW type queries.

I would equate this with a db upgrade, a patch, a tweak, a change. You should test. Do you have adequate shared servers configured? Do you need shared server? those would be more relevant probably then the query plan changes.

simply fabulous

Vijay'S, July 07, 2003 - 6:52 am UTC

Hey Tom,
Good day, once again simple and clear explanation.

Best Regards,
Vijay.

dedicated vs shared server

A reader, September 30, 2003 - 8:52 am UTC

Tom,
In chap. 2 of you book 'Effective Oracle by Design', the section 'How Do Dedicated Server Connections Work'
<quote>..Every dedicated server connection has a dedicated server allocated soley to it. This does not mean every single session has a dedicated server....it is possible for a single connection(dedicated server) to have many sessions concurrently active....In general....there is a one-to-one relationship between a session and a dedicated server.</quote>
q1)In a dedicated server connection, why dosen't it mean that every single connection has a dedicated server?
q2) You mention both the following
<quote>
it is possible for a single connection(dedicated server) to have many sessions concurrently active.....and also ..there is a one-to-one relationship between a session and a dedicated server</quote>
How can both of them be possible, can you please explain?

In the section 'Understanding Shared Server vs Dedicated Server Connections'
<quote>...that is time to consider switching over to shared servers...clients don't have control over this....</quote>
1) Can't the client change from a shared server connection to a dedicated server connection by modifying the TNSNames.ora file?
2) If the client dosen't have a TNSNames.ora, what parameter or entry decides shared server or dedicated server connection?
3)If an entry is made for the database in the DNS server. What configuration parameters tells yoy that the connection is configured either for a dedicated server or shared server
4) Is there a default mode(dedicated vs shared server) of connection/configuration, if nothing is specified?


Tom Kyte
September 30, 2003 - 9:07 am UTC

I think you meant chapter 3.

a1) because a single client process may open more then one session at a time. There is a CONNECTION, then within connections you create sessions -- as many as you need. typically -- this is "one session"

but you changed my words when you say:

<quote>
In a dedicated server connection, why dosen't it mean that every single
connection has a dedicated server?
</quote>

in a dedicated server connect, every CONNECTION does have a dedicated server, however, each SESSION need not have one.


a2) they are not possible simultaneously. you've taken some things out of context. Allow me to reproduce the text in question:


<quote>
So, in dedicated server mode, there is a one-to-one mapping between processes in the database and a client process. Every dedicated server connection has a dedicated server allocated solely to it. That does not mean every single session has a dedicated server, for it is possible for a single application, using a single physical connection (dedicated server) to have many sessions concurrently active. In general however, when in dedicated server mode, there is a one to one relationship between a session and a dedicated server.
</quote>

you left out the "IN GENERAL HOWEVER" that time, a key modifier -- in general, there is a one to one relationship. What MOST people will observe in practice is a one to one relationship. However, there need not be a one to one relationship.


1) that is not a client decision -- the database must be setup for it as well. I do not consider rewriting configuration files to be a "client decision". The database must be setup for shared server

2) the database, when it registers itself with the listener, decides how the service will work.

3) the listener and database deal with that.

4) dedicated is default out of the box (always there)





dedicated vs shared server

A reader, October 01, 2003 - 8:21 am UTC

Tom,
How are connections and sessions different?
If I need 2 SQLPlus sessions, I will need 2 connections. Can you give an example where for a single application, using a single physical connection (dedicated server) to have many sessions concurrently active.

Thank you

Tom Kyte
October 01, 2003 - 9:36 am UTC


sqlplus is an example.

when you set autotrace on with statistics -- sqlplus will actually use TWO sessions -- one you interact with and run the query in and another that watches your statistics (so as to not have the watching of the statistics INFLUENCE the statistics themselves!)

so, there you have a case where by you have one connection (physical circut from client to server) but more then one session.

forms does it -- for debugging.


app servers do it, for connection pooling.

dedicated vs shared server

A reader, October 01, 2003 - 8:20 pm UTC

Thank you.


Q on Shared Server

Anil Pant, June 29, 2004 - 6:58 am UTC

why are some of the administrative tasks (shutdown/startup) not allowed in shared server connection mode?



Tom Kyte
June 29, 2004 - 8:09 am UTC

because you need a dedicated server for them -- consider that in order to startup for example, you need "something" there. if the "something" was a shared server -- the database would already be up, for you cannot have a shared server without a database instance! it would be a chicken and egg, similar with shutdown -- in order to shutdown, there will be no instance. if there is no instance, there can be no shared server, if you don't have a shared server, you cannot shutdown cleanly.

Shared Server doubt

Felipe, February 14, 2006 - 6:52 am UTC

Hi Tom,

I was reading chapter 5 of your book (expert oracle database architecture) Regarding the use of shared servers and now I have some doubts.

If I have a database whith 50.000 users, I really thing that shared server is the best option, to reduce the number of process and memory use. But the example you gave scared me, "if I have 3 clients, and all of them attempt to run a 45-seconds process more or less at the same time, 2 of them will get their responses in 45 seconds and the third will get its responses in 90 seconds" I really don´t want this kind of situation in my application, so is there any way to avoid or reduce it ? Is it possible to configure a shared process to allow only 4 user per shared process s001(4 users), s002(4 users) reducing the number of users in a shared server process probably will reduce this situation happening every time.

I Know that I should use shared server only if my queries are really very fast like milliseconds. but I still have some 5 to 10 seconds queries in my application. In the book you say that features like advanced queuing (AQ) turns long-running process into a apparently short one . Where can I find more documentation regarding this feature ? I found something regarding this in OTN but I´m not sure if it´s the right documentation of this feature because it´s saying about Oracle streams...

And thank you for writing this amazing book ... I´m sure I´m learning a lot of new things.

Thank you,
Felipe

Tom Kyte
February 14, 2006 - 8:18 am UTC

if you have 50,000 CLIENT SERVER users (if you are 50,000 users connected over a stateless web application - you don't need to consider shared server, you already have a connection pool...) you need to ask yourself:

o how many do I want to be concurrently active at any point in time.

pick that number, set that number. That is the number of concurrent active sessions you feel your hardware can deal with.

If you have 50,000 client server users that run statements are measured in 10's of seconds - you have a much bigger problem.


There is AQ + streams (complimentary technologies).

Migrated session

Anil, September 11, 2008 - 12:41 am UTC

Hello Tom,
While answering the original question, you have shown an example and said <<there, you have a "migrated session">>

Can you please explain what does it mean by migrated session?

Thanks


Tom Kyte
September 16, 2008 - 12:05 pm UTC

your session migrates from process to process in shared server.

In shared server, your session only has a process when your session is actively doing something in the database. Every request you make in shared server might use a different operating system process to perform the work (unlike dedicated server where you have your own process and your session is bound to that process).

Your session "migrates" from process to process - moves.

More to Explore

DBMS_LOCK

More on PL/SQL routine DBMS_LOCK here