Performance optimization for a
TYPO3 website


                 Alexandre Gravel-Raymond, Web developer
                  ...
Plan


I – TYPO3 presentation

II - Performance and limits of standard rendering

III - Solutions
Enterprise level solution

Multilingual, multidomain websites
Workflows
Powerful user rights management
Great importance g...
Typoscript

Tree-based configuration langage (forming templates)

No functions (but references to PHP functions)

No varia...
Criticism about TYPO3


End user: The website seems slow.
Sys admin: The server load can be important on complex
websites....
Performance and limits of
standard rendering
Solutions to the
         performance issues
Three main reflexion areas:
     Code optimization: of course !
     Make the...
Standard cache

TypoScript objects composing a template fits in two
categories :
     Cacheable objects (USER plugins, TEX...
When the requested page is
   not cached yet

Standard (cached) typoscript objects are rendered
Dynamic (_INT) typoscript ...
When the requested page is
   in cache

The cached representation of the page is pulled from the
cache system
Tags represe...
Limits of the cache system


Every request, including those concerning already
cached pages, force the web server to execu...
Solutions
Alternative solution :
   nc_staticfilecache


Extension developed by Netcreators
Some benchmarks show a page delivery spe...
nc_staticfilecache extension



Stores the final document in a static HTML file
This file (if it is present) is directly d...
nc_staticfilecache advantages


Follows standard TYPO3 cache rules (ex: if the cached version of a
page has expired, the c...
Installing nc_staticfilecache


Apache and mod_rewrite are needed
Download and install the extension :
    http://forge.ty...
nc_staticfilecache constraints


POST requests are excluded (to maintain the dynamic
nature of the forms)
All GET paramete...
Architectural solutions


Use Nginx as a reverse proxy to deliver static files
(lighter and quicker than Apache)
Use eAcce...
For dynamic plugins



When the standard cache system doesn't help and
nc_staticfilecache doesn't apply

Use an alternate ...
Further optimization : reduce the
   number of HTTP requests


CSS and JS fusion / minification tools (TYPO3 extensions)

...
Good practices
Good practice #1


Do not deactivate the cache ! When you have cache
problems, refrain from doing this :
   www.example.co...
Good practice #2


Adapt the cache duration to the project
   Ex: At least one day for a typical publication website

Make...
Good practice #3


Audit the extensions you use
With the help of the community…




                       I – TYPO3 prese...
Good practice #4


Uninstall unused extensions (they can load typoscript
or PHP), even if an autoloading mecanism was
intr...
Good practice #5


Lessen the complexity of the typoscript templates
It is possible to accomplish very complex tasks in pu...
Good practice #6

For parts of the website that don't need it, do not use the
full TYPO3 rendering mecanism
     AJAX scri...
Good practice #7


Optimize SQL tables added by your extensions with
well chosen indices, notably if it was automatically
...
Some further reading
http://wiki.typo3.org/index.php/Performance_tuning
http://typo3.org/development/articles/testing-and-...
Upcoming SlideShare
Loading in …5
×

Performance optimization for a TYPO3 website

11,815 views

Published on

Published in: Technology
0 Comments
2 Likes
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total views
11,815
On SlideShare
0
From Embeds
0
Number of Embeds
3
Actions
Shares
0
Downloads
62
Comments
0
Likes
2
Embeds 0
No embeds

No notes for slide

Performance optimization for a TYPO3 website

  1. 1. Performance optimization for a TYPO3 website Alexandre Gravel-Raymond, Web developer a.gravel-raymond@alienor.net Aliénor.net : Bordeaux based Web agency
  2. 2. Plan I – TYPO3 presentation II - Performance and limits of standard rendering III - Solutions
  3. 3. Enterprise level solution Multilingual, multidomain websites Workflows Powerful user rights management Great importance given to retro-compatibility More than 4000 extensions on the TYPO3 Extension Repository (TER) I – TYPO3 presentation II - Performance and limits of standard rendering III - Solutions
  4. 4. Typoscript Tree-based configuration langage (forming templates) No functions (but references to PHP functions) No variable (but the possibility to use a registry for information exchange between parts of the template) I – TYPO3 presentation II - Performance and limits of standard rendering III - Solutions
  5. 5. Criticism about TYPO3 End user: The website seems slow. Sys admin: The server load can be important on complex websites. I – TYPO3 presentation II - Performance and limits of standard rendering III - Solutions
  6. 6. Performance and limits of standard rendering
  7. 7. Solutions to the performance issues Three main reflexion areas: Code optimization: of course ! Make the application lighter: not at the expense of flexibility ! Fine-grained cache : this is the way. I – TYPO3 presentation II - Performance and limits of standard rendering III - Solutions
  8. 8. Standard cache TypoScript objects composing a template fits in two categories : Cacheable objects (USER plugins, TEXT objects, Content Object Array - COA, etc.) Dynamic (non-cacheable) objects (USER_INT plugins, dynamic Content Object Array - COA_INT) I – TYPO3 presentation II - Performance and limits of standard rendering III - Solutions
  9. 9. When the requested page is not cached yet Standard (cached) typoscript objects are rendered Dynamic (_INT) typoscript objects are replaced by specially crafted tags (<!--INT_SCRIPT … >) The result is stored in the cache system (usally the database) A second rendering phase replaces the tags by the corresponding objects' HTML representation The final document is sent to the user I – TYPO3 presentation II - Performance and limits of standard rendering III - Solutions
  10. 10. When the requested page is in cache The cached representation of the page is pulled from the cache system Tags representing dynamic objects are replaced by the objects' HTML representation The final document is sent to the user I – TYPO3 presentation II - Performance and limits of standard rendering III - Solutions
  11. 11. Limits of the cache system Every request, including those concerning already cached pages, force the web server to execute TYPO3. It is (very) resource-intensive I – TYPO3 presentation II - Performance and limits of standard rendering III - Solutions
  12. 12. Solutions
  13. 13. Alternative solution : nc_staticfilecache Extension developed by Netcreators Some benchmarks show a page delivery speed multiplication by 230 ! I – TYPO3 presentation II - Performance and limits of standard rendering III - Solutions
  14. 14. nc_staticfilecache extension Stores the final document in a static HTML file This file (if it is present) is directly delivered by the web server PHP and TYPO3 are not loaded at all ! If the static cache is not found, the standard rendering process is executed I – TYPO3 presentation II - Performance and limits of standard rendering III - Solutions
  15. 15. nc_staticfilecache advantages Follows standard TYPO3 cache rules (ex: if the cached version of a page has expired, the corresponding static file is deleted Possibility to extend static cache delivery rules in a .htaccess file : Ex : Cookie identifying users that must have a dynamic version of the website Possibility to deactivate the static cache on a page-by-page basis I – TYPO3 presentation II - Performance and limits of standard rendering III - Solutions
  16. 16. Installing nc_staticfilecache Apache and mod_rewrite are needed Download and install the extension : http://forge.typo3.org/projects/extension-nc_staticfilecache Add basic rewrite rules given in the example .htaccess file Add a cronjob that points to the script that cleans expired static files (via scheduler) I – TYPO3 presentation II - Performance and limits of standard rendering III - Solutions
  17. 17. nc_staticfilecache constraints POST requests are excluded (to maintain the dynamic nature of the forms) All GET parameters must be rewritten on statically cached pages (with realurl or cooluri extensions) No page containing dynamic (_INT) objects will have static cache One solution to have a dynamic page : make the _INT object static, and use AJAX to render the « personalized » content (use with caution) I – TYPO3 presentation II - Performance and limits of standard rendering III - Solutions
  18. 18. Architectural solutions Use Nginx as a reverse proxy to deliver static files (lighter and quicker than Apache) Use eAccelerator or another PHP op-code cache system to boost PHP performance for dynamic pages and for the first hits of static pages I – TYPO3 presentation II - Performance and limits of standard rendering III - Solutions
  19. 19. For dynamic plugins When the standard cache system doesn't help and nc_staticfilecache doesn't apply Use an alternate cache system Memcached is a « high-performance, distributed memory object caching system » that can help override bottlenecks in an application. Since TYPO3 4.3, you can define an alternate cache backend (file or memcached instead of database) I – TYPO3 presentation II - Performance and limits of standard rendering III - Solutions
  20. 20. Further optimization : reduce the number of HTTP requests CSS and JS fusion / minification tools (TYPO3 extensions) scriptmerger: extensive configuration, possibility to exclude individual files load_optimization: HTML compression, only files added via typoscript are processed js_css_optimizer: uses the new page rendering API, fine- grained configuration file by file Minify: easy to install and use I – TYPO3 presentation II - Performance and limits of standard rendering III - Solutions
  21. 21. Good practices
  22. 22. Good practice #1 Do not deactivate the cache ! When you have cache problems, refrain from doing this : www.example.com/?no_cache=1 $GLOBALS[‘TSFE’]->set_no_cache() ; config.no_cache = 1 (typoscript template) « No cache » checkbox in backend in the page properties form I – TYPO3 presentation II - Performance and limits of standard rendering III - Solutions
  23. 23. Good practice #2 Adapt the cache duration to the project Ex: At least one day for a typical publication website Make TYPO3 clear the cache of affected pages automatically when needed In page TSConfig : TCEMAIN.clearCacheCmd = 1,2,3 I – TYPO3 presentation II - Performance and limits of standard rendering III - Solutions
  24. 24. Good practice #3 Audit the extensions you use With the help of the community… I – TYPO3 presentation II - Performance and limits of standard rendering III - Solutions
  25. 25. Good practice #4 Uninstall unused extensions (they can load typoscript or PHP), even if an autoloading mecanism was introduced in TYPO3 4.3 I – TYPO3 presentation II - Performance and limits of standard rendering III - Solutions
  26. 26. Good practice #5 Lessen the complexity of the typoscript templates It is possible to accomplish very complex tasks in pure typoscript, but sometimes it's more clear to encapsulate the functionnality in a specialized PHP class, and you get more speed at the same time. I – TYPO3 presentation II - Performance and limits of standard rendering III - Solutions
  27. 27. Good practice #6 For parts of the website that don't need it, do not use the full TYPO3 rendering mecanism AJAX script can be externalized with the eID method : www.example.com/index.php?eID=ajax_script Only loads necessary parts of TYPO3 core Do 404 error pages need to be dynamic ? Prefer the standard ErrorDocument method. I – TYPO3 presentation II - Performance and limits of standard rendering III - Solutions
  28. 28. Good practice #7 Optimize SQL tables added by your extensions with well chosen indices, notably if it was automatically created with the Kickstarter I – TYPO3 presentation II - Performance and limits of standard rendering III - Solutions
  29. 29. Some further reading http://wiki.typo3.org/index.php/Performance_tuning http://typo3.org/development/articles/testing-and- tuning-typo3-performance/ http://techblog.evo.pl/en/evo_nginx_boost-extension/ http://www.typofree.org/article/archive/2009/august/ title/enabling-nc-staticfilecache-in-typo3-nginx/ http://typo3.org/development/articles/using-cache- control-headers-in-typo3/

×