12
返回列表 发新帖
楼主: myownstars

[讨论] 为何listener要fork两次子进程

[复制链接]
论坛徽章:
4
鲜花蛋
日期:2011-07-21 16:06:54双黄蛋
日期:2011-09-02 20:36:17ITPUB十周年纪念徽章
日期:2011-11-01 16:26:29奥运会纪念徽章:射箭
日期:2012-07-26 19:04:19
11#
发表于 2013-6-30 16:57 | 只看该作者
wolfop 发表于 2013-6-30 16:13
互联网行业肯定要靠中间件实现连接池的。就算informix支撑互联网应用如果不用连接池也会挂,不过是相对可 ...

1、中间件做流量控制主要是企业应用里的概念,互联网行业相对很少见(我没见到,我特意咨询了下以前的同事求证,也是没有的)。
2、informix来支撑互联网的大并发,无论从技术还是市场来看,基本上都只是个梦想。
3、我以前做的一些不成熟的思考可以参考下
自己写cache server之网络框架处理——对比mysql、Oracle(上)
自己写cache server之网络框架处理——Oracle、Mysql都不靠谱儿(中)

使用道具 举报

回复
论坛徽章:
78
ITPUB15周年纪念
日期:2020-08-28 17:23:53双鱼座
日期:2016-03-19 19:38:31秀才
日期:2016-02-18 09:31:52秀才
日期:2016-01-25 15:02:04双子座
日期:2016-01-19 20:35:54秀才
日期:2016-01-13 12:14:26秀才
日期:2015-12-25 15:31:10秀才
日期:2015-12-18 09:28:57秀才
日期:2015-12-14 14:56:09秀才
日期:2015-12-14 14:51:16
12#
发表于 2013-7-1 22:22 | 只看该作者
freas 发表于 2013-6-30 16:57
1、中间件做流量控制主要是企业应用里的概念,互联网行业相对很少见(我没见到,我特意咨询了下以前的同事 ...

Paypal,支付宝。

使用道具 举报

回复
论坛徽章:
4
鲜花蛋
日期:2011-07-21 16:06:54双黄蛋
日期:2011-09-02 20:36:17ITPUB十周年纪念徽章
日期:2011-11-01 16:26:29奥运会纪念徽章:射箭
日期:2012-07-26 19:04:19
13#
发表于 2013-7-1 22:45 | 只看该作者
wolfop 发表于 2013-7-1 22:22
Paypal,支付宝。

支付属于金融行业,业务类型和典型互联网业务差距比较大。嘎嘎

使用道具 举报

回复
论坛徽章:
47
蒙奇·D·路飞
日期:2017-03-27 08:04:23马上有车
日期:2014-02-18 16:41:112014年新春福章
日期:2014-02-18 16:41:11一汽
日期:2013-09-01 20:46:27复活蛋
日期:2013-03-13 07:55:232013年新春福章
日期:2013-02-25 14:51:24ITPUB 11周年纪念徽章
日期:2012-10-09 18:03:322012新春纪念徽章
日期:2012-02-13 15:13:202012新春纪念徽章
日期:2012-02-13 15:13:202012新春纪念徽章
日期:2012-02-13 15:13:20
14#
发表于 2013-7-3 04:44 | 只看该作者
Beginning with 12c, you can set the DB parameter threaded_execution to true and listener parameter dedicated_through_broker to on to allow Oracle to spawn threads in an existing server process instead of spawning separate processes. I didn't test. But I think the overhead of spawning a full-fledged process is largely eliminated.

Related documentation:
http://docs.oracle.com/cd/E16655 ... 7615/refrn10335.htm
http://docs.oracle.com/cd/E16655 ... /process.htm#i16690

使用道具 举报

回复
论坛徽章:
4
鲜花蛋
日期:2011-07-21 16:06:54双黄蛋
日期:2011-09-02 20:36:17ITPUB十周年纪念徽章
日期:2011-11-01 16:26:29奥运会纪念徽章:射箭
日期:2012-07-26 19:04:19
15#
发表于 2013-7-3 09:43 | 只看该作者
Yong Huang 发表于 2013-7-3 04:44
Beginning with 12c, you can set the DB parameter threaded_execution to true and listener parameter d ...

12c才出来几天就搞得这么熟,版主威武。Oracle在网络处理上动了大手术,这样的革新让人兴奋。就是不知道会不会带来很多这方面的bug。

使用道具 举报

回复
论坛徽章:
47
蒙奇·D·路飞
日期:2017-03-27 08:04:23马上有车
日期:2014-02-18 16:41:112014年新春福章
日期:2014-02-18 16:41:11一汽
日期:2013-09-01 20:46:27复活蛋
日期:2013-03-13 07:55:232013年新春福章
日期:2013-02-25 14:51:24ITPUB 11周年纪念徽章
日期:2012-10-09 18:03:322012新春纪念徽章
日期:2012-02-13 15:13:202012新春纪念徽章
日期:2012-02-13 15:13:202012新春纪念徽章
日期:2012-02-13 15:13:20
16#
发表于 2013-7-9 05:11 | 只看该作者
本帖最后由 Yong Huang 于 2013-7-8 15:17 编辑

In threaded execution mode (see msg #14 to enable), the number of Oracle processes is drastically reduced:

[oracle@dcdrpcora1a admin]$ ps -fu oracle
UID        PID  PPID  C STIME TTY          TIME CMD
...[a few bash shell processes]...
oracle   12630     1  0 15:45 ?        00:00:00 /u01/app/oracle/product/12.1.0/db/bin/tnslsnr LISTENER -inherit
oracle   15457     1  0 15:47 ?        00:00:00 ora_pmon_test12c
oracle   15459     1  0 15:47 ?        00:00:00 ora_psp0_test12c
oracle   15461     1  0 15:47 ?        00:00:00 ora_vktm_test12c
oracle   15465     1  0 15:47 ?        00:00:03 ora_u004_test12c
oracle   15472     1  5 15:47 ?        00:00:26 ora_u005_test12c
oracle   15478     1  0 15:47 ?        00:00:00 ora_dbw0_test12c

All except the two ora_u* processes are just like in process (non-threaded) execution. The two ora_u* processes each contain multiple threads:

$ ps -fLp 15472
UID        PID  PPID   LWP  C NLWP STIME TTY          TIME CMD
oracle   15472     1 15472  0   40 15:47 ?        00:00:00 ora_u005_test12c
oracle   15472     1 15473  0   40 15:47 ?        00:00:00 ora_u005_test12c
...

Each thread has a specific function:

SQL> select stid, pname, program from v$process where spid = 15472 order by 1;

STID  PNAME PROGRAM
----- ----- ---------------------------------------------
15472 SCMN  oracle@dcdrpcora1a (SCMN)
15474 DIAG  oracle@dcdrpcora1a (DIAG)
15476 DIA0  oracle@dcdrpcora1a (DIA0)
15484 RECO  oracle@dcdrpcora1a (RECO)
15486 MMON  oracle@dcdrpcora1a (MMON)
15487 MMNL  oracle@dcdrpcora1a (MMNL)
...
15712 Q002  oracle@dcdrpcora1a (Q002)
15713 Q003  oracle@dcdrpcora1a (Q003)
21258       oracle@dcdrpcora1a  <-- server thread for my sqlplus connection, no PNAME
29468 W001  oracle@dcdrpcora1a (W001)

SQL> select stid, pname, program from v$process where spid = 15465 order by 1;

STID  PNAME PROGRAM
----- ----- ---------------------------------------------
15465 SCMN  oracle@dcdrpcora1a (SCMN)
15468 GEN0  oracle@dcdrpcora1a (GEN0)
15469 MMAN  oracle@dcdrpcora1a (MMAN)
15475 DBRM  oracle@dcdrpcora1a (DBRM)
15479 LGWR  oracle@dcdrpcora1a (LGWR)
15480 CKPT  oracle@dcdrpcora1a (CKPT)
15481 LG00  oracle@dcdrpcora1a (LG00)
15482 LG01  oracle@dcdrpcora1a (LG01)
15483 SMON  oracle@dcdrpcora1a (SMON)
15485 LREG  oracle@dcdrpcora1a (LREG)

As you can see, the latter one is very critical, as it contains LGWR, CKPT, etc. On Linux/UNIX, you can check a background process environment variable SKGP_HIDDEN_ARGS to see if it's fatal or non-fatal (previously just called background).

$ ps eww 15465
  PID TTY      STAT   TIME COMMAND
15465 ?        Ssl    0:03 ora_u004_test12c... SKGP_HIDDEN_ARGS=<FATAL/...

$ ps eww 15472
...SKGP_HIDDEN_ARGS=<NF/...

If it's fatal, killing the process would crash the instance. It's a quick way to find out whether you can release memory by killing a process. (Of course the real solution is elsewhere, fixing a bug for memory leak, e.g.)

使用道具 举报

回复
论坛徽章:
33
奥运会纪念徽章:自行车
日期:2012-10-29 10:38:502014年新春福章
日期:2014-02-18 16:49:31马上有钱
日期:2014-02-18 16:49:312014年世界杯参赛球队: 瑞士
日期:2014-06-23 14:15:52青年奥林匹克运动会-竞技体操
日期:2014-08-26 12:34:02马上加薪
日期:2015-01-04 22:33:19马上加薪
日期:2015-01-07 12:12:23马上有钱
日期:2015-02-06 10:13:47马上有房
日期:2015-02-06 23:07:11懒羊羊
日期:2015-02-12 11:01:13
17#
发表于 2018-10-18 22:55 | 只看该作者
本帖最后由 zhu_henry 于 2018-10-18 23:01 编辑

最近在研究C语言,看到这个帖子,感觉回答的不靠谱啊!特意登上来回复下我的研究结论:

1.listener只fork一个进程,这个进程调exec成为serverprocess
2.listener fork一个子进程,子进程再fork一个孙进程,孙进程调用exec成为serverprocess

1的局限性:listener进程fork子进程后如果不调wait,子进程终止后将成为僵尸进程,严重浪费系统资源;如果listener调用wait势必被阻塞,在子进程退出前,无法响应其它连接请求
2的优势:listener fork子进程,子进程fork孙进程后立马退出,这时候子进程变成僵尸进程,等listener调用Wait后正常退出由于子进程已经退出变僵尸进程listener进程调用Wait处理不会被阻塞,可以立即响应其它连接请求,孙进程也可以自行终止被init回收不会变为僵尸进程浪费系统资源

几行C代码就能验证的事。

使用道具 举报

回复
论坛徽章:
47
蒙奇·D·路飞
日期:2017-03-27 08:04:23马上有车
日期:2014-02-18 16:41:112014年新春福章
日期:2014-02-18 16:41:11一汽
日期:2013-09-01 20:46:27复活蛋
日期:2013-03-13 07:55:232013年新春福章
日期:2013-02-25 14:51:24ITPUB 11周年纪念徽章
日期:2012-10-09 18:03:322012新春纪念徽章
日期:2012-02-13 15:13:202012新春纪念徽章
日期:2012-02-13 15:13:202012新春纪念徽章
日期:2012-02-13 15:13:20
18#
发表于 2018-10-19 23:41 | 只看该作者
本帖最后由 Yong Huang 于 2018-10-19 09:56 编辑

> 子进程终止后将成为僵尸进程,严重浪费系统资源

This statement is a little exageration. Defunct or zombie processes do not consume resources, except for occupying process slots. They don't use CPU or memory.

Everything else you said is fine.

使用道具 举报

回复

您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

TOP技术积分榜 社区积分榜 徽章 团队 统计 知识索引树 积分竞拍 文本模式 帮助
  ITPUB首页 | ITPUB论坛 | 数据库技术 | 企业信息化 | 开发技术 | 微软技术 | 软件工程与项目管理 | IBM技术园地 | 行业纵向讨论 | IT招聘 | IT文档
  ChinaUnix | ChinaUnix博客 | ChinaUnix论坛
CopyRight 1999-2011 itpub.net All Right Reserved. 北京盛拓优讯信息技术有限公司版权所有 联系我们 未成年人举报专区 
京ICP备16024965号-8  北京市公安局海淀分局网监中心备案编号:11010802021510 广播电视节目制作经营许可证:编号(京)字第1149号
  
快速回复 返回顶部 返回列表