<ruby id="bdb3f"></ruby>

    <p id="bdb3f"><cite id="bdb3f"></cite></p>

      <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
        <p id="bdb3f"><cite id="bdb3f"></cite></p>

          <pre id="bdb3f"></pre>
          <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

          <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
          <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

          <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                <ruby id="bdb3f"></ruby>

                企業??AI智能體構建引擎,智能編排和調試,一鍵部署,支持知識庫和私有化部署方案 廣告
                # 提高性能:下一步該做什么?(Increasing Performance: What’s next?) 要開發出高性能的應用程序需要考慮多方面的因素: 服務器, 客戶端, 網絡, 數據庫, web服務器,靜態資源等。 本章中我集中分析在如何提升系統的性能及 如何檢測應用的瓶頸。 ## 關于服務端(Profile on the Server) 每種應用都有不同, 持久的性能分析對找出系統瓶頸是非常必要的。 性能分析可以讓我們更直觀的看出何處為性能瓶頸,何處不是。 性能分析在一個請示中和另一請求中可能表現 不一,所以要做出足夠的分析及權衡方可給出結論。 ### 關于 XDebug(Profiling with XDebug) [Xdebug](http://xdebug.org/docs)提供了簡易的性能測試的方式, 安裝后可在php.ini中 進行如下配置: ~~~ xdebug.profiler_enable = On ~~~ 使用[Webgrind](https://github.com/jokkedk/webgrind/)可以分析出哪些函數或方法比其它的要慢: ![../_images/webgrind.jpg](http://docs.iphalcon.cn/_images/webgrind.jpg) ### 關于 Xhprof(Profiling with Xhprof) [Xhprof](https://github.com/facebook/xhprof)也是一個非常有意思的擴展。 開發者可以添加如下的代碼到啟動文件中: ~~~ <?php xhprof_enable(XHPROF_FLAGS_CPU + XHPROF_FLAGS_MEMORY); ~~~ 然后在啟動文件的結尾保存性能分析數據: ~~~ <?php $xhprof_data = xhprof_disable('/tmp'); $XHPROF_ROOT = "/var/www/xhprof/"; include_once $XHPROF_ROOT . "/xhprof_lib/utils/xhprof_lib.php"; include_once $XHPROF_ROOT . "/xhprof_lib/utils/xhprof_runs.php"; $xhprof_runs = new XHProfRuns_Default(); $run_id = $xhprof_runs->save_run($xhprof_data, "xhprof_testing"); echo "http://localhost/xhprof/xhprof_html/index.php?run={$run_id}&source=xhprof_testing\n"; ~~~ Xhprof 提供了一個內置的HTML視圖用來對性能分析的數據進行展示: ![../_images/xhprof-2.jpg](http://docs.iphalcon.cn/_images/xhprof-2.jpg) ![../_images/xhprof-1.jpg](http://docs.iphalcon.cn/_images/xhprof-1.jpg) ### 關于 SQL 語句(Profiling SQL Statements) 幾乎所有的數據庫系統都提供了相關的工具以找出哪些執行緩慢的SQL語句。 檢測及修復那些執行緩慢的查詢對提高服務器端系統的性能來說是非常重要的。 在Mysql數據庫中, 開發者可以啟用慢查詢日志來記錄執行緩慢的查詢: ~~~ log-slow-queries = /var/log/slow-queries.log long_query_time = 1.5 ~~~ ## 關于客戶端(Profile on the Client) 有時開發者需要提升靜態資源加載的速度, 比如圖片, javascript, CSS等。 下面的工具可以讓開發者從客戶端檢測靜態資源加載的瓶頸: ### (使用Chrome/Firefox進行性能分析)Profile with Chrome/Firefox 幾乎所有的現代瀏覽器都有相應的工具來檢測頁面加載時間。 Chrome中開發者可使用web探察器來獲取一個頁面的所有資源加載所需的時間: ![../_images/chrome-1.jpg](http://docs.iphalcon.cn/_images/chrome-1.jpg) [Firebug](http://getfirebug.com/)提供了類似的功能: ![../_images/firefox-1.jpg](http://docs.iphalcon.cn/_images/firefox-1.jpg) ## Yahoo! YSlow 開發者可以使用[YSlow](http://developer.yahoo.com/yslow/)對網頁進行分析, YSlow給出基于[rules for high performance web pages](http://developer.yahoo.com/performance/rules.html)(高性能網頁規)的建議: ![../_images/yslow-1.jpg](http://docs.iphalcon.cn/_images/yslow-1.jpg) ### 使用Speed Trace進行性能分析(Profile with Speed Tracer) [Speed Tracer](https://developers.google.com/web-toolkit/speedtracer/)這個工具可以幫助開發者找出web應用性能方面的問題。 這個工個從瀏覽器的底層分析出web應用的性能。 Speed Tracer 這個插可以安裝 在Windows或Linux版本的Chrome上。 ![../_images/speed-tracer.jpg](http://docs.iphalcon.cn/_images/speed-tracer.jpg) 這是一個非常有用的工具,它可以為我們顯示出html頁面渲染的時間, Javascript及css執行(渲染)的時間等。 ## 使用最新的 PHP 版本(Use a recent PHP version) PHP本身的執行速度已經越來越快了, 使用最新版本的PHP及Phalcon可以更高的提升web應用的執行速度。 ## 使用 PHP 字節碼緩存(Use a PHP Bytecode Cache) [APC](http://php.net/manual/en/book.apc.php)像其它的字節碼緩存工具一樣可以幫助web應用程序減少讀取及解析php文件解析所花的時間。 安裝完APC之后在php.ini中添加如何配置: ~~~ apc.enabled = On ~~~ PHP5.5中包含了一個內置的字節碼緩存器,即 ZendOptimizer+, 這個擴展在5.3及5.4版本的php中也存在,只不過不是內置的而是用擴展的形式存在的。 ## 將可能發生阻塞的操作放到后臺運行(Do blocking work in the background) 處理視頻, 發送e-mail, 壓縮文件和圖片等是非常耗時的, 這些最好放在后臺執行。 開發者可以使用隊列及消息系統以提高web應用的性能,可使用如下組件: * [Beanstalkd](http://kr.github.io/beanstalkd/) * [Redis](http://redis.io/) * [RabbitMQ](http://www.rabbitmq.com/) * [Resque](https://github.com/chrisboulton/php-resque) * [Gearman](http://gearman.org/) * [ZeroMQ](http://www.zeromq.org/) ## Google Page Speed [mod\_pagespeed](https://developers.google.com/speed/pagespeed/mod)可以加速網站的運行速度及減少網站的加載時間。 這個開源的apache web服務器模塊(nginx下為[ngx\_pagespeed](https://developers.google.com/speed/pagespeed/ngx))會 自動對網頁,靜態資源(CSS, JavaScript, images)等進行性能相關的優化,而無需開發者修改已存在的代碼,內容,及工作流等。 注: 更多的性能相關的配置或建議可以查看具體的web服務器, 如apache中提供了mod\_cache, mod\_disk\_cache等.
                  <ruby id="bdb3f"></ruby>

                  <p id="bdb3f"><cite id="bdb3f"></cite></p>

                    <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
                      <p id="bdb3f"><cite id="bdb3f"></cite></p>

                        <pre id="bdb3f"></pre>
                        <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

                        <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
                        <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

                        <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                              <ruby id="bdb3f"></ruby>

                              哎呀哎呀视频在线观看