pbootcms网站模板|日韩1区2区|织梦模板||网站源码|日韩1区2区|jquery建站特效-html5模板网

  • <i id='wKI5Z'><tr id='wKI5Z'><dt id='wKI5Z'><q id='wKI5Z'><span id='wKI5Z'><b id='wKI5Z'><form id='wKI5Z'><ins id='wKI5Z'></ins><ul id='wKI5Z'></ul><sub id='wKI5Z'></sub></form><legend id='wKI5Z'></legend><bdo id='wKI5Z'><pre id='wKI5Z'><center id='wKI5Z'></center></pre></bdo></b><th id='wKI5Z'></th></span></q></dt></tr></i><div class="vs9jx00" id='wKI5Z'><tfoot id='wKI5Z'></tfoot><dl id='wKI5Z'><fieldset id='wKI5Z'></fieldset></dl></div>
  • <tfoot id='wKI5Z'></tfoot>

      <legend id='wKI5Z'><style id='wKI5Z'><dir id='wKI5Z'><q id='wKI5Z'></q></dir></style></legend>

      <small id='wKI5Z'></small><noframes id='wKI5Z'>

          <bdo id='wKI5Z'></bdo><ul id='wKI5Z'></ul>

      1. 完全理解 PDO ATTR_PERSISTENT

        Fully Understanding PDO ATTR_PERSISTENT(完全理解 PDO ATTR_PERSISTENT)

        <small id='z9rg1'></small><noframes id='z9rg1'>

              <tbody id='z9rg1'></tbody>

                <bdo id='z9rg1'></bdo><ul id='z9rg1'></ul>

                <legend id='z9rg1'><style id='z9rg1'><dir id='z9rg1'><q id='z9rg1'></q></dir></style></legend>

                <i id='z9rg1'><tr id='z9rg1'><dt id='z9rg1'><q id='z9rg1'><span id='z9rg1'><b id='z9rg1'><form id='z9rg1'><ins id='z9rg1'></ins><ul id='z9rg1'></ul><sub id='z9rg1'></sub></form><legend id='z9rg1'></legend><bdo id='z9rg1'><pre id='z9rg1'><center id='z9rg1'></center></pre></bdo></b><th id='z9rg1'></th></span></q></dt></tr></i><div class="jfqewnf" id='z9rg1'><tfoot id='z9rg1'></tfoot><dl id='z9rg1'><fieldset id='z9rg1'></fieldset></dl></div>
                • <tfoot id='z9rg1'></tfoot>
                • 本文介紹了完全理解 PDO ATTR_PERSISTENT的處理方法,對(duì)大家解決問(wèn)題具有一定的參考價(jià)值,需要的朋友們下面隨著小編來(lái)一起學(xué)習(xí)吧!

                  問(wèn)題描述

                  使用 PDO 時(shí)持久連接管理背后的規(guī)則/邏輯是什么?

                  What are the rules/logic behind persistent connection management when using PDO?

                  網(wǎng)絡(luò)服務(wù)器

                  • Windows 7 x64
                  • 雙核,16GB RAM
                  • Apache 2.2.17
                  • PHP 5.3.5
                  • 通過(guò)帶有 IP 地址、端口、服務(wù)名稱等的 DSN 字符串連接...
                  • 沒(méi)有用于 DB conn 的 ODBC(現(xiàn)在已經(jīng)嘗試創(chuàng)建一個(gè) 2 小時(shí)了,感謝 Oracle!)

                  數(shù)據(jù)庫(kù)服務(wù)器

                  • Linux 上的 Oracle 10g
                  • 具有 4GB RAM 的多核
                  • 專門為我的網(wǎng)絡(luò)應(yīng)用創(chuàng)建的用戶名(是的,它是假的)
                    • 用戶:網(wǎng)絡(luò)用戶

                    非持久連接

                    <?php
                    
                    // Open a new connection
                    // Session created in Oracle
                    $dbh = new PDO('DSN', 'webuser', 'password');
                    
                    // webuser is active in v$session with a SID=1
                    
                    $dbh = NULL;
                    
                    // webuser removed from v$session
                    
                    // Manually calling $dbh = NULL; will remove the session from v$session
                    // OR
                    // Wait for script EOL so a kill-session command is sent to Oracle?
                    
                    ?>
                    

                    • 腳本可靠地執(zhí)行大約需要大約 0.09 秒,框架開(kāi)銷等...
                    • 持久連接

                      <?php
                      
                      // Open a new connection and make it persistent
                      // Session created in Oracle
                      // Is Apache maintaining some sort of keep-alive with Oracle here?
                      // because I thought php.exe is only alive for the duration of the script
                      $dbh = new PDO('DSN', 'webuser', 'password', array(PDO::ATTR_PERSISTENT => TRUE));
                      
                      // webuser is active in v$session with a SID=1
                      
                      $dbh = NULL;
                      
                      // webuser is still active in v$session with a SID=1
                      
                      $dbh = new PDO('DSN', 'webuser', 'password', array(PDO::ATTR_PERSISTENT => TRUE));
                      
                      // webuser is still active in v$session with a SID=1
                      
                      // Manually calling $dbh = NULL; does not kill session
                      // OR
                      // Script EOL does not kill session
                      // ^^ this is good, just as expected
                      
                      ?>
                      

                      • 腳本在初次訪問(wèn)時(shí)需要約 .12 秒來(lái)執(zhí)行,并帶有框架開(kāi)銷等......
                      • 后續(xù)執(zhí)行 take ~.04
                      • 我訪問(wèn)該頁(yè)面,webuser 得到一個(gè) SID=1

                        I visit the page and webuser gets a SID=1

                        我的同事訪問(wèn)了該頁(yè)面,webuser 獲得了一個(gè)額外的 SID=2 <- 為訪問(wèn)此頁(yè)面的新計(jì)算機(jī)沖洗、重復(fù)和增加 SID

                        My colleague visits the page and webuser gets an additional SID=2 <- rinse, repeat, and increment SID for new computers visiting this page

                        新訪問(wèn)者不應(yīng)該重復(fù)使用 SID=1 嗎?

                        Shouldn't a new visitor be re-using SID=1?

                        歡迎所有答案、建議、替代測(cè)試請(qǐng)求、閱讀材料鏈接.

                        All answers, suggestions, requests for alternate testing, links to reading material are welcomed.

                        我已經(jīng)使用 RTFM 一段時(shí)間了,而谷歌搜索只產(chǎn)生了微薄的持久性與非持久性的優(yōu)勢(shì)博客.

                        I have RTFM'ed for a while and Googling has only produced meager Advantages of Persistent vs. Non-persistent blogs.

                        推薦答案

                        Apaches 的觀點(diǎn)

                        Apache 有一個(gè)父進(jìn)程.此進(jìn)程創(chuàng)建子進(jìn)程來(lái)處理傳入 Web 服務(wù)器的任何請(qǐng)求.Web 服務(wù)器啟動(dòng)時(shí)啟動(dòng)的初始子進(jìn)程數(shù)量由 apache 配置中的 StartServers 指令配置.這個(gè)數(shù)字會(huì)隨著訪問(wèn) Web 服務(wù)器的請(qǐng)求數(shù)量的增加而增加,直到達(dá)到 ServerLimit.

                        Apaches point of view

                        Apache has one parent process. This process creates child processes that will handle any requests coming to the web server. The initial amount of child processes being started when the web server starts is configured by the StartServers directive in the apache configuration. The number goes up as needed with a raising amount of requests hitting the web server until ServerLimit is reached.

                        如果 PHP(作為 mod_php 運(yùn)行,作為 CGI 在腳本執(zhí)行結(jié)束時(shí)所有資源都被釋放)現(xiàn)在被告知為請(qǐng)求建立與數(shù)據(jù)庫(kù)的持久連接,即使在腳本完成后,該連接也會(huì)保持.現(xiàn)在保持的連接是處理請(qǐng)求的 apache 子進(jìn)程和數(shù)據(jù)庫(kù)服務(wù)器之間的連接,并且可以被這個(gè)確切的子進(jìn)程正在處理的任何請(qǐng)求重用.

                        If PHP (ran as mod_php, as CGI all resources are freed at the end of script execution) is now being told to establish a persistent connection with a database for a request, this connection is hold even after the script finishes. The connection being now hold is a connection between the apache child process which the request was handled by and the database server and can be re-used by any request that is being handled by this exact child process.

                        如果由于某種原因(不要問(wèn)我確切的原因),子進(jìn)程被占用的時(shí)間比實(shí)際請(qǐng)求的時(shí)間長(zhǎng)并且另一個(gè)請(qǐng)求進(jìn)來(lái),父 apache 進(jìn)程將此請(qǐng)求重定向到一個(gè)(新)子進(jìn)程,這可能到目前為止還沒(méi)有建立到數(shù)據(jù)庫(kù)的連接.如果在腳本執(zhí)行期間必須這樣做,它會(huì)像您觀察到的那樣引發(fā) SID.現(xiàn)在有兩個(gè)連接被apache的兩個(gè)不同的子進(jìn)程持有.

                        If, for some reason (do not ask me exactly why), the child process is being occupied longer than the actual request and another request comes in, the parent apache process redirects this request to a (new) child process which may has not established a connection to the database up to this time. If it has to during the execution of the script, it raises the SID as you have observed. Now there are two connections be hold by two different child processes of apache.

                        重要的是要知道,這也會(huì)引起很多麻煩.如果在腳本執(zhí)行過(guò)程中出現(xiàn)死循環(huán)或中止事務(wù)或其他一些甚至不可預(yù)測(cè)的錯(cuò)誤,連接將被阻塞且無(wú)法重用.也可能發(fā)生數(shù)據(jù)庫(kù)的所有可用連接都被使用,但 apache 服務(wù)器的另一個(gè)子進(jìn)程試圖訪問(wèn)數(shù)據(jù)庫(kù).該進(jìn)程暫時(shí)被阻止,直到數(shù)據(jù)庫(kù)或 apache 釋放連接(超時(shí)或自愿終止).此頁(yè)面上有關(guān)此主題的任何進(jìn)一步信息:http://www.php.net/manual/en/features.persistent-connections.php

                        It is important to know, that this can also cause a lot of trouble. If there is an endless loop or an aborted transaction or some other may be even unpredictable error during the script execution, the connection is blocked and can not be re-used. Also it could happen that all of the available connections of the database are used, but there is another child process of the apache server trying to access the database. This process is blocked for the time being until a connection is freed by the database or apache (timeout or voluntarily by termination). Any further information about this topic on this page: http://www.php.net/manual/en/features.persistent-connections.php

                        我希望我能正確總結(jié)我們?cè)谠u(píng)論對(duì)話中討論的所有內(nèi)容,并且沒(méi)有忘記任何事情.如果是這樣,請(qǐng)給我一個(gè)提示,我會(huì)添加它.:)

                        I hope I got all that we have discussed in our comment conversation summarized correctly and did not forget anything. If so, please, leave me a hint and I will add it. :)

                        我剛剛讀完了這篇評(píng)論.它描述了我在上面總結(jié)的過(guò)程,并提供了有關(guān)如何優(yōu)化 apache 服務(wù)器以更好地與持久連接一起工作的有用信息.不過(guò),它可以在有或沒(méi)有 oracle 數(shù)據(jù)庫(kù)后端的情況下使用.你應(yīng)該看看:http://www.oracle.com/technetwork/articles/coggeshall-persist-084844.html

                        I just finished reading the article @MonkeyZeus mentioned in this comment. It describes the process I summarized above and provides useful information on how to optimize your apache server to work better together with persistent connections. It can be used with or without oracle database backends, though. You should give a look: http://www.oracle.com/technetwork/articles/coggeshall-persist-084844.html

                        這篇關(guān)于完全理解 PDO ATTR_PERSISTENT的文章就介紹到這了,希望我們推薦的答案對(duì)大家有所幫助,也希望大家多多支持html5模板網(wǎng)!

                        【網(wǎng)站聲明】本站部分內(nèi)容來(lái)源于互聯(lián)網(wǎng),旨在幫助大家更快的解決問(wèn)題,如果有圖片或者內(nèi)容侵犯了您的權(quán)益,請(qǐng)聯(lián)系我們刪除處理,感謝您的支持!

                  相關(guān)文檔推薦

                  Deadlock exception code for PHP, MySQL PDOException?(PHP、MySQL PDOException 的死鎖異常代碼?)
                  PHP PDO MySQL scrollable cursor doesn#39;t work(PHP PDO MySQL 可滾動(dòng)游標(biāo)不起作用)
                  PHP PDO ODBC connection(PHP PDO ODBC 連接)
                  Using PDO::FETCH_CLASS with Magic Methods(使用 PDO::FETCH_CLASS 和魔術(shù)方法)
                  php pdo get only one value from mysql; value that equals to variable(php pdo 只從 mysql 獲取一個(gè)值;等于變量的值)
                  MSSQL PDO could not find driver(MSSQL PDO 找不到驅(qū)動(dòng)程序)
                  • <bdo id='xbLm2'></bdo><ul id='xbLm2'></ul>

                    1. <legend id='xbLm2'><style id='xbLm2'><dir id='xbLm2'><q id='xbLm2'></q></dir></style></legend><tfoot id='xbLm2'></tfoot>

                      1. <small id='xbLm2'></small><noframes id='xbLm2'>

                          <tbody id='xbLm2'></tbody>

                      2. <i id='xbLm2'><tr id='xbLm2'><dt id='xbLm2'><q id='xbLm2'><span id='xbLm2'><b id='xbLm2'><form id='xbLm2'><ins id='xbLm2'></ins><ul id='xbLm2'></ul><sub id='xbLm2'></sub></form><legend id='xbLm2'></legend><bdo id='xbLm2'><pre id='xbLm2'><center id='xbLm2'></center></pre></bdo></b><th id='xbLm2'></th></span></q></dt></tr></i><div class="fr05ba5" id='xbLm2'><tfoot id='xbLm2'></tfoot><dl id='xbLm2'><fieldset id='xbLm2'></fieldset></dl></div>

                          • 主站蜘蛛池模板: 贴片电感_贴片功率电感_贴片绕线电感_深圳市百斯特电子有限公司 贴片电容代理-三星电容-村田电容-风华电容-国巨电容-深圳市昂洋科技有限公司 | 盘扣式脚手架-附着式升降脚手架-移动脚手架,专ye承包服务商 - 苏州安踏脚手架工程有限公司 | 国标白水泥,高标号白水泥,白水泥厂家-淄博华雪建材有限公司 | 洗石机-移动滚筒式,振动,螺旋,洗矿机-青州冠诚重工机械有限公司 | 幂简集成 - 品种超全的API接口平台, 一站搜索、试用、集成国内外API接口 | 工业铝型材-铝合金电机壳-铝排-气动执行器-山东永恒能源集团有限公司 | 散热器厂家_暖气片_米德尔顿散热器| 深圳办公室装修,办公楼/写字楼装修设计,一级资质 - ADD写艺 | 河北凯普威医疗器材有限公司,高档轮椅系列,推车系列,座厕椅系列,协步椅系列,拐扙系列,卫浴系列 | 彩超机-黑白B超机-便携兽用B超机-多普勒彩超机价格「大为彩超」厂家 | 柴油机_柴油发电机_厂家_品牌-江苏卡得城仕发动机有限公司 | 变色龙云 - 打包app_原生app_在线制作平台_短链接_ip查询 | 铆钉机|旋铆机|东莞旋铆机厂家|鸿佰专业生产气压/油压/自动铆钉机 | 电子万能试验机_液压拉力试验机_冲击疲劳试验机_材料试验机厂家-济南众标仪器设备有限公司 | 点胶机_点胶阀_自动点胶机_智能点胶机_喷胶机_点胶机厂家【欧力克斯】 | 活性氧化铝|无烟煤滤料|活性氧化铝厂家|锰砂滤料厂家-河南新泰净水材料有限公司 | 猎头招聘_深圳猎头公司_知名猎头公司| 双工位钻铣攻牙机-转换工作台钻攻中心-钻铣攻牙机一体机-浙江利硕自动化设备有限公司 | 升降机-高空作业车租赁-蜘蛛车-曲臂式伸缩臂剪叉式液压升降平台-脚手架-【普雷斯特公司厂家】 | 重庆磨床过滤机,重庆纸带过滤机,机床伸缩钣金,重庆机床钣金护罩-重庆达鸿兴精密机械制造有限公司 | 上海办公室装修,写字楼装修—启鸣装饰设计工程有限公司 | 合肥仿石砖_合肥pc砖厂家_合肥PC仿石砖_安徽旭坤建材有限公司 | 恒压供水控制柜|无负压|一体化泵站控制柜|PLC远程调试|MCGS触摸屏|自动控制方案-联致自控设备 | 创富网-B2B网站|供求信息网|b2b平台|专业电子商务网站 | 根系分析仪,大米外观品质检测仪,考种仪,藻类鉴定计数仪,叶面积仪,菌落计数仪,抑菌圈测量仪,抗生素效价测定仪,植物表型仪,冠层分析仪-杭州万深检测仪器网 | 热处理温控箱,热处理控制箱厂家-吴江市兴达电热设备厂 | 识禅_对禅的了解,从这里开始| 上海瑶恒实业有限公司|消防泵泵|离心泵|官网 | 拉力机-万能试验机-材料拉伸试验机-电子拉力机-拉力试验机厂家-冲击试验机-苏州皖仪实验仪器有限公司 | 爆炸冲击传感器-无线遥测传感器-航天星百科 | 尊享蟹太太美味,大闸蟹礼卡|礼券|礼盒在线预订-蟹太太官网 | 超声波清洗机_大型超声波清洗机_工业超声波清洗设备-洁盟清洗设备 | 兰州牛肉面加盟,兰州牛肉拉面加盟-京穆兰牛肉面 | 热镀锌槽钢|角钢|工字钢|圆钢|H型钢|扁钢|花纹板-天津千百顺钢铁贸易有限公司 | PCB厂|线路板厂|深圳线路板厂|软硬结合板厂|电路板生产厂家|线路板|深圳电路板厂家|铝基板厂家|深联电路-专业生产PCB研发制造 | 成都中天自动化控制技术有限公司 | 动库网动库商城-体育用品专卖店:羽毛球,乒乓球拍,网球,户外装备,运动鞋,运动包,运动服饰专卖店-正品运动品网上商城动库商城网 - 动库商城 | 捷码低代码平台 - 3D数字孪生_大数据可视化开发平台「免费体验」 | 滚珠丝杆升降机_螺旋升降机_丝杠升降机-德迈传动 | 台式低速离心机-脱泡离心机-菌种摇床-常州市万丰仪器制造有限公司 | MES系统工业智能终端_生产管理看板/安灯/ESOP/静电监控_讯鹏科技 |