我在Digital Ocean服务器上运行Magento商店时遇到问题。
这是我的Droplet配置:
2GB Ram | 40GB SSD Disk | New York 2 | Ubuntu Ubuntu 12.04.3 x64
当我使用Magento商店时,它正常工作,除非我尝试创建帐户或进行购买。
然后完成购买需要2分钟。
我在本地下载了整个站点(使用db),订单和创建帐户只需几秒钟。
我尝试将Droplet升级到4GB Ram,但仍然是相同的。
这是我的php配置:
max_execution_time 30
max_file_uploads 20 20
max_input_nesting_level 64
max_input_time 60
max_input_vars 1000
memory_limit 512M
我不知道如何继续调试。有人可以建议吗?
更新#2(基于MageWorx的UPD): 基于MageWorx(更新)的建议,我在服务器上运行了mysqltunner。结果如下:
[OK] Logged in using credentials from debian maintenance account.
[OK] Currently running supported MySQL version 5.5.38-0ubuntu0.12.04.1
[OK] Operating on 64-bit architecture
-------- Storage Engine Statistics -------------------------------------------
[--] Status: +ARCHIVE +BLACKHOLE +CSV -FEDERATED +InnoDB +MRG_MYISAM
[--] Data in MyISAM tables: 25K (Tables: 28)
[--] Data in InnoDB tables: 36M (Tables: 1386)
[--] Data in PERFORMANCE_SCHEMA tables: 0B (Tables: 17)
[--] Data in MEMORY tables: 0B (Tables: 68)
[!!] Total fragmented tables: 1387
-------- Security Recommendations -------------------------------------------
[OK] All database users have passwords assigned
-------- Performance Metrics -------------------------------------------------
[--] Up for: 49s (338 q [6.898 qps], 71 conn, TX: 181K, RX: 51K)
[--] Reads / Writes: 92% / 8%
[--] Total buffers: 832.0M global + 2.7M per thread (100 max threads)
[OK] Maximum possible memory usage: 1.1G (54% of installed RAM)
[OK] Slow queries: 0% (0/338)
[OK] Highest usage of available connections: 2% (2/100)
[OK] Key buffer size / total MyISAM indexes: 32.0M/178.0K
[!!] Query cache efficiency: 12.9% (30 cached / 233 selects)
[OK] Query cache prunes per day: 0
[OK] Sorts requiring temporary tables: 0% (0 temp sorts / 12 sorts)
[OK] Temporary tables created on disk: 25% (57 on disk / 222 total)
[OK] Thread cache hit rate: 97% (2 created / 71 connections)
[OK] Table cache hit rate: 25% (1K open / 6K opened)
[OK] Open file limit used: 1% (104/8K)
[OK] Table locks acquired immediately: 100% (248 immediate / 248 locks)
[OK] InnoDB buffer pool / data size: 512.0M/36.8M
[OK] InnoDB log waits: 0
-------- Recommendations -----------------------------------------------------
General recommendations:
Run OPTIMIZE TABLE to defragment tables for better performance
MySQL started within last 24 hours - recommendations may be inaccurate
Enable the slow query log to troubleshoot bad queries
Variables to adjust:
query_cache_limit (> 4M, or use smaller result sets)
这些是apachebuddy的结果:
Your server has 2002 MB of memory
The largest apache process is using 39.78 MB of memory
The smallest apache process is using 15.04 MB of memory
The average apache process is using 17.32 MB of memory
Going by the average Apache process, Apache can potentially use 433.00 MB RAM (21.63 % of available RAM)
Going by the largest Apache process, Apache can potentially use 994.50 MB RAM (49.68 % of available RAM)
Generating reports...
### GENERAL REPORT ###
Settings considered for this report:
Your server's physical RAM: 2002MB
Apache's MaxClients directive: 25
Apache MPM Model: prefork
Largest Apache process (by memory): 39.78MB
[ OK ] Your MaxClients setting is within an acceptable range.
Max potential memory usage: 994.5 MB
Percentage of RAM allocated to Apache 49.68 %
答案 0 :(得分:2)
我敢于认为问题是由于缺少mysql设置优化造成的。关键是没有优化mysql,你就无法提高网站速度,因为mysql不会使用100%的服务器资源。
这些是2Gb Droplet的基本设置(/etc/mysql/my.cnf):
key_buffer=32M
query_cache_type=1
query_cache_limit=1M
query_cache_size=32M
table_cache=128
innodb_buffer_pool_size=256M
由于这些是基本设置,您可以使用app http://mysqltuner.com/进行进一步的mysql优化。
答案 1 :(得分:2)
UPD:
正如我从mysqltuner的结果中看到的那样,您需要尝试以下设置:
skip-networking
query_cache_limit = 4M
query_cache_size = 256M
thread_concurrency = 4
table_open_cache = 4096
innodb_buffer_pool_size = 512M
join_buffer_size = 1M
另请注意,在对my.cnf文件进行更改后,不要忘记重启mysql
sudo service mysql restart
设置适用后,请测试您的网站一段时间,然后启动mysqltuner以查看结果。
答案 2 :(得分:1)
对于各种Magento开发/暂存站点,我使用精确的数字海洋配置(就RAM和SSD而言 - 我的Centos和默认的PHP.ini配置),它们工作正常,所以我说你的服务器配置不是问题。它必须是模板或模块中的低效代码。
我开始对它进行分析;
https://www.nublue.co.uk/blog/using-magento-profiler-to-speed-up-magento-performance/
我仍然使用AOE探查器模块,它让我觉得生活更轻松;
https://github.com/fbrnc/Aoe_Profiler
我还会运行n98-magerun以查看是否存在模块冲突;
https://github.com/netz98/n98-magerun
然后,如果你仍然找不到它,请切换到默认主题并开始禁用模块以查看它是哪一个。