Pimcore in a load-balanced environment

Make recommendations and share installation and reliability experiences.
Post Reply
neilcraig
Posts: 45
Joined: Fri Dec 16, 2011 7:49 pm
Location: Oxford, UK
Contact:

Pimcore in a load-balanced environment

Post by neilcraig » Wed Feb 22, 2012 2:35 pm

Hi all

I've been learning pimcore recently and have a test rig here at work with a pair of load balanced debianb/nginx web servers, an NFS share for shared assets/files and a MySQL (well, percona) database server (which will soon be a mirrored pair) - i'm building a small internal app in pimcore and also using this as a proof of concept in setup/configuration.

I have today started the work of making Pimcore work properly in a load-balanced sense, i.e. moving shared assets/files to the nfs share - this is the part i am struggling a little with. The directories i have moved so far are /static (more for my benefit) and also website/var.

The front end is working fine as-is, the major 2 issues i have though are:
- The admin interface will not allow me to log in when load-balanced - i get an endless redirect loop upon submitting the login form

- When i modify content via the admin interface, the changes do not show on the front end. I wonder if this is due to the cache/static files being (or not being) on the nfs share

What would be really useful is if someone could annotate a tree diagram of the pimcore directory structure showing which files/directories should be moved to shared (nfs) storage. It seems that several people are looking for this information.

If anyone is able to help, that would be very much appreciated - i am happy to help out in any way i can e.g. testing etc.

Many thanks
Neil

neilcraig
Posts: 45
Joined: Fri Dec 16, 2011 7:49 pm
Location: Oxford, UK
Contact:

Re: Pimcore in a load-balanced environment

Post by neilcraig » Wed Feb 22, 2012 2:39 pm

I just had a look in the chrome console and when logging in, it looks like i am being redirected from /admin to /admin?_dc=xyz mutliple times - i guess this is probably a session problem. i will look at moving the session data to nfs now.

neilcraig
Posts: 45
Joined: Fri Dec 16, 2011 7:49 pm
Location: Oxford, UK
Contact:

Re: Pimcore in a load-balanced environment

Post by neilcraig » Wed Feb 22, 2012 2:45 pm

Right, that solved the admin login problem!

I moved the session.save_path in my php.ini file to a path pointing to the nfs share and that now works (make sure your permissions allow your web server user/group to write to the relevant path if you do the same)

I can't make nginx use a per-site session.save_path yet, i will post back if i get that working (it's better for security)

Now i just really need that map of pimcore directories and what should be put on the nfs share - if someone can help with that i will write the whole thing up into a tutorial - i am sure lots of people want to use pimcore in a load balanced setup!

Cheers
Neil

neilcraig
Posts: 45
Joined: Fri Dec 16, 2011 7:49 pm
Location: Oxford, UK
Contact:

Re: Pimcore in a load-balanced environment

Post by neilcraig » Wed Feb 22, 2012 2:52 pm

Actually, i do still have the problem that saving in admin does not update front end content

User avatar
IgorBenko
Posts: 689
Joined: Thu Jul 21, 2011 4:33 pm
Location: Berlin
Contact:

Re: Pimcore in a load-balanced environment

Post by IgorBenko » Wed Feb 22, 2012 4:49 pm

Although I can't help you, I want to thank you for reporting your problems and solutions on forum!

I hope you will sort it out.

Greets, Igor
basilicom GmbH - Official Pimcore Selected Company - http://basilicom.de/de/pimcore

neal
Posts: 13
Joined: Mon Aug 22, 2011 4:24 am
Location: Texas, USA

Re: Pimcore in a load-balanced environment

Post by neal » Thu Feb 23, 2012 1:56 am

Hi Neil,

I also am working on load-balancing pimcore. I'll post any updates I have here. Thanks for sharing your results so far!

neilcraig
Posts: 45
Joined: Fri Dec 16, 2011 7:49 pm
Location: Oxford, UK
Contact:

Re: Pimcore in a load-balanced environment

Post by neilcraig » Thu Feb 23, 2012 12:12 pm

Hi Neal, Igor

No problem...i am hoping to get a little time tomorrow to work on this, i'll post back here also with findings.

Many thanks
Neil

santos
Posts: 1
Joined: Thu Feb 23, 2012 7:15 pm

Re: Pimcore in a load-balanced environment

Post by santos » Thu Feb 23, 2012 7:22 pm

Hi Neil,

thank you for sharing your progress with pimcore in a load-balanced enviroment. This might get helpful for us aswell.

I've a question about nginx - we're discussing to change from apache to nginx - what are your experiences, is everything working fine?
I've googled a little bit about it and all i found were these links:
viewtopic.php?f=19&t=109&p=229&hilit=nginx#p229
http://www.pimcore.org/issues/browse/PIMCORE-1134

Did you already convert the whole .htaccess to nginx.conf? If yes could you share it?

thx

brusch
Core Team
Posts: 565
Joined: Sat Jul 16, 2011 5:37 pm
Location: Salzburg, AT
Contact:

Re: Pimcore in a load-balanced environment

Post by brusch » Thu Feb 23, 2012 9:48 pm

Hi,

For a clusted environment i recommend you to put the whole document root onto the NFS-share (this makes the maintenance a lot easier, eg. updates, ... ). At least you have to share the complete website/var folder (this is the only place where pimcore writes files to). You also have to use the memcached cache adapter, otherwise the cache-file will be written to the NFS. I think you can imagine the effect :)
http://www.pimcore.org/wiki/display/PIMCORE/Cache

Cheers,
Bernie

timg
Official Partner
Posts: 170
Joined: Fri Jul 22, 2011 11:59 am

Re: Pimcore in a load-balanced environment

Post by timg » Fri Feb 24, 2012 2:15 am

to avoid IO Requests use the apc.stat http://www.php.net/manual/de/apc.config ... i.apc.stat . you can combine them with an auto prepend file http://www.php.net/manual/en/ini.core.p ... epend-file to clear the apc cache.

neal
Posts: 13
Joined: Mon Aug 22, 2011 4:24 am
Location: Texas, USA

Re: Pimcore in a load-balanced environment

Post by neal » Fri Feb 24, 2012 4:52 am

I spent some time today setting up two ubuntu/apache servers running pimcore behind a load-balancer.

Caching is handled with memcache, and I kept the document roots local to each server. I shared most of the /website/var folder via NFS. Both the frontend and admin work fine, including content changes. I haven't finished testing session handling yet because I plan on moving sessions to memcache as well.

For a basic setup, it's probably best to share the entire /website/var directory, but I am planning to exclude /website/var/classes and /website/var/areas from NFS.

Although excluding /website/var/classes will break object class management, I plan on disabling it in our production environment. I think it is bad practice to allow users to modify php code and database schema directly in production environments. We require these types of modifications to go through our dev->staging->production process.

I'm also keeping the document roots off of NFS because we have experienced poor performance and reliability issues when running php code directly from NFS. Of course, as Bernie mentioned, this complicates deployment/maintenance, but we have a custom deployment system that handles this.

Cheers,
Neal

neilcraig
Posts: 45
Joined: Fri Dec 16, 2011 7:49 pm
Location: Oxford, UK
Contact:

Re: Pimcore in a load-balanced environment

Post by neilcraig » Fri Feb 24, 2012 11:23 am

Hi everyone

Thanks very much for all your input.

Bernie: I did consider putting all the files on NFS but was aware that might mean hitting the NFS share pretty hard as per Neal's comments - though i am using php-xcode which (similarly to APC) should mitigate that to a large extent. I'll continue to think about this.

Santos - please see attached example nginx config files. Do please note though that these are a genuine work-in-progress so may yet be optimised, may contain mistakes and may contain insecurities - they're provided as-is with no warranty of any kind. That said, they should get you up and running for a dev environment at least.

The files are based on a (Debian) Linux server - so remove the ".txt" file extensions on all files, copy the vhost file (remember to adjust for your website/domain name and remember to add the symlink in /etc/nginx/site-enabled), then copy the rest of the files to /etc/nginx (this all assumes your nginx config files live there).

You will also need to amend some variables in the vhost file ($base_loc - set this to the base path where your website lives - this files assumed the directory your website files are in is $base_loc/$main_domain_name/www).
I hope this all makes sense, feel free to ask any questions if not.

Please also note that i have ported the access control rules from apache mod_rewrite to nginx rewrite rules (in php-pimcore file).

Finally, you will need to ensure you have the necessaries installed, on Debian i use php5, php5-fpm, php5-mysql plus the regulars - i can supply more info if needed.


If anyone has any ideas on where i should begin to look as to why the content updates in the admin area but not on the front-end (even after nginx and php-fpm restarts) then i'd very much appreciate some pointers - i ran out of ideas when looking a couple of days ago.

Many thanks
Neil
Attachments
Pimcore nginx config for pimcore forums.zip
Development versions of nginx - pimcore config files
(3.03 KiB) Downloaded 464 times

neilcraig
Posts: 45
Joined: Fri Dec 16, 2011 7:49 pm
Location: Oxford, UK
Contact:

Re: Pimcore in a load-balanced environment

Post by neilcraig » Fri Feb 24, 2012 2:15 pm

After a little further investigation, it seems that the "current version" of the document is not being updated, if i steal the query string which the admin area uses to show different versions of the document, i see my edits.

This seems unrelated in any way to my load balanced setup - it may be that i have an old version of pimcore example code, i had to download it from the archive.

I think i'll start again with the latest stable build and see how it goes.

timg
Official Partner
Posts: 170
Joined: Fri Jul 22, 2011 11:59 am

Re: Pimcore in a load-balanced environment

Post by timg » Fri Feb 24, 2012 7:10 pm

Code: Select all

because we have experienced poor performance and reliability issues when running php code directly from NFS


just read my post from Fri Feb 24, 2012 1:15 am. avoid io requests using apc. memcache should work fine, but i would also try to disable the cache (also Output Cache).

if you have a lot of content pages we prefer to loadbalance multiple varnish instances.
On "dynamic" high traffic pages you could improve the performance using a 1 second cache 8-)

neal
Posts: 13
Joined: Mon Aug 22, 2011 4:24 am
Location: Texas, USA

Re: Pimcore in a load-balanced environment

Post by neal » Sun Feb 26, 2012 10:55 pm

timg wrote:just read my post from Fri Feb 24, 2012 1:15 am. avoid io requests using apc. memcache should work fine, but i would also try to disable the cache (also Output Cache).


Hi Tim,

Thanks for your input. I actually did read your response. We have experimented with disabling stat in the past, but we weren't satisfied with the results. We host hundreds of sites, and it wasn't safe to assume that apc could cache all of our sites in memory. Also, clearing the apc cache across our cluster of app servers every time a file is modified adds more complexity to our deployment process.

More importantly, we run our sites in Amazon's EC2 cloud, and that means we need to be prepared for server instances to become unavailable at any moment. When we ran all of our sites on NFS, we experienced a single point of failure that would bring down all of our sites at once. We can handle unhealthy app server instances much more gracefully behind our load balancer.

timg wrote:if you have a lot of content pages we prefer to loadbalance multiple varnish instances. On "dynamic" high traffic pages you could improve the performance using a 1 second cache


I also agree that the most significant performance gains come from full page caching. However, we still need to be able to scale our app servers reliably. I think our use case might be a little different because we host so many sites in a shared environment. Regardless, cloud computing is becoming a very popular choice, and I think pimcore should think a little more about supporting cloud architecture.

Thanks again for sharing your advice. I'm always open to hearing new ideas.

Cheers,
Neal

timg
Official Partner
Posts: 170
Joined: Fri Jul 22, 2011 11:59 am

Re: Pimcore in a load-balanced environment

Post by timg » Mon Feb 27, 2012 7:06 pm

we discussed about a IO driver
https://github.com/pimcore/pimcore/pull/7

at the moement i like the way to create a complex deployment. for example a

customer change content
-> create deb (or whatever you want) package
-> deploy deb package using you your favourite tool (bash, php, phing, c, capistrano, ant, ...)


if you just want to host pimcore pages without a complex deployment it's pain. but i think there is no really good solution for this issue.

i would like special IO Driver, using different stream wrappers it could be very easy to use something like s3 for custom data.

kathleenrueb
Posts: 3
Joined: Thu May 28, 2015 1:22 pm

Re: Pimcore in a load-balanced environment

Post by kathleenrueb » Fri Oct 02, 2015 9:02 am

I am very excited to see how the pimcore would work in the load-balanced environment condition. I have already done a project based on the load-balancing concept. Let me try it do it using pimcore.

Post Reply

Return to “Hosting Issues & Experiences”



Who is online

Users browsing this forum: No registered users and 1 guest