Oracle Database Server Architecture: Overview

 





Memory Structures

There are three major structures in Oracle Database server architecture: memory structures, process structures, and storage structures. A basic Oracle database system consists of an Oracle database and a database instance.

Oracle Database Server Architecture - memory structures

The database consists of both physical structures and logical structures. Because the physical and logical structures are separate, the physical storage of data can be managed without affecting access to logical storage structures.


The instance consists of memory structures and background processes associated with that instance. Every time an instance is started, a shared memory area called the System Global Area (SGA) is allocated and the background processes are started. Processes are jobs that work in the memory of computers. A process is defined as a “thread of control” or a mechanism in an operating system that can run a series of steps. After starting a database instance, the Oracle software associates the instance with a specific physical database. This is called mounting the database. The database is then ready to be opened, which makes it accessible to authorized users.


Connecting to the Database Instance

Connections and sessions are closely related to user processes but are very different in meaning.

oracle database architecture - session vs connection

A connection is a communication pathway between a user process and an Oracle Database instance. A communication pathway is established using available interprocess communication mechanisms (on a computer that runs both the user process and Oracle Database) or network software (when different computers run the database application and Oracle Database and communicate through a network).

A session represents the state of a current user login to the database instance. For example, when a user starts SQL*Plus, the user must provide a valid username and password, and then a session is established for that user. A session lasts from the time a user connects until the user disconnects or exits the database application. Multiple sessions can be created and exist concurrently for a single Oracle database user using the same username. For example, a user with the username/password of HR/HR can connect to the same Oracle Database instance several times.


Oracle Database Memory Structures

Oracle Database creates and uses memory structures for various purposes. For example, memory stores program code being run, data that is shared among users, and private data areas for each connected user.

Oracle Database Memory Structures

Two basic memory structures are associated with an instance:

  • System Global Area (SGA): Group of shared memory structures, known as SGA components, that contain data and control information for one Oracle Database instance. The SGA is shared by all server and background processes. Examples of data stored in the SGA include cached data blocks and shared SQL areas.
  • Program Global Areas (PGA): Memory regions that contain data and control information for a server or background process. A PGA is nonshared memory created by Oracle Database when a server or background process is started. Access to the PGA is exclusive to the server process. Each server process and background process has its own PGA.

The SGA is the memory area that contains data and control information for the instance. The SGA includes the following data structures:

  • Shared pool: Caches various constructs that can be shared among users
  • Database buffer cache: Caches blocks of data retrieved from the database
  • Redo log buffer: Caches redo information (used for instance recovery) until it can be written to the physical redo log files stored on the disk
  • Large pool: Optional area that provides large memory allocations for certain large processes, such as Oracle backup and recovery operations, and I/O server processes
  • Java pool: Used for all session-specific Java code and data in the Java Virtual Machine (JVM)
  • Streams pool: Used by Oracle Streams to store information required by capture and apply
  • Fixed SGA: An internal housekeeping area containing general information about the state of the database and the instance, and information communicated between processes When you start the instance, the amount of memory allocated for the SGA is displayed.

A Program Global Area (PGA) is a memory region that contains data and control information for each server process. An Oracle server process services a client’s requests. Each server process has its own private PGA that is allocated when the server process is started. Access to the PGA is exclusive to that server process, and the PGA is read and written only by the Oracle code acting on its behalf. The PGA is divided into two major areas: stack space and the user global area (UGA).

With the dynamic SGA infrastructure, the sizes of the database buffer cache, the shared pool, the large pool, the Java pool, and the Streams pool can change without shutting down the instance.

The Oracle Database server uses initialization parameters to create and manage memory structures. The simplest way to manage memory is to allow the database to automatically manage and tune it for you. To do so (on most platforms), you only have to set a target memory size initialization parameter (MEMORY_TARGET) and a maximum memory size initialization parameter (MEMORY_MAX_TARGET).

Process Architecture

The processes in an Oracle Database system can be divided into three major groups:

  • User processes that run the application or Oracle tool code
  • Oracle Database processes that run the Oracle Database server code (including server processes and background processes)
  • Oracle daemons and application processes not specific to a single database

When a user runs an application program or an Oracle tool such as SQL*Plus, the term user process is used to refer to the user’s application. The user process may or may not be on the database server machine. Oracle Database also creates a server process to execute the commands issued by the user process. In addition, the Oracle server also has a set of background processes for an instance that interact with each other and with the operating system to manage the memory structures, asynchronously perform I/O to write data to disk, and perform other required tasks. The process structure varies for different Oracle Database configurations, depending on the operating system and the choice of Oracle Database options. The code for connected users can be configured as a dedicated server or a shared server.

Dedicated server

For each session, the database application is run by a user process that is served by a dedicated server process that executes Oracle database server code.

Shared server

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. A shared server process serves any client request.

Process Structures


process structures oracle database basics

Server Processes

Oracle Database creates server processes to handle the requests of user processes connected to the instance. The user process represents the application or tool that connects to the Oracle database. It may be on the same machine as the Oracle database, or it may exist on a remote client and use a network to reach the Oracle database. The user process first communicates with a listener process that creates a server process in a dedicated environment.

Server processes created on behalf of each user’s application can perform one or more of the following:

  • Parse and run SQL statements issued through the application.
  • Read necessary data blocks from data files on disk into the shared database buffers of the SGA (if the blocks are not already present in the SGA).
  • Return results in such a way that the application can process the information.

Background Processes

To maximize performance and accommodate many users, a multiprocess Oracle Database system uses some additional Oracle Database processes called background processes. An Oracle Database instance can have many background processes.

The background processes commonly seen in non-RAC, non-ASM environments can include the following:

  • Database Writer process (DBWn)
  • Log Writer process (LGWR)
  • Checkpoint process (CKPT)
  • System monitor process (SMON)
  • Process monitor process (PMON)
  • Recoverer process (RECO)
  • Listener registration process (LREG)
  • Manageability monitor process (MMON)
  • Manageability monitor lite process (MMNL)
  • Job queue coordinator (CJQ0)
  • Job slave processes (Jnnn)
  • Archiver processes (ARCn)
  • Queue monitor processes (QMNn)
  • The process spawner process (PSP0)

Other background processes may be found in more advanced configurations such as RAC. See the V$BGPROCESS view for more information about background processes. Some background processes are created automatically when an instance is started, whereas others are started as required. Other process structures are not specific to a single database, but rather can be shared among many databases on the same server. The Grid Infrastructure and networking processes fall into this category.


Comments

Popular posts from this blog

Advantages and Disadvantages of React Native

Azure DevOps vs GitHub