Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Performance improvements #2

Open
peterlarkin opened this issue Dec 17, 2014 · 18 comments
Open

Performance improvements #2

peterlarkin opened this issue Dec 17, 2014 · 18 comments
Assignees

Comments

@peterlarkin
Copy link
Member

I think it'd be great if we can spend some time looking into the speed of crafty. It feels like a real drag sometimes.

I understand that Craft in dev mode is always going to be bit a bit slower but I wonder if there's anything we can do to speed it up, possibly on the Vagrant box?

@nickautomatic
Copy link
Contributor

Yep, it would be great to speed it up. I think there are a few things we might do. From what I've gathered, a major source of slowness for Vagrant is accessing the shared folder. Newer versions of Vagrant let you use rsync to sync the folders, rather than trying to share between the filesystem and the vagrant machine, which is meant to be more efficient (though at the cost of some increased complexity). Might be worth a try.

Another thing that might be worth a shot would be to install APC for PHP, which caches frequently-accessed php scripts in memory, which might help if the filesystem accesses are the major source of slowness.

@nickautomatic
Copy link
Contributor

Also, in the short term, might be worth setting type: "nfs" on the shared folder. This should be more efficient on OSX / Linux, and though it won't have any effect on Windows, it shouldn't cause any problems either (Vagrant on Windows should just ignore it).

@balazscsaba2006
Copy link

@nickautomatic Actually even on Windows NFS will work, with help from this plugin: https://github.com/winnfsd/vagrant-winnfsd

Happy coding!

@nickautomatic
Copy link
Contributor

@balazscsaba2006 Thanks for that - looks interesting! Have you tried it with Vagrant on Windows at all? If so, did you find it makes a noticeable difference to performance?

@balazscsaba2006
Copy link

Yes, we are using it for almost a year now on the current project. The performance boost is more visible with heavier systems, eg. based on Symfony, and the speedup is a couple 100%s. I really recommend it for Windows users.

@nickautomatic
Copy link
Contributor

Ah, that sounds really promising! I'll definitely give this a try when I have a moment. Thanks again for the suggestion.

@nickautomatic
Copy link
Contributor

Another possible performance improvement (jotting here while it's fresh in my mind) - Twig has a PHP extension that improves performance of compiling Twig templates. Adding that to the Vagrant box might give another speed boost.

@balazscsaba2006
Copy link

Exactly, this one
I'm using it on production, but don't expect a huge improvement, it will be around 10-15%, but it's worth it.

@nickautomatic
Copy link
Contributor

Ah, interesting - thanks again @balazscsaba2006. Good to know it makes a noticeable difference! Now I just need to find some time to get it set up...

@balazscsaba2006
Copy link

@nickautomatic This is the best part, I've installed it on 4 servers in 10 minutes, so it is just a plug and play really.

@nickautomatic
Copy link
Contributor

@balazscsaba2006 Excellent, that sounds promising. I still have to write a Puppet script to get it to install in Crafty Vagrant, but sounds like it should be easy enough in that case.

@nickautomatic
Copy link
Contributor

nickautomatic commented Apr 16, 2016

I've just seen that Ubuntu 16.04 uses PHP 7 as its default PHP version. Since that's meant to have major performance improvements over PHP 5, I'd suggest we bump Crafty up to Ubuntu 16.04 in the near future (it's due to be released later this week).

@nickautomatic
Copy link
Contributor

An Ubuntu 16.04 / PHP 7 / Apache 2.4 / MySQL 5.7 environment is now available on a feature branch (feature/php7.0)

This should be significantly more performant, but would be good to test this a bit before merging it into master. If anyone tries and has any feedback (eg. Did it improve performance? Did you run into any problems?) please do post it here!

@toddprouty toddprouty mentioned this issue Jul 29, 2016
@certainlyakey
Copy link

certainlyakey commented Aug 10, 2016

Also, in the short term, might be worth setting type: "nfs" on the shared folder.

After inserting :nfs => true in the end of my Vagrantfile (removed :owner => "www-data", group: "www-data" as console asked), Craft gave me this message:

Could not find your craft/ folder. Please ensure that $craftPath is set correctly in /vagrant/app/public/index.php

The whole line in the config now looks like this:

config.vm.synced_folder "app/", "/vagrant/app/", :nfs => true

Why would this happen? The path hasn't changed and the folder is where it was before. It seems one of the 2 folders haven't mounted.

@nickautomatic
Copy link
Contributor

@certainlyakey It turns out that switching to NFS changes the way permissions are handled, which I suspect is what's causing the problem you're experiencing here. I only suggested it because I thought it might be a "quick win", improving performance a bit on Unix-like host OSes without causing problems on Windows. But since it introduces problems of its own I don't think it's worthwhile (for us, anyway - Crafty Vagrant is intended to work on OSX, Linux, or Windows). Switching to PHP7 + Apache 2.4 - which you can try on the php7.0 feature branch - seemed like a better bet, since it provides significant performance improvements regardless of host OS. In future we might revisit this, but we'd probably more likely go with rsync than NFS for Vagrant's synced folders I think (since that potentially works on all host OSes).

If you do get anywhere with NFS, do let us know (I'd be interested to see what you did to get it working), but for the above reasons there are no plans to switch to NFS with Crafty Vagrant, for the moment, anyway. If you'd like better performance, do try the feature/php7.0 branch (which we're still testing) and let us know how you get on.

@certainlyakey
Copy link

certainlyakey commented Aug 11, 2016

Thanks for your reply! I'm already on php7 - even though i installed it myself to a machine based on master, so Apache is probably not that new. The performance is better by (subjectively) somewhat 20-30%, so it's bearable though still leaves a lot to be desired.

UPDATE: Actually now it's closer to 60-70%, so far better than before.

If I'll try again to get somewhere with NFS, I'll give some instructions here.

@j-greig
Copy link

j-greig commented Aug 11, 2017

Any update on the possibility of NFS compatibility?

@nickautomatic
Copy link
Contributor

nickautomatic commented Aug 16, 2017

@j-greig My previous comment still holds I'm afraid: we have no plans to switch to NFS. Please do feel free to send a pull request though if you (or anyone else) do manage to get it working!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants