PostgreSQL的postmaser的fork的学习体会
生活随笔
收集整理的這篇文章主要介紹了
PostgreSQL的postmaser的fork的学习体会
小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.
可以說,postmaster是PostgreSQL服務(wù)器端的總代理了。
通過它,把客戶端的請求轉(zhuǎn)給新生成的postgres 進(jìn)程。
postmaster.c 的代碼注釋中有如下的描述:
When a request message is received, we now fork() immediately.The child process performs authentication of the request, and then becomes a backend if successful.This allows the auth code to be written in a simple single-threaded style (as opposed to the crufty "poor man's multitasking" code that used to be needed). More importantly, it ensures that blockages in non-multithreaded libraries like SSL or PAM cannot cause denial of service to other clients.這個(gè)fork的方式是,只要有請求進(jìn)來了,就fork一個(gè)進(jìn)程。
然后,認(rèn)證什么的都有這個(gè)進(jìn)程自己來搞定。然后提出請求的客戶端和這個(gè)postgres進(jìn)程之間,該干嘛就干嘛。
每一對(duì) 客戶端/postgres進(jìn)程 和其他的 客戶端/postgres進(jìn)程之間互不干擾。
想想看,這么做確實(shí)有它的好處:
認(rèn)證部分的代碼可以盡量簡化,不需要考慮鎖定機(jī)制什么的。處理效率比較高,也沒有排隊(duì)什么的。
另外,如果一個(gè)postgres進(jìn)程崩潰了,也不會(huì)影響另一個(gè)。
本文轉(zhuǎn)自健哥的數(shù)據(jù)花園博客園博客,原文鏈接:http://www.cnblogs.com/gaojian/archive/2012/07/19/2599235.html,如需轉(zhuǎn)載請自行聯(lián)系原作者
總結(jié)
以上是生活随笔為你收集整理的PostgreSQL的postmaser的fork的学习体会的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: Gartner:人工智能将把部分专业工作
- 下一篇: windows安装mysql5.7