title: Drupal very slow in Vagrant environment
body: <p>I've begun migrating a lot of our development environments to Vagrant. So far, this has been great for almost everything, but our first Drupal migration is unusable. It's unbelievably slow. Our Wordpress, CakePHP and Node.js sites all perform very adequately or better, but not Drupal. This think is just <em>awful</em>.</p>
  
  <p>The box is a Veewee-created Ubuntu 12.04 64bit machine. It's the same base box we use for all of our web-based projects so nothing unique there. In my sites directory, I have a canonical directory (<code>sites/my-site/</code>) with all of the site resources and a symlink to that canonical directory with the domain name (<code>sites/dev.mysite.com -&gt; /vagrant/www/sites/my-site</code>) that is evidently required for some module that the team is using.</p>
  
  <p>This is a mixed Windows/OSX dev team and it's slow across both platforms. The only semi-unconventional snippet from my <code>Vagrantfile</code> is this:</p>
  
  <pre><code>config.vm.forward_port 80, 8080
  
  config.vm.share_folder( "v-root", "/vagrant", ".", :extra =&gt; 'dmode=777,fmode=777' )
  
  # Allows symlinks to the host directory.
  config.vm.customize ["setextradata", :id, "VBoxInternal2/SharedFoldersEnableSymlinksCreate/v-root", "1"]
  
  Vagrant::Config.run do |config|
    config.vm.provision :shell, :path =&gt; "provision.vm.sh"
  end
  </code></pre>
  
  <p>My shell provisioner only does a couple of things:</p>
  
  <ul>
  <li>Installs drush</li>
  <li>Creates the aforementioned symlink to the canonical site directory</li>
  <li>Writes out an Nginx server block</li>
  <li>If necessary, creates a <code>settings.php</code> file.</li>
  </ul>
  
  <p>Is there anything I can do to improve performance? Like, a lot?</p>
  
  <p><strong>UPDATE</strong></p>
  
  <p>I've narrowed this down to a point where it looks like the issue is the remote database. To compare apples to apples with no project baggage, I downloaded a fresh copy of Drupal 7.21 and performed a standard install from the Vagrant web server against 3 different databases:</p>
  
  <ul>
  <li>A new database created on the same Vagrant VM as the webserver (localhost)</li>
  <li>A new database created on the shared dev server used in the original question (dev)</li>
  <li>A new database created on an EC2 instance (tmp)</li>
  </ul>
  
  <p>Once that was done, I logged in to the fresh Drupal install and loaded the homepage (localhost:8080) 5 times. I then connected to each database and loaded the same page, the same way. What I found was that the page loaded 4-6x slower when Drupal was connected to the remote database.</p>
  
  <p>Remember, this is a fresh (standard) install. There is no project baggage.</p>