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

Smarty's Perfomance on High Load traffics

 
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 -> General
View previous topic :: View next topic  
Author Message
sangprabv
Smarty Rookie


Joined: 14 Feb 2005
Posts: 13
Location: Jakarta

PostPosted: Mon Dec 14, 2015 10:16 am    Post subject: Smarty's Perfomance on High Load traffics Reply with quote

This maybe already thousands time questioned. How stable Smarty on a high load traffics site? My daily page views is around 20-30 millions per day. And still looking for the best solution. And I would like to thanks for any fine tuning tips
Back to top
View user's profile Send private message Visit poster's website Yahoo Messenger MSN Messenger
elpmis
Smarty Elite


Joined: 07 Jun 2007
Posts: 321

PostPosted: Mon Dec 14, 2015 2:09 pm    Post subject: Reply with quote

How often is the content of your site changed?

An option could be to deactivate template parsing, another thing the use of solutions like memcache...
Back to top
View user's profile Send private message
AnrDaemon
Administrator


Joined: 03 Dec 2012
Posts: 1785

PostPosted: Mon Dec 14, 2015 5:07 pm    Post subject: Reply with quote

@elpmis, Disabling compile_check in production is a recommended course of action.

@sangprabv, I feel this is not a question of "stability", but of your architecture design.
Smarty lets you finely control the caching of various aspects of your webpages. The way you implement it will be the answer to your question.
Back to top
View user's profile Send private message
sangprabv
Smarty Rookie


Joined: 14 Feb 2005
Posts: 13
Location: Jakarta

PostPosted: Tue Dec 15, 2015 12:54 am    Post subject: Reply with quote

@elpmis it's a news portal, we have 500+ new article every day

@anrdaemon, yes agree with the architecture design. do you have any tips for the effective and scalable one?
Back to top
View user's profile Send private message Visit poster's website Yahoo Messenger MSN Messenger
U.Tews
Administrator


Joined: 22 Nov 2006
Posts: 5068
Location: Hamburg / Germany

PostPosted: Tue Dec 15, 2015 1:53 am    Post subject: Reply with quote

@sangprabv If your templates are stable and do not change you may set
$smarty->compile_check = false;
But remember if you change a template after that you must manually empty the compiled and cache folders after the change to ensure that it get recompiled.

A big performance boost is setting $smarty->merge_compiled_includes = true;
Smarty will then merge all the code of {$include} sub-templates in the compiled template file of the main template. So Smarty has to load just one file.

Most performance you will gain if you enable caching.
But if you call the same template for different contents like your news page you must use different cache_id's to identify the content.
With 500+ articles a day some care must by taken to build cache_id's which will not screw up the file system.
When you use caching you must assign template variables like the your news text only if the cache is invalid which can be check with $smarty->isCached(). This will save the time for database access assuming you have your news text in a database.
If you are interested I can give you some more detailed hints.

Enable an PHP cache like Opcache or ACP.

@elpmis using memcache must not have necessarily have better performance as the file system as it can not make use of a PHP op code cache like at the file system. The loaded template must be evaled each time.
Back to top
View user's profile Send private message
sangprabv
Smarty Rookie


Joined: 14 Feb 2005
Posts: 13
Location: Jakarta

PostPosted: Tue Dec 15, 2015 2:02 am    Post subject: Reply with quote

@u.tews thanks for the tips, yes I need your advice in term of caching. Currently I have implemented

Code:

$smarty->setCacheDir($_SERVER['DOCUMENT_ROOT'].'/cache');
$smarty->setCaching(Smarty::CACHING_LIFETIME_SAVED);
$smarty->setCacheLifetime(3);


The other settings are still default.
And also how about the PHP cache things? Thanks again
Back to top
View user's profile Send private message Visit poster's website Yahoo Messenger MSN Messenger
U.Tews
Administrator


Joined: 22 Nov 2006
Posts: 5068
Location: Hamburg / Germany

PostPosted: Tue Dec 15, 2015 3:05 am    Post subject: Reply with quote

sangprabv wrote:
Code:

$smarty->setCacheDir($_SERVER['DOCUMENT_ROOT'].'/cache');
$smarty->setCaching(Smarty::CACHING_LIFETIME_SAVED);
$smarty->setCacheLifetime(3);



The above alone does not make to much sense or could cause problems that sometime wrong content may be displayed.
As I don't now your application in detail I can just make assumptions.

First you should identify which pages show content which is dependent of user selections like selected news message.

Which pages are completely static.

Which pages are almost static and have just some variable sections which must be updated on each call, which need an update in longer intervals like minutes, hours, days.

For all cases Smarty offers solutions to improve performance.
Back to top
View user's profile Send private message
sangprabv
Smarty Rookie


Joined: 14 Feb 2005
Posts: 13
Location: Jakarta

PostPosted: Tue Dec 15, 2015 3:38 am    Post subject: Reply with quote

Any example of the static and dynamic implementation?
Back to top
View user's profile Send private message Visit poster's website Yahoo Messenger MSN Messenger
AnrDaemon
Administrator


Joined: 03 Dec 2012
Posts: 1785

PostPosted: Tue Dec 15, 2015 10:48 pm    Post subject: Reply with quote

Your question doesn't make much sense, but I'll try to explain.
I would not recommend merging includes, but rather use template extension (it effectively have the effect of merging includes without the drawbacks), and focus on caching as a means to reduce load on your site.
There's at least two approaches to caching specifically.
If your site is generally public, you can just use a front caching server like varnish and sleep happily.
If your site has private blocks, you need a more discreet solution.
How am I doing it for myself, I have a main template, which {include}s everything that is not website contents (global navigation, user status block, etc.), and small content templates that {extend} the main template. The end result is such that I have a bunch of 6h cached content pages, which include separate blocks of different purpose with different caching times. Each block is a meaningful presentation entity. Catalog tree state. User status block. Announce slider. Etc. Assembling a page from these cached blocks is fast. Most time spent on checking user status and access rights, even then, that data is cached for several seconds, and if a user would fall asleep on F5, the load on server would not rise to the sky.
Back to top
View user's profile Send private message
sangprabv
Smarty Rookie


Joined: 14 Feb 2005
Posts: 13
Location: Jakarta

PostPosted: Wed Dec 16, 2015 1:39 am    Post subject: Reply with quote

@anrdaemon many thanks and sorry for unclear question. My site is mostly public use but some with private blocks. What do you mean with template extension? Would you explain me and how it works also the benefits merging includes vs template extension? Thanks
Back to top
View user's profile Send private message Visit poster's website Yahoo Messenger MSN Messenger
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 -> General 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