Smarty Forum Index Smarty
WARNING: All discussion is moving to https://reddit.com/r/smarty, please go there! This forum will be closing soon.

Upgrade to version 2.63 if you haven't

 
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    Smarty Forum Index -> Testimonials
View previous topic :: View next topic  
Author Message
damastabugz
Smarty Rookie


Joined: 23 Jun 2004
Posts: 5
Location: Brasil

PostPosted: Wed Jun 23, 2004 3:49 am    Post subject: Upgrade to version 2.63 if you haven't Reply with quote

When you're dealing with high numbers, any little thing matters. a site we have running smarty has (twice a year) very high visitation rates, having already hit the 70k unique users/day mark.
If this was a standard 101 basic html site that wouldn't present much of a challenge, but if you have a news site, updated almost every twenty minutes, churning out about 12Giga/day of information, you can guess that any little thing can cause mayhem...
Acutally, don't bother guessing, I'm telling you.
With this many visitors, and a page view number almost 10 times that value, the ammount of concurrent hits to the site is spine chilling.

Through this venture we've learn't a few basic ground rules that might, just might, save your day...

1 - Keep database calls simple and short - Mysql churns up much more processor than php/html does.
2 - Split up your page and only refresh what needs to be resfreshed (sounds obvious, but it takes much more thinking than you might like it to)
3 - when dealing with this kind of volume, NEVER, I repeat NEVER clean up all the cache. Remember, cache is there to be used, it's your friend, don't throw it all away!!

Having said that, if you're using SMARTY 2.6.0, upgrade now to 2.6.3

Version 260 had something I loved about it, it would store all the cache neatly into directories, making everything nice and organized, allowing me to manully erase the files during development. This magnificent feature, unfortunately, turned out to be the one of the things causing my site to hang.
In version 263, smarty does not create those lovely folders anymore, it creates files with long and ugly names in chache.
So you must be asking me... why should I upgrade if it's going to mess up my cache?!
Simple, if you have 1000 users requesting a page to be generated in version 260 simultaneously, smarty would (depending on how you've organized your caching system) create a folder for that page, then another folder inside that folder, and finally the page (or bit of page being cached)
Taking a real example like my page: it had 6 sections cached independantly, eahc within a stucture roughly like, SECTION_NAME/SECION_ID/LANGUAGE_ID.
So for each section of the page, smarty would create: four directories (smarty creates a directory inside LANGUAGE_ID), plus a file. That's five system calls for a section!!!!
Multiply that by the six sections of the page and you get 30 system calls, now multiply that by 1000 users and you get the astinishing 30k system calls just under a second!!!! Enough to crash even the best configured apache.
Smarty 6.3.2, uses now a file naming system as oposed to the directories, so suddenly, my 30.000 calls have become 6000, 1/5 of what we had before (and much less stressfull for the server).

Please note, that's one of the modifications I've found out on 263, it's not an ultimate guide to the truth about smarty, but, it worked for me, and might just work for you.
Back to top
View user's profile Send private message Visit poster's website
messju
Administrator


Joined: 16 Apr 2003
Posts: 3336
Location: Oldenburg, Germany

PostPosted: Wed Jun 23, 2004 8:19 am    Post subject: Reply with quote

just FYI the behaviour of auto-filename-creation (for templates_c and cache) can be changed with $smarty->use_sub_dirs

Smarty has this feature for ages, since 2.6.2 Smarty just shipped with $use_sub_dirs set false, where older version had true as default value for that option.

The main reason for changing the default to false was that people always had problems with safe_mode=enabled and use_sub_dirs=true. many of them didn't even know what "safe_mode" or "use_sub_dirs" is. so we changed the default to false to get people startet without knowing the existance of use_sub_dirs (and let them tweak that value if they like when they are more experienced).

It's nice to hear that this change also enhanced the stability of your site under hight loads.
Back to top
View user's profile Send private message Send e-mail Visit poster's website
mohrt
Administrator


Joined: 16 Apr 2003
Posts: 7368
Location: Lincoln Nebraska, USA

PostPosted: Wed Jun 23, 2004 2:24 pm    Post subject: Reply with quote

For a small number of files this may work, but larger numbers and you'll start seeing other performance problems.

Every time a file needs to be opened, the directory is opened and the filename is searched for. With 10,000+ files in a single directory, that takes time to scan. This will likely clear the file system directory cache, slowing things even more. That is where dividing the files into sub-directories will actually help performance.

Of course a lot is dependent on your file system and how it handles its access to files. Your best bet is to try it both ways and run some benchmarks.
Back to top
View user's profile Send private message Visit poster's website
Display posts from previous:   
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    Smarty Forum Index -> Testimonials All times are GMT
Page 1 of 1

 
Jump to:  
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
Protected by Anti-Spam ACP