+ All Categories
Home > Technology > Oracle 12c Multithreaded Multi Process

Oracle 12c Multithreaded Multi Process

Date post: 11-Apr-2017
Category:
Upload: markus-flechtner
View: 1,134 times
Download: 4 times
Share this document with a friend
43
Oracle 12c: Multi Oracle 12c: Multi Process Process Multi Multi Threaded Threaded A A closer closer look look at at the the multi multi-process process multi multi-threaded threaded model model for for Oracle Oracle on Linux/Unix on Linux/Unix Markus Flechtner Markus Flechtner Senior Consultant Senior Consultant BASLE BERN BRUGG DÜSSELDORF FRANKFURT A.M. FREIBURG I.BR. GENEVA HAMBURG COPENHAGEN LAUSANNE MUNICH STUTTGART VIENNA ZURICH
Transcript
Page 1: Oracle 12c Multithreaded Multi Process

Oracle 12c: Multi Oracle 12c: Multi ProcessProcess Multi Multi ThreadedThreadedA A closercloser looklook atat thethe multimulti--processprocess multimulti--threadedthreaded model model forfor Oracle Oracle on Linux/Unixon Linux/Unix

Markus FlechtnerMarkus FlechtnerSenior ConsultantSenior Consultant

BASLE BERN BRUGG DÜSSELDORF FRANKFURT A.M. FREIBURG I.BR. GENEVA HAMBURG COPENHAGEN LAUSANNE MUNICH STUTTGART VIENNA ZURICH

Page 2: Oracle 12c Multithreaded Multi Process

Our company.

Trivadis is a market leader in IT consulting, system integration, solution engineeringand the provision of IT services focusing on and technologiesin Switzerland, Germany, Austria and Denmark. We offer our services in the following strategic business fields:

Oracle 12c: Multi Process Multi Threaded2 11/4/2015

Trivadis Services takes over the interactive operation of your IT systems.

O P E R A T I O NO P E R A T I O N

Page 3: Oracle 12c Multithreaded Multi Process

COPENHAGEN

HAMBURG

DÜSSELDORF

With over 600 specialists and IT experts in your region.

14 Trivadis branches and more than600 employees

200 Service Level Agreements

Over 4,000 training participants

Research and development budget:CHF 5.0 / EUR 4 million

MUNICH

LAUSANNEBERN

ZURICH

BRUGG

GENEVA

DÜSSELDORF

FRANKFURT

STUTTGART

FREIBURG

BASLE

VIENNA

Oracle 12c: Multi Process Multi Threaded3 11/4/2015

CHF 5.0 / EUR 4 million

Financially self-supporting and sustainably profitable

Experience from more than 1,900 projects per year at over 800customers

Page 4: Oracle 12c Multithreaded Multi Process

About Markus Flechtner

Senior Consultant, Trivadis, Duesseldorf/Germany, since April 2008

Discipline Infrastructure Database @Trivadis

Working with Oracle since the 1990’s– Development (Forms, Reports, PL/SQL)

– Support

– Database Administration

Focus– Oracle Real Application Clusters

– Database Migration Projects

Teacher– O-RAC – Oracle Real Application Clusters

– O-NF12CDBA – Oracle 12c New Features for the DBA

Blog:http://markusdba.de/

@markusdba

Oracle 12c: Multi Process Multi Threaded4 11/4/2015

Page 5: Oracle 12c Multithreaded Multi Process

Agenda

1. The problem & existing solutions

2. New in Oracle Database 12c: THREADED_EXECUTION

3. Architecture

4. Performance

Oracle 12c: Multi Process Multi Threaded5 11/4/2015

5. Threaded Execution in the daily DBA business

6. Pros & Cons

Page 6: Oracle 12c Multithreaded Multi Process

The The problemproblem & & existingexisting solutionssolutions

Oracle 12c: Multi Process Multi Threaded6 11/4/2015

Page 7: Oracle 12c Multithreaded Multi Process

The problem & existing solutions (1)

In the dedicated server achitecture on Unix/Linux:

– every client session has got its own server process

– these processes need memory and processor time

– there are many context switches

Many applications

Oracle 12c: Multi Process Multi Threaded7 11/4/2015

Many applications

– Keep database sessions open and rarely execute SQL statements

Result

– Overhead on the database server

– Waste of system resources

Page 8: Oracle 12c Multithreaded Multi Process

The problem & existing solutions (2)

Existing solutions

– Shared Server (Multithreaded Server)

– Database Resident Connection Pooling (DRCP)� not for all applications

– Universal Connection Pool (UCP)

Oracle 12c: Multi Process Multi Threaded8 11/4/2015

– Connection Pools in general (Application Server)

All these solutions affect client sessions only

Page 9: Oracle 12c Multithreaded Multi Process

The problem & existing solutions (3)

Overview on existing solutions

Oracle 12c: Multi Process Multi Threaded9 11/4/2015

• From Oracle Database 12c Administrators Guide © Oracle Corporation

Page 10: Oracle 12c Multithreaded Multi Process

The problem & existing solutions (4)

The “Multithreaded Oracle Process Model” does not replace these solutions but is a new method to reduce the resource consumption of a database instance on a Linux/Unix

Oracle 12c: Multi Process Multi Threaded10 11/4/2015

these solutions but is a new method to reduce the resource consumption of a database instance on a Linux/Unix database server.

Page 11: Oracle 12c Multithreaded Multi Process

New in Oracle Database 12c: New in Oracle Database 12c: THREADED_EXECUTIONTHREADED_EXECUTION

Oracle 12c: Multi Process Multi Threaded11 11/4/2015

""Multithreaded Oracle Process Model"Multithreaded Oracle Process Model"

Page 12: Oracle 12c Multithreaded Multi Process

Processes vs. Threads

Process

– A process is an instance of a computer program that is being executed. It contains the program code and its current activity. Depending on the operating system (OS), a process may be made up of multiple threads of execution that execute instructions concurrently

Process

Thread 1

Thread 2

Oracle 12c: Multi Process Multi Threaded12 11/4/2015

Threads

– A thread of execution is the smallest sequence of programmed instructions that can be managed independently by a scheduler ..

Source: Wikipedia (http://en.wikipedia.org)

Thread 2

Page 13: Oracle 12c Multithreaded Multi Process

Multithreaded Oracle Process Model (1)

The “Multithreaded Oracle Process Model” on Unix/Linux enables the database instance to run instance processes as operating system threads

– Similar to Oracle on Windows

– No additional license costs; works on SE1, SE2, SE and EE

Configuration:

Oracle 12c: Multi Process Multi Threaded13 11/4/2015

– Restart the instance

– Result: (most) background processes and local connections run as OS threads

ALTER SYSTEM SET threaded_execution=TRUE SCOPE=spfile SID='*'

Page 14: Oracle 12c Multithreaded Multi Process

Multithreaded Oracle Process Model (2)

For remote clients which connect via Oracle Net a parameter for the listener must be set in the listener.ora file:

– Restart the listener afterwards

DEDICATED_THROUGH_BROKER_<listener_name>=ON

Oracle 12c: Multi Process Multi Threaded14 11/4/2015

If you want to run remote clients in threaded and non-threaded mode, a second listener is required

– Different port and/or host name resp. IP address

– DEDICATED_THROUGH_BROKER_<new_listener>=OFF (default)

Page 15: Oracle 12c Multithreaded Multi Process

Multithreaded Oracle Process Model (3) – DB Connect

Conn.Broker(Thread)

LISTENER

➌Thread for

Oracle 12c: Multi Process Multi Threaded15 11/4/2015

SGA

➍➎

➌Thread for

DB Session

Page 16: Oracle 12c Multithreaded Multi Process

ArchitectureArchitecture

Oracle 12c: Multi Process Multi Threaded16 11/4/2015

Page 17: Oracle 12c Multithreaded Multi Process

Architecture (1) - Processes

Process list of an Oracle instance with THREADED_EXECUTION

oracle@te:~/ [TEST] ps –ef |grep $ORACLE_SID

oracle 6593 1 0 10:02 ? 00:00:00 ora_pmon_TEST

oracle 6595 1 0 10:02 ? 00:00:00 ora_psp0_TEST

oracle 6597 1 14 10:02 ? 00:00:03 ora_vktm_TEST

oracle 6601 1 23 10:02 ? 00:00:05 ora_u004_TEST

oracle 6607 1 99 10:02 ? 00:00:22 ora_u005_TEST

Oracle 12c: Multi Process Multi Threaded17 11/4/2015

“Threaded Sessions” are “hidden” in the "ora_u<nnn>_<SID>“-processes

oracle 6607 1 99 10:02 ? 00:00:22 ora_u005_TEST

oracle 6613 1 0 10:02 ? 00:00:00 ora_dbw0_TEST

Page 18: Oracle 12c Multithreaded Multi Process

Architecture (2) - Processes

oracle@te:~/ [TEST] ps –ef |grep ora_u00

oracle 31220 1 2 21:18 ? 00:00:03 ora_u004_TEST

oracle 31226 1 11 21:18 ? 00:00:13 ora_u005_TEST

oracle@te:~/ [TEST] pidstat -t -p 31220

Linux 3.8.13-26.2.1.el6uek.x86_64 (te.markusflechtner.vm) 03/22/2014 _x86_64_ (4 CPU)

09:20:45 PM TGID TID %usr %system %guest %CPU CPU Command

09:20:45 PM 31220 - 0.01 0.01 0.00 0.02 3 ora_scmn_test

09:20:45 PM - 31220 0.00 0.00 0.00 0.00 3 |__ora_scmn_test

09:20:45 PM - 31221 0.00 0.00 0.00 0.00 1 |__oracle

Oracle 12c: Multi Process Multi Threaded18 11/4/2015

09:20:45 PM - 31221 0.00 0.00 0.00 0.00 1 |__oracle

09:20:45 PM - 31222 0.00 0.00 0.00 0.00 0 |__ora_gen0_test

09:20:45 PM - 31223 0.00 0.00 0.00 0.00 2 |__ora_mman_test

09:20:45 PM - 31229 0.00 0.00 0.00 0.00 3 |__ora_dbrm_test

09:20:45 PM - 31233 0.00 0.00 0.00 0.00 1 |__ora_lgwr_test

09:20:45 PM - 31234 0.00 0.00 0.00 0.00 0 |__ora_ckpt_test

09:20:45 PM - 31235 0.00 0.00 0.00 0.00 3 |__ora_lg00_test

09:20:45 PM - 31236 0.00 0.00 0.00 0.00 3 |__ora_smon_test

09:20:45 PM - 31237 0.00 0.00 0.00 0.00 2 |__ora_lg01_test

09:20:45 PM - 31239 0.00 0.00 0.00 0.00 3 |__ora_lreg_test

Page 19: Oracle 12c Multithreaded Multi Process

Architecture (3) – V$PROCESS

SQL> select spid,stid,execution_type,pname from v$process

2 where spid is not null and (execution_type=‘PROCESS’ or pname in

3 ('PMON','SMON','DBW0','PSP0','VKTM','MMON','RECO','LGWR',’SCMN’));

SPID STID EXECUTION_ PNAME

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

6593 6593 PROCESS PMON

6595 6595 PROCESS PSP0

6597 6597 PROCESS VKTM

Oracle 12c: Multi Process Multi Threaded19 11/4/2015

6597 6597 PROCESS VKTM

6601 6614 THREAD LGWR

6601 6601 THREAD SCMN

6601 6618 THREAD SMON

6607 6621 THREAD MMON

6607 6607 THREAD SCMN

6607 6619 THREAD RECO

6613 6613 PROCESS DBW0

Page 20: Oracle 12c Multithreaded Multi Process

Architecture (4)

The “SCMN”-Thread is the “thread listener” or “thread coordinator” within the process

The threaded sessions remain “dedicated server” sessions:

SQL> select p.execution_type,s.server,count(*)

2 from v$process p,v$session s

3 where s.paddr=p.addr

4 group by p.execution_type,s.server;

Oracle 12c: Multi Process Multi Threaded20 11/4/2015

PGA is allocated from the shared pool (like with “Shared Server")

EXECUTION_ SERVER COUNT(*)

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

THREAD DEDICATED 38

PROCESS DEDICATED 4

Page 21: Oracle 12c Multithreaded Multi Process

Architecture (5)

Oracle 12c: Multi Process Multi Threaded21 11/4/2015

Ora_uNNN processes are terminated after beeing idle for 30 seconds

Every threaded session needs a processes slot (=> Parameter PROCESSES) (� TNS-12602 “Connection pooling limit reached.”)

Page 22: Oracle 12c Multithreaded Multi Process

Architecture (6) – Memory Consumption

In average:18% less memoryconsumption with„THREADED_EXECUTION“

Oracle 12c: Multi Process Multi Threaded22 11/4/2015

Page 23: Oracle 12c Multithreaded Multi Process

Architecture (7) – Connection Broker

Threaded Execution requires a Connection Broker

The new parameter CONNECTION_BROKERS is set automatically when THREADED_EXECUTION=TRUE

SQL> show parameter connection_brokers

NAME TYPE VALUE

Oracle 12c: Multi Process Multi Threaded23 11/4/2015

NAME TYPE VALUE

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

connection_brokers string ((TYPE=DEDICATED)(BROKERS=1)),

((TYPE=EMON)(BROKERS=1))

Page 24: Oracle 12c Multithreaded Multi Process

Architecture (8) – Connection Broker & Listener

lsnrctl services

[..]

Service "TEST.markusflechtner.vm" has 1 instance(s).

Instance "TEST", status READY, has 2 handler(s) for this service...

Handler(s):

"N000" established:1 refused:0 state:ready

CMON <machine: te.markusflechtner.vm, pid: 1649_1668>

Oracle 12c: Multi Process Multi Threaded24 11/4/2015

CMON <machine: te.markusflechtner.vm, pid: 1649_1668>

(ADDRESS=(PROTOCOL=tcp)(HOST=127.0.0.1)(PORT=34848))

"DEDICATED" established:0 refused:0 state:ready

LOCAL SERVER

[..]

Page 25: Oracle 12c Multithreaded Multi Process

Architecture (9) – Connection Broker & Listener

oracle@te:~/ [TEST] ps –ef |grep 1649

oracle 1649 1 9 19:24 ? 00:05:12 ora_u005_TEST

SQL> select spid,stid,pname,execution_type from v$process

2 where spid=1649 and stid=1668;

SPID STID PNAME EXECUTION_TYPE

Oracle 12c: Multi Process Multi Threaded25 11/4/2015

SPID STID PNAME EXECUTION_TYPE

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

1649 1668 N000 THREAD

Page 26: Oracle 12c Multithreaded Multi Process

Architecture (10) - Miscellaneous

Threaded Execution & CPU usage

– No essential difference to "Non-Threaded-Execution"

Threaded Execution & Connect Time

– No essential difference to "Non-Threaded-Execution"

Threaded Execution on Windows

Oracle 12c: Multi Process Multi Threaded26 11/4/2015

Threaded Execution on Windows

– The parameter has no effect

Multitenant Databases

– An OS process can contain sessions of multiple PDBs

Page 27: Oracle 12c Multithreaded Multi Process

PerformancePerformance

Oracle 12c: Multi Process Multi Threaded27 11/4/2015

Page 28: Oracle 12c Multithreaded Multi Process

Performance (1) – Test Environment

Host

– Notebook Lenovo W510 / 32 GB RAM / SSD

– Oracle Linux 6.5

Virtual Server (VirtualBox)

– 16 GB RAM

Oracle 12c: Multi Process Multi Threaded28 11/4/2015

– 16 GB RAM

Oracle Database

– Oracle 12.1.0.1

– 6000M SGA / 2000M PGA

– Non-CDB-Architecture

Page 29: Oracle 12c Multithreaded Multi Process

Performance (2) – Test with Swingbench

Test Software

– Swingbench 2.5.0.99 (www.dominicgiles.com)

– 3 tests with50 - 900 sessions, average of transactions

Oracle 12c: Multi Process Multi Threaded29 11/4/2015

average of transactionsper second

Page 30: Oracle 12c Multithreaded Multi Process

Performance (3) - Results

Oracle 12c: Multi Process Multi Threaded30 11/4/2015

Page 31: Oracle 12c Multithreaded Multi Process

Performance (4) – Other tests

Oracle presentation on „Real Application Testing":

– 5% better performance with THREADED_EXECUTION

Thomas Bordeau: http://blog.arkzoyd.com/2014/01/17/oracle-multithreaded-does-it-worth-a-try/

– Another test with Swingbench☺

Oracle 12c: Multi Process Multi Threaded31 11/4/2015

Overall result:�Better performance�Better scalability

Page 32: Oracle 12c Multithreaded Multi Process

ThreadedThreaded ExecutionExecutionin in thethe dailydaily DBA DBA businessbusiness

Oracle 12c: Multi Process Multi Threaded32 11/4/2015

Page 33: Oracle 12c Multithreaded Multi Process

OS Authentication (1)

OS authentication is not supported with threaded execution

– � ORA-1017 invalid username ..

– Password File required

– � Startup/Shutdown scripts have to be changed

Some Oracle tools require "Non-Threaded Execution"

Oracle 12c: Multi Process Multi Threaded33 11/4/2015

Some Oracle tools require "Non-Threaded Execution"

– dbca

– dbua

– datapatch

Page 34: Oracle 12c Multithreaded Multi Process

OS Authentication (2) - Workaround

Store the password in a wallet

In short (see MOS-Note 340559.1 for details)

# create wallet

mkstore -wrl <wallet_location> -create

# add db authentication information

mkstore -wrl <wallet_location> -createCredential <db_connect_string>

<username> <password>

Oracle 12c: Multi Process Multi Threaded34 11/4/2015

<username> <password>

# add the following lines to sqlnet.ora

WALLET_LOCATION =

(SOURCE =

(METHOD = FILE)

(METHOD_DATA = (DIRECTORY = <wallet_location_directory>)))

SQLNET.WALLET_OVERRIDE = TRUE

Connect to the DB using sqlplus sys/@<DB_Connect_String>

Page 35: Oracle 12c Multithreaded Multi Process

OS Authentication (3) – Other workarounds

sqlplus

/@"(ADDRESS=(PROTOCOL=BEQ)(PROGRAM=oracle)(ARGS='(ADDRESS=(PROTOCOL=BEQ))'

))" AS SYSDBA

# the way the clusterware agent connects to the instance

sqlplus

Oracle 12c: Multi Process Multi Threaded35 11/4/2015

sqlplus

/@"(DESCRIPTION=(ADDRESS=(PROTOCOL=beq)(PROGRAM=/u00/app/oracle/product/12

.1.0.2/bin/oracle)(ARGV0=oracleGG03)(ENVS='ORACLE_HOME=/u00/app/oracle/pro

duct/12.1.0.2,ORACLE_SID=TEST,LD_LIBRARY_PATH=,ORACLE_BASE=')(ARGS='(DESCR

IPTION=(LOCAL=YES)(ADDRESS=(PROTOCOL=beq)))')(CONNECT_DATA=(SID=TEST))))"

AS SYSDBA

Page 36: Oracle 12c Multithreaded Multi Process

SQL Tracing

What‘s the name of the trace file?

� The filename contains SPID and STID

SQL> select spid,stid,execution_type,tracefile from v$process;

SPID STID E_TYPE TRACEFILE

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

Oracle 12c: Multi Process Multi Threaded36 11/4/2015

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

NONE /u00/app/oracle/diag/rdbms/test/TEST/trace/TEST_ora_0.trc

6961 6961 PROCESS /u00/app/oracle/diag/rdbms/test/TEST/trace/TEST_pmon_6961.trc

6963 6963 PROCESS /u00/app/oracle/diag/rdbms/test/TEST/trace/TEST_psp0_6963.trc

6965 6965 PROCESS /u00/app/oracle/diag/rdbms/test/TEST/trace/TEST_vktm_6965.trc

6969 6971 THREAD /u00/app/oracle/diag/rdbms/test/TEST/trace/TEST_gen0_6969_6971.trc

6969 6969 THREAD /u00/app/oracle/diag/rdbms/test/TEST/trace/TEST_scmn_6969_6969.trc

6969 6972 THREAD /u00/app/oracle/diag/rdbms/test/TEST/trace/TEST_mman_6969_6972.trc

6975 7000 THREAD /u00/app/oracle/diag/rdbms/test/TEST/trace/TEST_ora_6975_7000.trc

..

Page 37: Oracle 12c Multithreaded Multi Process

How to kill database sessions?

As usual, sessions are identified via SID and SERIAL# in V$SESSION

Kill on database/instance level works fine:

But „kill -9 <spid>“ on OS level is not a good idea �

ALTER SYSTEM KILL SESSION ‘<sid>,<serial#>‘;

Oracle 12c: Multi Process Multi Threaded37 11/4/2015

But „kill -9 <spid>“ on OS level is not a good idea

A thread cannot be killled from without the corresponding OS process

„kill -6 <stid>“ (SIGABRT) can help

– � find out the thread id via V$PROCESS or „pidstat“

– � execute „kill -6 <stid>“

Page 38: Oracle 12c Multithreaded Multi Process

Pros & Pros & ConsCons

Oracle 12c: Multi Process Multi Threaded38 11/4/2015

Page 39: Oracle 12c Multithreaded Multi Process

Pros & Cons - Pro

Easy setup

Reduced memory consumption

Reduced number of processes on OS level

– � less context switches

Performance

Statements regarding performance and scalability have to be verified in each

Oracle 12c: Multi Process Multi Threaded39 11/4/2015

Performance

– Equal or better than "non-threaded execution“

Scalability

– Equal or better than „non-threaded execution“

have to be verified in each individual case!

Test Threaded Execution with your application before you use it!

Page 40: Oracle 12c Multithreaded Multi Process

Pros & Cons - Con

Missing OS authentication

– Scripts have to be changed

„kill -9“ does not work

srvctl (RAC) does not work

– Unpublished bug

Oracle 12c: Multi Process Multi Threaded40 11/4/2015

– Unpublished bug

Page 41: Oracle 12c Multithreaded Multi Process

Summary

There‘s not much information from Oracle on this feature

It is not really clear, why Oracle introduced this feature

There is no experience from customer projects so far, but if you accept the disadvantages(missing OS authentication, killing sessions on OS level), the „Multithreaded Multi Threaded“-model can make sense, if

Oracle 12c: Multi Process Multi Threaded41 11/4/2015

Threaded“-model can make sense, if

– Your application does not support connection pools

– Your database is low on memory

But „Threaded execution“ cannot replace connection pools

Page 42: Oracle 12c Multithreaded Multi Process

Further InformationFurther Information

Oracle 12c: Multi Process Multi Threaded42 11/4/2015

�MOS-Note 1639445.1: 12c: Threaded_execution=true Prevents OS Login As Sysdba�MOS-Note 1958348.1: Multi-Threaded Oracle Model�MOS-Note 340559.1: „Using The Secure External Password Store“�Oracle Presentation „Maximizing Database Performance Using Database Replay“�http://blog.arkzoyd.com/2014/01/17/oracle-multithreaded-does-it-worth-a-try/�http://dbwhisperer.wordpress.com/2013/10/04/multi-threaded-oracle-12c-Architektur-on-linux-2/

Page 43: Oracle 12c Multithreaded Multi Process

QuestionsQuestions andand AnswersAnswersMarkus FlechtnerMarkus FlechtnerSenior ConsultantSenior Consultant

Phone +49 211 5866 6470Phone +49 211 5866 [email protected]@Trivadis.com

@@markusdbamarkusdba http://markusdba.dehttp://markusdba.de

Download the slides from http://www.slideshare.net/markusdba

Please don‘t forget the session evaluation – Thank you!

11/4/2015 Oracle 12c: Multi Process Multi Threaded43


Recommended