【问题标题】:Magento on DigitalOcean serverDigitalOcean 服务器上的 Magento
【发布时间】:2015-02-13 09:24:42
【问题描述】:

我对在 Digital Ocean 服务器上运行的 Magento 商店有疑问。

这是我的液滴配置:

2GB Ram | 40GB SSD Disk | New York 2 | Ubuntu Ubuntu 12.04.3 x64

当我使用 Magento 商店时,它可以正常工作,除非我尝试创建帐户或进行购买。

然后需要2分钟完成购买。

我在本地(使用 db)下载了整个网站,订购和创建帐户只需几秒钟。

我尝试将 droplet 升级到 4GB 内存,但还是一样。

这是我的 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(updated) 的建议,我在服务器上运行了 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 %

【问题讨论】:

    标签: php mysql apache magento digital-ocean


    【解决方案1】:

    更新:

    从你使用 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 以查看结果。

    【讨论】:

    • 您好,感谢您的更新。我更新了这些设置,但还是一样。我还添加了 mysqltunner 的新结果。我应该对总碎片表的数量做些什么吗?也许这就是导致它变慢的原因
    • 就mysql而言,你需要运行命令“mysqlcheck -u username -p --auto-repair --check --optimize --all-databases” 另外我建议你将 php 设置的 max_input_vars 增加到 5000
    • 我做了所有这些,但结果仍然相同。我联系了数字海洋以获取更多信息。我还安装了 apachebuddy 并从中添加了结果。仍然是相同的行为。
    • 要回答这个问题,我们需要了解以下详细信息:您使用什么作为邮件服务器? (SMTP 或内部)?从您的工作电子邮件发送的电子邮件是否会到达收件人?您使用的是哪个版本的 Magento?您的在线商店中的产品数量是多少?您在商店中使用了哪些扩展程序?
    • 邮件服务器就是解决方案!所以一开始我没有做任何事情来设置邮件服务器,这就是为什么发送一封电子邮件需要 2 分钟。所以,我只是设置了 Postfix 邮件服务器,它就像一个魅力。你能添加电子邮件答案,以便我接受吗?
    【解决方案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
    

    由于这些是基本设置,您可以使用应用程序http://mysqltuner.com/ 进一步优化mysql。

    【讨论】:

    • 您好 MageWorx,感谢您的回复。我用 MysqlTunner 结果更新了我的问题。我看到这个项目上有 2 个感叹号:Total fragmented tables。我应该为此做点什么吗?你有什么建议吗?谢谢
    【解决方案3】:

    我为各种 Magento 开发/登台站点使用精确的 Digital Ocean 配置(就 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

    然后如果你仍然找不到它切换到默认主题并开始禁用模块以查看它是哪一个。

    【讨论】:

    • 您好,感谢您的评论。我检查了站点代码,所以它肯定与代码无关。因为,我尝试在共享主机上使用相同的代码。我在服务器上创建的 mysql 或 php 配置可能有错误。
    • 我还检查了该服务器上新安装的 Magento,结果相同。
    • 啊,对不起,我错过了您关于在本地将其拉下来并且在那里还可以的观点。那么我将把这个答案留给一般的调试链接。
    • 好的,谢谢,我给你的链接投了票,因为它对 Magento 的调试很有用。还是谢谢。
    猜你喜欢
    • 1970-01-01
    • 2018-07-26
    • 1970-01-01
    • 2017-01-03
    • 2016-06-23
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多