Magento Redis会议问题:几小时后网站速度减慢

时间:2016-07-21 21:42:39

标签: magento caching redis magento-1.9 hhvm

我一直在尝试使用Redis for Magento来提升性能,但我在Magneto CE 1.9.2.4中遇到Redis问题。

当我使用Redis时,我的网站在几个小时后变慢,有时可能需要大约一分钟才能加载页面。奇怪的是管理区域正常工作。

我正在使用easyengine堆栈将主要依赖项安装到服务器:hhvm作为php编译器,nginx作为web服务器,redis作为缓存服务器。

服务器操作系统:Ubuntu 14.04 CPU:4 x 2.40 GHz RAM:3072 MB + 384 MB加+ 1536 MB SWAP(使用3261 MB)

server ram usage

我的local.xml配置:

<config>
    <global>
        <install>
            <date><![CDATA[Wed, 27 Apr 2016 21:17:58 +0000]]></date>
        </install>
        <crypt>
            <key><![CDATA[***********]]></key>
        </crypt>
        <disable_local_modules>false</disable_local_modules>
        <resources>
            <db>
                <table_prefix><![CDATA[]]></table_prefix>
            </db>
            <default_setup>
                <connection>
                    <host><![CDATA[localhost]]></host>
                    <username><![CDATA[*********]]></username>
                    <password><![CDATA[*********]]></password>
                    <dbname><![CDATA[*********]]></dbname>
                    <initStatements><![CDATA[SET NAMES utf8]]></initStatements>
                    <model><![CDATA[mysql4]]></model>
                    <type><![CDATA[pdo_mysql]]></type>
                    <pdoType><![CDATA[]]></pdoType>
                    <active>1</active>
                </connection>
            </default_setup>
        </resources>
        <session_save><![CDATA[db]]></session_save>

    <!-- redis cache -->
        <cache>
          <backend>Cm_Cache_Backend_Redis</backend>
          <backend_options>
            <server>127.0.0.1</server>                               
            <port>6379</port>
            <persistent></persistent>                                
            <database>0</database>                                   
            <password></password>                                   
            <force_standalone>0</force_standalone>                   
            <connect_retries>1</connect_retries>                     
            <read_timeout>10</read_timeout>                          
            <automatic_cleaning_factor>0</automatic_cleaning_factor> 
            <compress_data>1</compress_data>                         
            <compress_tags>1</compress_tags>                         
            <compress_threshold>20480</compress_threshold>           
            <compression_lib>gzip</compression_lib>                  
            <use_lua>0</use_lua>                                     
          </backend_options>
        </cache>

    <!-- redis session storage -->
        <session_save>db</session_save>
        <redis_session>                                          
            <host>127.0.0.1</host>                               
            <port>6379</port>
            <password></password>                                
            <timeout>2.5</timeout>                               
            <persistent></persistent>                            
            <db>1</db>                                           
            <compression_threshold>2048</compression_threshold>  
            <compression_lib>gzip</compression_lib>              
            <log_level>1</log_level>                             
            <max_concurrency>6</max_concurrency>                 
            <break_after_frontend>5</break_after_frontend>       
            <break_after_adminhtml>30</break_after_adminhtml>
            <first_lifetime>600</first_lifetime>                 
            <bot_first_lifetime>60</bot_first_lifetime>          
            <bot_lifetime>7200</bot_lifetime>                    
            <disable_locking>0</disable_locking>                 
            <min_lifetime>60</min_lifetime>                      
            <max_lifetime>2592000</max_lifetime>                 
        </redis_session>
    </global>

    <admin>
        <routers>
            <adminhtml>
                <args>
                    <frontName><![CDATA[admin]]></frontName>
                </args>
            </adminhtml>
        </routers>
    </admin>
</config>

HHVM php.ini config:

; php options
session.save_handler = files
session.save_path = /var/lib/hhvm/sessions
session.gc_maxlifetime = 1440

; hhvm specific 
hhvm.log.level = Warning
hhvm.log.always_log_unhandled_exceptions = true
hhvm.log.runtime_error_reporting_level = 8191
hhvm.mysql.typed_results = false
hhvm.log.header = true
hhvm.log.natives_stack_trace = true
hhvm.mysql.socket = /var/run/mysqld/mysqld.sock
hhvm.pdo_mysql.socket = /var/run/mysqld/mysqld.sock
hhvm.mysqli.socket = /var/run/mysqld/mysqld.sock
hhvm.log.header = true
hhvm.log.natives_stack_trace = true

mysql config:

[client]
port        = 3306
socket      = /var/run/mysqld/mysqld.sock

[mysqld_safe]
socket      = /var/run/mysqld/mysqld.sock
nice        = 0

[mysqld]
user        = mysql
pid-file    = /var/run/mysqld/mysqld.pid
socket      = /var/run/mysqld/mysqld.sock
port        = 3306
basedir     = /usr
datadir     = /var/lib/mysql
tmpdir      = /tmp
lc_messages_dir = /usr/share/mysql
lc_messages = en_US
skip-external-locking

max_connections     = 100
connect_timeout     = 5
wait_timeout        = 600
max_allowed_packet  = 16M
thread_cache_size       = 128
sort_buffer_size    = 4M
bulk_insert_buffer_size = 16M
tmp_table_size      = 32M
max_heap_table_size = 32M

myisam_recover_options = BACKUP
key_buffer_size     = 128M
#open-files-limit   = 2000
table_open_cache    = 400
myisam_sort_buffer_size = 512M
concurrent_insert   = 2
read_buffer_size    = 2M
read_rnd_buffer_size    = 1M

query_cache_limit       = 128K
query_cache_size        = 64M

log_warnings        = 2

slow_query_log_file = /var/log/mysql/mariadb-slow.log
long_query_time = 10
log_slow_verbosity  = query_plan

log_bin         = /var/log/mysql/mariadb-bin
log_bin_index       = /var/log/mysql/mariadb-bin.index

expire_logs_days    = 10
max_binlog_size         = 100M

default_storage_engine  = InnoDB

innodb_buffer_pool_size = 256M
innodb_log_buffer_size  = 8M
innodb_file_per_table   = 1
innodb_open_files   = 400
innodb_io_capacity  = 400
innodb_flush_method = O_DIRECT

[mysqldump]
quick
quote-names
max_allowed_packet  = 16M

[isamchk]
key_buffer      = 16M

!includedir /etc/mysql/conf.d/

1 个答案:

答案 0 :(得分:0)

Redis会话锁定

第1步:

<disable_locking>添加到您的Magento local.xml

<session_save><![CDATA[db]]></session_save>
<redis_session>
.
.
   <disable_locking>1</disable_locking>
</redis_session>

第2步:

注意:旧版本的Cm_RedisSession没有此功能。 要找到答案,请打开app / code / community / Cm / RedisSession / Model / Session.php并查找“disable_locking”。

grep disable_locking app / code / community / Cm / RedisSession -r app / code / community / Cm / RedisSession / Model / Session.php ::! (strlen(“{$ config-&gt; descend('disable_locking')}”)?(bool)“{$ config-&gt; descend('disable_locking')}”:self :: DEFAULT_DISABLE_LOCKING);

If you see the above, it will work with no further action. This updated code is bundled as of Magento CE 1.9 or EE 1.14.
If you don’t see that, then the module needs to be updated.