Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.


Our old forums are still available as a read-only archive.

Moderators: martimiz, Sean, biapar, Willr, Ingo, simon_w

Load balancing

Go to End

11 Posts   7355 Views


22 April 2008 at 10:21pm Community Member, 787 Posts


Has anyone got any experience with load balancers in combination with Silverstripe ?

I've currently got a live site which behaves quite weird behind a load-balancer (once someone is logged in into Silverstripe the system gets very very slow for that user) and I'm wondering if the caching system is acting up if there are 2 machines writing / reading to the same silverstripe-cache directory.

Is there a way to switch the entire caching system off so I can test this ?


23 April 2008 at 1:52pm Administrator, 685 Posts

I know that Matt set up a site on Mediatemple's grid hosting and had to deal with a few issues surrounding this.

Matt - care to elaborate?


23 April 2008 at 9:10pm Community Member, 787 Posts

Thanks. I'd be really interested in hearing about this....


23 April 2008 at 9:53pm Core Development Team, 84 Posts

Hey there, runs on (mt) Media Temple's (gs) Grid Service - which means that many servers share a common set of directories via something like a SAN (Storage Area Network). It did involve some challenges - the biggest one was that because of the specific way the Grid servers are setup, not all directories are shared - basically only the /home directories (where all the site files are stored) was shared. So therefore, whenever you accessed a page, you would get one of (potentially) 100 servers, and the likelihood that this particular server had already cached the templates needed to generate this page was quite unlikely. I ended up hacking sapphire/core/Core.php to change the TEMP_FOLDER definition to be something that was shared across all servers, thus all servers looked in a common place for the template cache.

This might be something that could help you also - I added some notes to [url=]this wiki page on content delivery network issues[/url] which might help you. I had to contact Media Temple to confirm this with them first, but it might be a similar problem to you... or maybe it's the opposite.

Can't be entirely sure without a little more info - are the cache directories shared? How are they shared? Do you have stats on the load balancer - is it one or other of the servers that is slow?


24 April 2008 at 12:36am Community Member, 787 Posts

Hi Matt,

Thanks for the information.

Silly thing is that in my situation , the servers do have their webroot shared, so the silverstripe-cache directory is the same for both. But it just slows down to a near halt once you are logged in and start working in the CMS. The anonymous front-end works perfect.

Do you guys have any other ideas I could try ? ;-)


24 April 2008 at 1:16am Core Development Team, 84 Posts

Ah, so it's the CMS itself that's slow. I'm not really sure what's going on - the CMS does load a lot of very small files, rather than a few big ones, so it's possible that the servers are tuned to not answer requests for lots of files at once for one IP address or something, or the load balancer is slow for many requests at once (unlikely, but it could also be slowing the requests to a more manageable level for the web server)?

I won't be any real help I'm afraid, are you running a custom load balanced solution? If not, what host are you with?


24 April 2008 at 7:13am Community Member, 787 Posts

Hi Matt,

It is a custom solution. Funny thing is , the system works perfectly for a couple of minutes before collapsing.... ;-)

I'm suspicious about the cache and the cookies (I had to use some dirty hacks to get SS working in a subdirectory while having it think it was running in the root, don't ask why ... ;-)

THanks for your help though ! If I ever get it fixed, I'll let you guys know...


12 May 2008 at 1:00pm Community Member, 13 Posts

could you elaborate some more on the lines of code that need hacking. i'm not much of php guy, but after convincing a client to ditch their current host (really bad) for media temple i'm looking a bit red in the face.

i assumed that all instances of $ssTmp need to be modified and tried both:

$ssTmp = "domains/";


$ssTmp = dirname(dirname($_SERVER['SCRIPT_FILENAME'])) . "domains/";

neither seem to be working, or at least i should say neither seem to be adding cached versions of the files to the directory.

Go to Top