Performance Tuneup

Before we deploy our blog system, we would like to tuneup the system performance.

Changing Application Mode

A PRADO application may be configured to run in different mode. By default, it runs in debug mode which generates a lot of log messages and in case of errors, it displays full call stack of the error places. Such behavior is preferrable during development, but not so if the system is in production. To change the application mode from Debug to Normal (meaning production mode), we modify the application configuration as follows:

......

Enabling Caching

There are a lot of parsing work involved in a PRADO application: configuration XMLs, templates, theme skins, etc. For every user request, PRADO needs to redo the parsing. To save this effort, we can enable caching. To do so, we modify the application configuration as follows,

...... ...... ...... ......

Now after accessing any page in our blog system, we shall be able to find a file named sqlite3.cache. This is the database file that keeps the parsed page templates, configurations, etc.

The cache module we just enabled uses database as persistent cache medium. PRADO also has other cache modules using faster cache medium, such as TMemCache, TAPCCache. They require installation of the corresponding PHP extensions.

Using pradolite.php

Running a PRADO page involves including tens of PHP files, which could be very time-consuming. These files also carry a lot of comments for generating user-friendly API documentation. In order to reduce this cost, we modify index.php and replace the inclusion of prado.php with pradolite.php. The latter is a big file generated by merging necessary PRADO code files and stripping out comments. We thus modify index.php as follows,

Other Techniques

There are other techniques to further improve the performance of a PRADO application. According to our experience, one of the bottlenecks in a Web application is the database tier. The database queries often take a long time to complete, which greatly degrades the response time of a page request. Caching is the main solution for this problem. The cache module enabled in our application configuration can also be used for this purpose.

For a page that is relatively stable yet frequently accessed, output caching should be considered. Output caching caches the HTML output of selected portions of a page. This may improve the performance of the cached pages significantly.

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.