diff options
Diffstat (limited to 'demos/quickstart/protected/pages/Advanced/Performance.page')
-rw-r--r-- | demos/quickstart/protected/pages/Advanced/Performance.page | 77 |
1 files changed, 77 insertions, 0 deletions
diff --git a/demos/quickstart/protected/pages/Advanced/Performance.page b/demos/quickstart/protected/pages/Advanced/Performance.page index d1c5a49c..5aee4a9b 100644 --- a/demos/quickstart/protected/pages/Advanced/Performance.page +++ b/demos/quickstart/protected/pages/Advanced/Performance.page @@ -1,5 +1,82 @@ <com:TContent ID="body" >
<h1>Performance Tuning</h1>
+<p>
+Performance of Web applications is affected by many factors. Database access, file system operations, network bandwidth are all potential affecting factors. PRADO tries in every effort to reduce the performance impact caused by the framework.
+</p>
+
+<h2>Caching</h2>
+<p>
+PRADO provides a generic caching technique used by in several core parts of the framework. For example, when caching is enabled, <tt>TTemplateManager</tt> will save parsed templates in cache and reuse them in the following requests, which saves time for parsing templates. The <tt>TThemeManager</tt> adopts the similar strategy to deal with theme parsing.
+</p>
+<p>
+Enabling caching is very easy. Simply add the cache module in the application configuration, and PRADO takes care of the rest.
+</p>
+<com:TTextHighlighter Language="xml" CssClass="source">
+<modules>
+ <module id="cache" class="System.Data.TSqliteCache" />
+</modules>
+</com:TTextHighlighter>
+
+<p>
+Developers can also take advantage of the caching technique in their applications. The <tt>Cache</tt> property of <tt>TApplication</tt> returns the plugged-in cache module when it is available. To save and retrieve a data item in cache, use the following commands,
+</p>
+<com:TTextHighlighter CssClass="source">
+if($application->Cache) {
+ // saves data item in cache
+ $application->Cache->set($keyName,$dataItem);
+ // retrieves data item from cache
+ $dataItem=$application->Cache->get($keyName);
+}
+</com:TTextHighlighter>
+<p>
+where <tt>$keyName</tt> should be a string that uniquely identifies the data item stored in cache.
+</p>
+
+<h2>Using <tt>pradolite.php</tt></h2>
+<p>
+Including many PHP script files may impact application performance significantly. PRADO classes are stored in different files and when processing a page request, it may require including tens of class files.To alleviate this problem, in each PRADO release, a file named <tt>pradolite.php</tt> is also included. The file is a merge of all core PRADO class files whose comments are also stripped off.
+</p>
+<p>
+To use <tt>pradolite.php</tt>, in your application entry script, replace the inclusion of <tt>prado.php</tt> with <tt>pradolite.php</tt>.
+</p>
+
+<h2>Changing Application Mode</h2>
+<p>
+Application mode also affects application performance. A PRADO application can be in one of the following modes: <tt>Off</tt>, <tt>Debug</tt>, <tt>Normal</tt> and <tt>Performance</tt>. The <tt>Debug</tt> mode should mainly be used during application development, while <tt>Normal</tt> mode is usually used in early stage after an application is deployed to ensure everything works correctly. After the application is proved to work stably for some period, the mode can be switched to <tt>Performance</tt> to further improve the performance.
+</p>
+<p>
+The difference between <tt>Debug</tt>, <tt>Normal</tt> and <tt>Performance</tt> modes is that under <tt>Debug</tt> mode, application logs will contain debug information, and under <tt>Performance</tt> mode, timestamp checking is not performed for cached templates and published assets. Therefore, under <tt>Performance</tt> mode, application may not run properly if templates or assets are modified. Since <tt>Performance</tt> mode is mainly used when an application is stable, change of templates or assets are not likely.
+</p>
+<p>
+To switch application mode, configure it in application configuration:
+</p>
+<com:TTextHighlighter Language="xml" CssClass="source">
+<application Mode="Performance" >
+ ......
+</application >
+</com:TTextHighlighter>
+
+<h2>Reduce Page Size</h2>
+<p>
+By default, PRADO stores page state in hidden fields of the HTML output. The page state could be very large in size if complex controls, such as <tt>TDataGrid</tt>, is used. To reduce the size of the network transmitted page size, two strategies can be used.
+<p>
+First, you may disable viewstate by setting <tt>EnableViewState</tt> to false for the page or some controls on the page if they do not need user interactions. Viewstate is mainly used to keep track of page state when a user interacts with that page.
+</p>
+<p>
+Second, you may use a different page state storage. For example, page state may be stored in session, which essentially stores page state on the server side and thus saves the network transmission time. The module responsible for page state storage is <tt>System.Web.UI.TPageStatePersister</tt>, which uses hidden fields as persistent storage. To use your own storage, configure the module in application configuration as follows,
+</p>
+<com:TTextHighlighter Language="xml" CssClass="source">
+<service id="page" class="TPageService">
+ <modules>
+ <module id="state" class="MyPageStatePersister" />
+ </modules>
+</service>
+</com:TTextHighlighter>
+
+<h2>Other Techniques</h2>
+<p>
+Server caching techniques are proven to be very effective in improving the performance of PRADO applications. For example, we have observed that by using Zend Optimizer, the RPS (request per second) of a PRADO application can be increased by more than ten times. Of course, this is at the cost of stale output, while PRADO's caching techniques always ensure the correctness of the output.
+</p>
</com:TContent>
\ No newline at end of file |