Definition of Daemon Process
What is a Process? Background, Foreground #
To understand daemons, let's first look at processes.
A process refers to a computer program that is running continuously. Processes can be divided into foreground processes and background processes.
Looking at each, a foreground process refers to visible programs such as internet browsers, IntelliJ, KakaoTalk, etc. In contrast, a background process refers to invisible programs like antivirus software or graphics drivers.
Furthermore, foreground processes use standard input/output devices that can interact with the user, such as a terminal and keyboard (tty or pts). However, background processes do not receive input from the user via any device; instead, they operate autonomously.
What is a Daemon? #
A daemon refers to a process that automatically starts up during boot in Unix operating systems and continues to run in the background.
- As implied by the phrase 'a process that continuously runs in the background,' a daemon falls within the category of processes.
- Since daemons belong to background processes, they do not have a TTY (terminal device), similar to other background processes. Additionally, they have the characteristic that their PPID (parent ID) is 1 and their SID (session ID) is the same as their own ID.
- In Unix (including Linux) operating systems, processes whose names end with 'd' can be considered typical daemon processes.
- A web server can also be run via a terminal on the server, but since it doesn't need to interact with the user using tty, pts, etc., it can be seen as a representative daemon process.
The fact that a daemon continuously runs in the background can also be seen as it being on standby, ready to respond immediately when a request comes in.
There are two ways daemons can run: 'Stand alond' and 'Xinetd'.
Stand-alone #
This is a mode where the daemon operates independently, handling requests on its own. Because it resides in memory and is always running, it has a fast response time to requests, making it frequently used for processes with high request volumes. While fast, it's important to note that because it continuously resides in memory and runs, it can impose a load.
Xinetd #
It exists above other daemons and is also called a Super Daemon.
This method involves launching subordinate daemons dependent on itself (xinetd) when a request arrives, although xinetd itself operates in a stand-alone manner. From the perspective of subordinate daemons, the response processing speed is slower compared to the 'Stand alond' method mentioned above. However, it has the advantage of entering a dormant state and not using memory when no requests come in, making it suitable for services with infrequent requests.