|
Smarty
WARNING: All discussion is moving to https://reddit.com/r/smarty, please go there! This forum will be closing soon. |
|
View previous topic :: View next topic |
Author |
Message |
rudder Smarty Rookie
Joined: 20 Oct 2009 Posts: 14
|
Posted: Tue Mar 30, 2010 12:14 am Post subject: NFS templates_c and high traffic solutions for compiling tpl |
|
|
In a continuation of a post I made to a thread about compile times being problematic in high traffic sites, it was suggested that I use NFS mounted templates_c. Here are some quotes:
moneysack wrote: | @rudder:
With the complex Lexer/Parser of Smarty3, on a High-Load Website, this is not a good Idea.
I think the best is, to share the whole Web-Directory (with templates_c etc.) with NFS or something. Now you can run the Method compileAllTemplates() from any server.
The only Problem is that you need more Redundancy and maybe some sort of High-Availability Software.
|
mohrt wrote: |
I use NFS to share both templates and compiled templates. It works a bit better on the maintenance side. You do incur the overhead of NFS networking, but since NFS can hold a (short) cache on the client side, it is pretty negligible. |
In our setup we've been trying to move away from NFS because it becomes a single point of failure. We recently had a problem where our NFS server crashed and was permanently disabled: for 10hrs we had to test, and replace the NFS, during which 5 webservers became unaccessible - we had to manually change code to work around the NFS being missing to cut down the total downtime.
The only solution to a single point of failure NFS mount that we can come up with appears to be a monolithic highly redundant NFS server (multiple PSUs, good RAID, etc etc) but even then it seems that RAM can fail, motherboards can die, CPUs get old, the NFS network connection could become flaky etc) and then have a hot standby of that NFS server.
Are there any other suggestions?
We've been moving more and more away from NFS and instead relying on rsync to synchronize configs etc amongst all servers so that we're not crippled by NFS problems. I had initially proposed the following:
rudder wrote: |
I wonder if the following is practical:
- push files to deployment server
- Run compileAllTemplate() utility
- rsync templates + templates_c to production servers
Previously our deployment method using Smarty2 is to:
- push files to deployment server
- rsync templates to production server, but EXCLUDE templates_c and let each serve recompile.
|
But it seems that nobody would use such a method. |
|
Back to top |
|
emt Smarty Regular
Joined: 10 Dec 2009 Posts: 43
|
Posted: Tue Mar 30, 2010 12:59 pm Post subject: |
|
|
I have worked with high load servers before using rsync extensively, and I cannot see any problems with your proposed method. The only thing you have to be careful about is that the paths to the templates, templates_c and cache are identical on each individual server.
I would also be careful about the order you push updates - if you push "templates" first then you could easily trigger a template recompile if you have compile checking on.
I would advise that on the production servers you have compile_check turned off - it shouldn't be needed in production anyway if you compile all the templates on the deployment server. Also, rsync by default deletes before transfer which again could trigger a compile from a template that is supposed to be removed.
I would modify your proposed method slightly:
* Push files to DEPLOYMENT server
* Delete everything in templates_c on DEPLOYMENT
* Compile All Templates
* rsync to PRODUCTION with "rsync -a --delete-after"
Make sure you preserve timestamps etc (I would use '-a' option on rsync if your usernames and group names are consistent across all environments as well).
Should work a treat. |
|
Back to top |
|
mohrt Administrator
Joined: 16 Apr 2003 Posts: 7368 Location: Lincoln Nebraska, USA
|
Posted: Tue Mar 30, 2010 2:00 pm Post subject: |
|
|
Everything is a give and take. rsync requires more management. NFS is technically a single point of failure, but this can be rectified with RAID drives and a stable OS and redundant hardware components. I have an NFS server that has run for many years without trouble. Be sure you run NFS on a fast (gigabit+) network with UDP as protocol for minimal network overhead.
You can also create a hot failover for NFS with DRDB.
http://www.howtoforge.com/high_availability_nfs_drbd_heartbeat |
|
Back to top |
|
emt Smarty Regular
Joined: 10 Dec 2009 Posts: 43
|
Posted: Tue Mar 30, 2010 5:49 pm Post subject: |
|
|
rsync can definitely be more management, but on the other side NFS can give you problems that are VERY hard to detect and troubleshoot sometimes.
I would suggest that your PHP routine that calls the compile all templates also executes the rsync automatically afterwards to remove synchronisation issues. |
|
Back to top |
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|