2013-12-13 82 views
5

讓說我使用的PHP 5.5的操作碼緩存,並設置每個php-fpm池都有自己的內存池嗎?

opcache.memory_consumption=128

,如果我有在PHP-FPM 4個游泳池,將每個高速緩存的4池共享128MB的,或將他們自己每個池有128M的opcache?

回答

0

由於OpCache基本上可以作爲APC確實(在共享內存存儲預編譯腳本的字節碼),以同樣的方式,這是confirmed,如果它們是由同一個主開始APC操作碼緩存PHP-FPM池之間共享過程中,也將在4個池之間共享128 MB。

1

作爲通link128 MB將被共享betweeen 4池

添加到該提及raina77ow,作爲官方文件

; Sets how much memory to use 
opcache.memory_consumption=128 

opcache.memory_consumption套中提到無論您使用多少個池,將使用的內存限制將相應地共享。

4

如果您對池之間使用的緩存內存如何進行簡單測試有任何疑問。

技術很簡單。具有相同內容的創建2個不同的WWW-dir的聽音例如8081 FPM-池和8082個端口和2個文件的index.phpcheck.php

<?php 
echo "<pre>\n"; 
var_dump(opcache_get_status()); 

首先重新啓動你的php-fpm的服務,然後運行第一個池localhost:8081/index.php,然後運行localhost:8082/check.php。在此檢查後["scripts"]部分輸出。我下的結果:

本地主機:8081/index.php的

["scripts"]=> 
    array(1) { 
    ["/usr/share/nginx/html/index.php"]=> 
    array(6) { 
     ["full_path"]=> 
     string(31) "/usr/share/nginx/html/index.php" 
     ["hits"]=> 
     int(0) 
     ["memory_consumption"]=> 
     int(1032) 
     ["last_used"]=> 
     string(24) "Mon Dec 23 23:38:35 2013" 
     ["last_used_timestamp"]=> 
     int(1387827515) 
     ["timestamp"]=> 
     int(1387825100) 
    } 
    } 

本地主機:8082/check.php

["scripts"]=> 
    array(2) { 
    ["/usr/share/nginx/html1/check.php"]=> 
    array(6) { 
     ["full_path"]=> 
     string(32) "/usr/share/nginx/html1/check.php" 
     ["hits"]=> 
     int(0) 
     ["memory_consumption"]=> 
     int(1056) 
     ["last_used"]=> 
     string(24) "Mon Dec 23 23:38:47 2013" 
     ["last_used_timestamp"]=> 
     int(1387827527) 
     ["timestamp"]=> 
     int(1387825174) 
    } 
    ["/usr/share/nginx/html/index.php"]=> 
    array(6) { 
     ["full_path"]=> 
     string(31) "/usr/share/nginx/html/index.php" 
     ["hits"]=> 
     int(0) 
     ["memory_consumption"]=> 
     int(1032) 
     ["last_used"]=> 
     string(24) "Mon Dec 23 23:38:35 2013" 
     ["last_used_timestamp"]=> 
     int(1387827515) 
     ["timestamp"]=> 
     int(1387825100) 
    } 
    } 

正如你看到的第二個池已經有index.php在緩存中,所以回答是所有4個池將共享128MB的緩存