performance optimization for a typo3 website

29
Performance optimization for a TYPO3 website Alexandre Gravel-Raymond, Web developer [email protected] Aliénor.net : Bordeaux based Web agency

Upload: alienornet

Post on 08-May-2015

9.502 views

Category:

Technology


1 download

TRANSCRIPT

Page 1: Performance optimization for a TYPO3 website

Performance optimization for a TYPO3 website

Alexandre Gravel-Raymond, Web [email protected]

Aliénor.net : Bordeaux based Web agency

Page 2: Performance optimization for a TYPO3 website

Plan

I – TYPO3 presentation

II - Performance and limits of standard rendering

III - Solutions

Page 3: Performance optimization for a TYPO3 website

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 presentationII - Performance and limits of standard rendering

III - Solutions

Enterprise level solution

Page 4: Performance optimization for a TYPO3 website

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)

Typoscript

I – TYPO3 presentationII - Performance and limits of standard rendering

III - Solutions

Page 5: Performance optimization for a TYPO3 website

End user: The website seems slow.

Sys admin: The server load can be important on complex

websites.

Criticism about TYPO3

I – TYPO3 presentationII - Performance and limits of standard rendering

III - Solutions

Page 6: Performance optimization for a TYPO3 website

Performance and limits of standard rendering

Page 7: Performance optimization for a TYPO3 website

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.

Solutions to the performance issues

I – TYPO3 presentationII - Performance and limits of standard rendering

III - Solutions

Page 8: Performance optimization for a TYPO3 website

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)

Standard cache

I – TYPO3 presentationII - Performance and limits of standard rendering

III - Solutions

Page 9: Performance optimization for a TYPO3 website

Standard (cached) typoscript objects are renderedDynamic (_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 representationThe final document is sent to the user

When the requested page is not cached yet

I – TYPO3 presentationII - Performance and limits of standard rendering

III - Solutions

Page 10: Performance optimization for a TYPO3 website

The cached representation of the page is pulled from the cache systemTags representing dynamic objects are replaced by the objects' HTML representationThe final document is sent to the user

When the requested page is in cache

I – TYPO3 presentationII - Performance and limits of standard rendering

III - Solutions

Page 11: Performance optimization for a TYPO3 website

Every request, including those concerning already

cached pages, force the web server to execute

TYPO3.

It is (very) resource-intensive

Limits of the cache system

I – TYPO3 presentationII - Performance and limits of standard rendering

III - Solutions

Page 12: Performance optimization for a TYPO3 website

Solutions

Page 13: Performance optimization for a TYPO3 website

Extension developed by Netcreators

Some benchmarks show a page delivery speed

multiplication by 230 !

Alternative solution : nc_staticfilecache

I – TYPO3 presentationII - Performance and limits of standard rendering

III - Solutions

Page 14: Performance optimization for a TYPO3 website

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

nc_staticfilecache extension

I – TYPO3 presentationII - Performance and limits of standard rendering

III - Solutions

Page 15: Performance optimization for a TYPO3 website

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

nc_staticfilecache advantages

I – TYPO3 presentationII - Performance and limits of standard rendering

III - Solutions

Page 16: Performance optimization for a TYPO3 website

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)

Installing nc_staticfilecache

I – TYPO3 presentationII - Performance and limits of standard rendering

III - Solutions

Page 17: Performance optimization for a TYPO3 website

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 cacheOne solution to have a dynamic page : make the _INT object static, and use AJAX to render the « personalized » content (use with caution)

nc_staticfilecache constraints

I – TYPO3 presentationII - Performance and limits of standard rendering

III - Solutions

Page 18: Performance optimization for a TYPO3 website

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

Architectural solutions

I – TYPO3 presentationII - Performance and limits of standard rendering

III - Solutions

Page 19: Performance optimization for a TYPO3 website

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

Use an alternate cache systemMemcached 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)

For dynamic plugins

I – TYPO3 presentationII - Performance and limits of standard rendering

III - Solutions

Page 20: Performance optimization for a TYPO3 website

CSS and JS fusion / minification tools (TYPO3 extensions)

scriptmerger: extensive configuration, possibility to exclude individual filesload_optimization: HTML compression, only files added via typoscript are processedjs_css_optimizer: uses the new page rendering API, fine-grained configuration file by fileMinify: easy to install and use

Further optimization : reduce the number of HTTP requests

I – TYPO3 presentationII - Performance and limits of standard rendering

III - Solutions

Page 21: Performance optimization for a TYPO3 website

Good practices

Page 22: Performance optimization for a TYPO3 website

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

Good practice #1

I – TYPO3 presentationII - Performance and limits of standard rendering

III - Solutions

Page 23: Performance optimization for a TYPO3 website

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

Make TYPO3 clear the cache of affected pages

automatically when neededIn page TSConfig : TCEMAIN.clearCacheCmd = 1,2,3

Good practice #2

I – TYPO3 presentationII - Performance and limits of standard rendering

III - Solutions

Page 24: Performance optimization for a TYPO3 website

Audit the extensions you use

With the help of the community…

Good practice #3

I – TYPO3 presentationII - Performance and limits of standard rendering

III - Solutions

Page 25: Performance optimization for a TYPO3 website

Uninstall unused extensions (they can load typoscript

or PHP), even if an autoloading mecanism was

introduced in TYPO3 4.3

Good practice #4

I – TYPO3 presentationII - Performance and limits of standard rendering

III - Solutions

Page 26: Performance optimization for a TYPO3 website

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.

Good practice #5

I – TYPO3 presentationII - Performance and limits of standard rendering

III - Solutions

Page 27: Performance optimization for a TYPO3 website

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_scriptOnly loads necessary parts of TYPO3 core

Do 404 error pages need to be dynamic ? Prefer the

standard ErrorDocument method.

Good practice #6

I – TYPO3 presentationII - Performance and limits of standard rendering

III - Solutions

Page 28: Performance optimization for a TYPO3 website

Optimize SQL tables added by your extensions with

well chosen indices, notably if it was automatically

created with the Kickstarter

Good practice #7

I – TYPO3 presentationII - Performance and limits of standard rendering

III - Solutions

Page 29: Performance optimization for a TYPO3 website

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/