Automating Google Workspace (GWS) & more with Apps Script
Oracle 12c Multi Process Multi Threaded
1. BASLE BERN BRUGG DÜSSELDORF FRANKFURT A.M. FREIBURG I.BR. GENEVA
HAMBURG COPENHAGEN LAUSANNE MUNICH STUTTGART VIENNA ZURICH
Oracle 12c: Multi Process Multi Threaded
A closer look at the multi-process multi-threaded model for Oracle
on Linux/Unix
Markus Flechtner
Senior Consultant
Flechtner_Oracle_12c_multi_process_multi_t
hreaded.pptx
2. Our company.
Oracle 12c: Multi Process Multi Threaded3 12/24/16
Trivadis is a market leader in IT consulting, system integration, solution engineering
and the provision of IT services focusing on and technologies
in Switzerland, Germany, Austria and Denmark. We offer our services in the following
strategic business fields:
Trivadis Services takes over the interactive operation of your IT systems.
O P E R A T I O N
3. COPENHAGEN
MUNICH
LAUSANNE
BERN
ZURICH
BRUGG
GENEVA
HAMBURG
DÜSSELDORF
FRANKFURT
STUTTGART
FREIBURG
BASLE
VIENNA
With over 600 specialists and IT experts in your region.
Oracle 12c: Multi Process Multi Threaded4 12/24/16
14 Trivadis branches and more than
600 employees
200 Service Level Agreements
Over 4,000 training participants
Research and development budget:
CHF 5.0 / EUR 4 million
Financially self-supporting and
sustainably profitable
Experience from more than 1,900
projects per year at over 800
customers
4. 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 Threaded5 12/24/16
5. Agenda
Oracle 12c: Multi Process Multi Threaded6 12/24/16
1. The problem & existing solutions
2. New in Oracle Database 12c: THREADED_EXECUTION
3. Architecture
4. Performance
5. Threaded Execution in the daily DBA business
6. Pros & Cons
6. Oracle 12c: Multi Process Multi Threaded7 12/24/16
The problem & existing solutions
7. The problem & existing solutions (1)
Oracle 12c: Multi Process Multi Threaded8 12/24/16
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
– Keep database sessions open and rarely execute SQL statements
Result
– Overhead on the database server
– Waste of system resources
8. The problem & existing solutions (2)
Oracle 12c: Multi Process Multi Threaded9 12/24/16
Existing solutions
– Shared Server (Multithreaded Server)
– Database Resident Connection Pooling (DRCP)
è not for all applications
– Universal Connection Pool (UCP)
– Connection Pools in general (Application Server)
All these solutions affect client sessions only
10. The problem & existing solutions (4)
Oracle 12c: Multi Process Multi Threaded11 12/24/16
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
database server.
11. Oracle 12c: Multi Process Multi Threaded12 12/24/16
New in Oracle Database 12c:
THREADED_EXECUTION
"Multithreaded Oracle Process Model"
12. Processes vs. Threads
Oracle 12c: Multi Process Multi Threaded13 12/24/16
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
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)
Process
Thread 1
Thread 2
13. Multithreaded Oracle Process Model (1)
Oracle 12c: Multi Process Multi Threaded14 12/24/16
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:
– Restart the instance
– Result: (most) background processes and local connections run as OS threads
ALTER SYSTEM SET threaded_execution=TRUE SCOPE=spfile SID='*'
14. Multithreaded Oracle Process Model (2)
Oracle 12c: Multi Process Multi Threaded15 12/24/16
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
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)
DEDICATED_THROUGH_BROKER_<listener_name>=ON
15. Multithreaded Oracle Process Model (3) – DB Connect
Oracle 12c: Multi Process Multi Threaded16 12/24/16
Conn.Broker
(Thread)
SGA
LISTENER
➊
➍
➎
➋
➌
Thread for
DB Session
19. Architecture (3) – V$PROCESS
Oracle 12c: Multi Process Multi Threaded20 12/24/16
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
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
20. Architecture (4)
Oracle 12c: Multi Process Multi Threaded21 12/24/16
The “SCMN”-Thread is the “thread listener” or “thread coordinator” within the process
The threaded sessions remain “dedicated server” sessions:
PGA is allocated from the shared pool (like with “Shared Server")
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;
EXECUTION_ SERVER COUNT(*)
---------- --------- ----------
THREAD DEDICATED 38
PROCESS DEDICATED 4
21. Architecture (5)
Oracle 12c: Multi Process Multi Threaded22 12/24/16
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.”)
22. Architecture (6) – Memory Consumption
Oracle 12c: Multi Process Multi Threaded23 12/24/16
In average:
18% less memory
consumption with
„THREADED_EXECUTION“
23. Architecture (7) – Connection Broker
Oracle 12c: Multi Process Multi Threaded24 12/24/16
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
------------------ ------- ----------------------------------------
connection_brokers string ((TYPE=DEDICATED)(BROKERS=1)),
((TYPE=EMON)(BROKERS=1))
24. Architecture (8) – Connection Broker & Listener
Oracle 12c: Multi Process Multi Threaded25 12/24/16
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>
(ADDRESS=(PROTOCOL=tcp)(HOST=127.0.0.1)(PORT=34848))
"DEDICATED" established:0 refused:0 state:ready
LOCAL SERVER
[..]
25. Architecture (9) – Connection Broker & Listener
Oracle 12c: Multi Process Multi Threaded26 12/24/16
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
---------------- ---------------- ----- --------------
1649 1668 N000 THREAD
26. Architecture (10) - Miscellaneous
Oracle 12c: Multi Process Multi Threaded27 12/24/16
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
– The parameter has no effect
Multitenant Databases
– An OS process can contain sessions of multiple PDBs
28. Performance (1) – Test Environment
Oracle 12c: Multi Process Multi Threaded29 12/24/16
Host
– Notebook Lenovo W510 / 32 GB RAM / SSD
– Oracle Linux 6.5
Virtual Server (VirtualBox)
– 16 GB RAM
Oracle Database
– Oracle 12.1.0.1
– 6000M SGA / 2000M PGA
– Non-CDB-Architecture
29. Performance (2) – Test with Swingbench
Oracle 12c: Multi Process Multi Threaded30 12/24/16
Test Software
– Swingbench 2.5.0.99
(www.dominicgiles.com)
– 3 tests with
50 - 900 sessions,
average of transactions
per second
30. Performance (3) - Results
Oracle 12c: Multi Process Multi Threaded31 12/24/16
31. Performance (4) – Other tests
Oracle 12c: Multi Process Multi Threaded32 12/24/16
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 SwingbenchJ
Overall result:
èBetter performance
èBetter scalability
32. Oracle 12c: Multi Process Multi Threaded33 12/24/16
Threaded Execution
in the daily DBA business
33. OS Authentication (1)
Oracle 12c: Multi Process Multi Threaded34 12/24/16
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"
– dbca
– dbua
– datapatch
34. OS Authentication (2) - Workaround
Oracle 12c: Multi Process Multi Threaded35 12/24/16
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>
# 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>
35. OS Authentication (3) – Other workarounds
Oracle 12c: Multi Process Multi Threaded36 12/24/16
sqlplus
/@"(ADDRESS=(PROTOCOL=BEQ)(PROGRAM=oracle)(ARGS='(ADDRESS=(PROTOCOL=BEQ))'
))" AS SYSDBA
# the way the clusterware agent connects to the instance
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
36. SQL Tracing
Oracle 12c: Multi Process Multi Threaded37 12/24/16
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
----- ----- ------- ------------------------------------------------------------------
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
..
37. How to kill database sessions?
Oracle 12c: Multi Process Multi Threaded38 12/24/16
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 L
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>“
ALTER SYSTEM KILL SESSION ‘<sid>,<serial#>‘;
39. Pros & Cons - Pro
Oracle 12c: Multi Process Multi Threaded40 12/24/16
Easy setup
Reduced memory consumption
Reduced number of processes on OS level
– è less context switches
Performance
– Equal or better than "non-threaded execution“
Scalability
– Equal or better than „non-threaded execution“
Statements regarding
performance and scalability
have to be verified in each
individual case!
Test Threaded Execution with
your application before you use
it!
40. Pros & Cons - Con
Oracle 12c: Multi Process Multi Threaded41 12/24/16
Missing OS authentication
– Scripts have to be changed
„kill -9“ does not work
srvctl (RAC) does not work
– Unpublished bug
41. Summary
Oracle 12c: Multi Process Multi Threaded42 12/24/16
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
– Your application does not support connection pools
– Your database is low on memory
But „Threaded execution“ cannot replace connection pools
42. Oracle 12c: Multi Process Multi Threaded43 12/24/16
§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/
Further Information
43. Questions and Answers
Markus Flechtner
Senior Consultant
Phone +49 211 5866 6470
Markus.Flechtner@Trivadis.com
@markusdba http://markusdba.de
Download the slides from http://www.slideshare.net/markusdba
Please don‘t forget the session evaluation – Thank you!
12/24/16 Oracle 12c: Multi Process Multi Threaded44