PostgreSQL的postmaser的fork的学习体会
生活随笔
收集整理的這篇文章主要介紹了
PostgreSQL的postmaser的fork的学习体会
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
可以說,postmaster是PostgreSQL服務器端的總代理了。
通過它,把客戶端的請求轉給新生成的postgres 進程。
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.這個fork的方式是,只要有請求進來了,就fork一個進程。
然后,認證什么的都有這個進程自己來搞定。然后提出請求的客戶端和這個postgres進程之間,該干嘛就干嘛。
每一對 客戶端/postgres進程 和其他的 客戶端/postgres進程之間互不干擾。
想想看,這么做確實有它的好處:
認證部分的代碼可以盡量簡化,不需要考慮鎖定機制什么的。處理效率比較高,也沒有排隊什么的。
另外,如果一個postgres進程崩潰了,也不會影響另一個。
本文轉自健哥的數據花園博客園博客,原文鏈接:http://www.cnblogs.com/gaojian/archive/2012/07/19/2599235.html,如需轉載請自行聯系原作者
總結
以上是生活随笔為你收集整理的PostgreSQL的postmaser的fork的学习体会的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: Gartner:人工智能将把部分专业工作
- 下一篇: AE 中的查找与定位,以城市查找为例