Linux上的Vagrant VirtualBox上的PHP比Linux上的PHP慢10倍

Linux上的Vagrant VirtualBox上的PHP比Linux上的PHP慢10倍,vagrant,Vagrant,我曾经在(a)Ubuntu Linux和(b)Vagrant上检查php基准测试,其中Ubuntu Linux在同一个Ubuntu Linux上运行,而(c)Vagrant在我的Mac上运行 为流浪汉我用 (a)Ubuntu Linux -------------------------------------- | PHP BENCHMARK SCRIPT | -------------------------------------- PHP version :

我曾经在(a)Ubuntu Linux和(b)Vagrant上检查php基准测试,其中Ubuntu Linux在同一个Ubuntu Linux上运行,而(c)Vagrant在我的Mac上运行

为流浪汉我用

(a)Ubuntu Linux

--------------------------------------
|        PHP BENCHMARK SCRIPT        |
--------------------------------------
PHP version : 5.5.23-1+deb.sury.org~precise+2
Platform : Linux
--------------------------------------
test_math                 : 0.969 sec.
test_stringmanipulation   : 1.028 sec.
test_loops                : 0.709 sec.
test_ifelse               : 0.589 sec.
--------------------------------------
Total time:               : 3.295 sec.
(b)在同一个Ubuntu Linux上运行Ubuntu Linux的流浪汉

--------------------------------------
|        PHP BENCHMARK SCRIPT        |
--------------------------------------
PHP version : 5.5.23-1+deb.sury.org~precise+2
Platform : Linux
--------------------------------------
test_math                 : 0.969 sec.
test_stringmanipulation   : 1.028 sec.
test_loops                : 0.709 sec.
test_ifelse               : 0.589 sec.
--------------------------------------
Total time:               : 3.295 sec.
没有vm.synced\u文件夹

--------------------------------------
|        PHP BENCHMARK SCRIPT        |
--------------------------------------
PHP version : 5.5.9-1ubuntu4.11
Platform : Linux
--------------------------------------
test_math                 : 17.078 sec.
test_stringmanipulation   : 15.038 sec.
test_loops                : 1.468 sec.
test_ifelse               : 1.790 sec.
--------------------------------------
Total time:               : 35.374 sec.
(c)我的Mac电脑上的流浪汉:

--------------------------------------
|        PHP BENCHMARK SCRIPT        |
--------------------------------------
PHP version : 5.4.26-1~ppa1~precise
Platform : Linux
--------------------------------------
test_math                 : 1.004 sec.
test_stringmanipulation   : 1.111 sec.
test_loops                : 0.591 sec.
test_ifelse               : 0.609 sec.
--------------------------------------
Total time:               : 3.315 sec.
--------------------------------------
|        PHP BENCHMARK SCRIPT        |
--------------------------------------
PHP version : 5.4.26-1~ppa1~precise
Platform : Linux
--------------------------------------
test_math                 : 1.041 sec.
test_stringmanipulation   : 1.064 sec.
test_loops                : 0.650 sec.
test_ifelse               : 0.636 sec.
--------------------------------------
Total time:               : 3.391 sec.
vm.synced_文件夹:类型:“nfs”

我应该怎么做才能让它工作得更快


超节点基准 (d)ubuntu上vagrant上的超节点:

--------------------------------------
|        PHP BENCHMARK SCRIPT        |
--------------------------------------
PHP version : 5.4.26-1~ppa1~precise
Platform : Linux
--------------------------------------
test_math                 : 1.004 sec.
test_stringmanipulation   : 1.111 sec.
test_loops                : 0.591 sec.
test_ifelse               : 0.609 sec.
--------------------------------------
Total time:               : 3.315 sec.
--------------------------------------
|        PHP BENCHMARK SCRIPT        |
--------------------------------------
PHP version : 5.4.26-1~ppa1~precise
Platform : Linux
--------------------------------------
test_math                 : 1.041 sec.
test_stringmanipulation   : 1.064 sec.
test_loops                : 0.650 sec.
test_ifelse               : 0.636 sec.
--------------------------------------
Total time:               : 3.391 sec.
(e)mac上的vagrant上的超节点:

--------------------------------------
|        PHP BENCHMARK SCRIPT        |
--------------------------------------
PHP version : 5.4.26-1~ppa1~precise
Platform : Linux
--------------------------------------
test_math                 : 1.004 sec.
test_stringmanipulation   : 1.111 sec.
test_loops                : 0.591 sec.
test_ifelse               : 0.609 sec.
--------------------------------------
Total time:               : 3.315 sec.
--------------------------------------
|        PHP BENCHMARK SCRIPT        |
--------------------------------------
PHP version : 5.4.26-1~ppa1~precise
Platform : Linux
--------------------------------------
test_math                 : 1.041 sec.
test_stringmanipulation   : 1.064 sec.
test_loops                : 0.650 sec.
test_ifelse               : 0.636 sec.
--------------------------------------
Total time:               : 3.391 sec.

使用超节点基准测试更好。但Magento的加载时间仍然不太好。我不知道该用哪个脚本来显示如何重现速度问题。

看来,您的系统上使用了配置不好的“漫游”框。例如,没有优化的虚拟化,内存不足,并非所有CPU都是共享的

我在自己的机器上得到了完全不同的结果:

约塞米蒂OSX,pP5.5

--------------------------------------
|        PHP BENCHMARK SCRIPT        |
--------------------------------------
Start : 2015-07-31 11:42:45
Server : @
PHP version : 5.5.24
Platform : Darwin
--------------------------------------
test_math                 : 1.078 sec.
test_stringmanipulation   : 1.514 sec.
test_loops                : 0.813 sec.
test_ifelse               : 0.695 sec.
--------------------------------------
Total time:               : 4.1 sec.
Vagrant Box(nfs服务器在来宾操作系统上)Ubuntu,PHP5.4

--------------------------------------
|        PHP BENCHMARK SCRIPT        |
--------------------------------------
Start : 2015-07-31 11:43:28
Server : @
PHP version : 5.4.26-1~ppa1~precise
Platform : Linux
--------------------------------------
test_math                 : 1.143 sec.
test_stringmanipulation   : 1.171 sec.
test_loops                : 0.728 sec.
test_ifelse               : 0.642 sec.
--------------------------------------
Total time:               : 3.684 sec.
我有这样一个配置文件:

VAGRANTFILE_API_VERSION = "2"
BOX_NAME='project'
HOSTNAME="#{BOX_NAME}.box"
ALIASES=%w(subdomain.project.box subdomain2.project.box)
ALIASES << HOSTNAME

%w(vagrant-hostmanager vagrant-nfs_guest vagrant-auto_network).each do |plugin|
  unless Vagrant.has_plugin?(plugin)
    raise 'In order to use this box, you must install plugin: ' + plugin
  end
end

AutoNetwork.default_pool = '33.33.33.0/24'

Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
  config.ssh.forward_agent = true
  config.vm.provider 'virtualbox' do |vb|
    # Clean up network interface after tests.
    vb.destroy_unused_network_interfaces = true
  end

  config.vm.box = "hypernode"
  config.vm.box_url = "http://vagrant.hypernode.com/catalog.json"

  config.vm.provision "shell", path: "vagrant/provisioning/hypernode.sh"
  config.vm.provision "shell", path: "vagrant/provisioning/project.sh"

  config.vm.synced_folder '.', '/vagrant/', disabled: true

  if Vagrant.has_plugin?("vagrant-nfs_guest")
     config.vm.synced_folder 'server', '/data/web', type: 'nfs_guest', create: true,
        linux__nfs_options: ["rw", "no_subtree_check", "all_squash", "insecure", "async"],
        map_uid: Process.euid, map_gid: Process.egid
  end

  if Vagrant.has_plugin?("vagrant-hostmanager")
    config.hostmanager.enabled = true
    config.hostmanager.manage_host = true
    config.hostmanager.ignore_private_ip = false
    config.hostmanager.include_offline = true
    config.vm.define 'hypernode' do |node|
      node.vm.hostname = "#{BOX_NAME}.hypernode.box"
      node.vm.network :private_network, auto_network: true
      node.hostmanager.aliases = ALIASES
    end
  end
end
VAGRANTFILE\u API\u VERSION=“2” 框_NAME='project' HOSTNAME=“#{BOX_NAME}.BOX” 别名=%w(subdomain.project.box subdomain2.project.box)
别名您是否在BIOS中启用了虚拟化支持?脚本是否在共享文件系统上?Im也是linux主机和linux来宾(都是ubuntu)您可以发布您的vagrant fileshare配置吗?-----------------------------------------------PHP基准脚本|------------------------------------开始:2015-07-31 12:40:22服务器:@PHP版本:5.5.27-1+deb.sury.org~precise+1平台:Linux----------------------测试数学:5.094秒。测试:4.549秒。测试循环:1.908秒。测试:1.409秒。-------------------------------------总时间:12.96秒。我用vagrant配置和文件共享选项更新了帖子。b)怎么样,你是说这是VirtualBox文件共享吗?如果是这样,请在你的帖子中提及更多信息。谢谢!那个很好用!有没有办法配置此框?我看到一些文件是由Ansible生成的。能够更改配置也很好。PHP基准测试显示了良好的结果。但是Magento也有同样的速度。3-4s在hypernode vagrant上加载主页,300ms在Ubuntu Linux上加载。@razbakov不要忘记nfs来宾插件工具