Skip to the content
Documentation
Help Start
Reading in:
  • German: 9,059 of 9,059 pages
About the help in other languages
All help pages

Performance in extensions

Keep an extension fast and safe under persistent workers: count queries, fetch with limits, cache, keep listeners cheap, measure, and never keep request state in statics.

Download as PDF

Address: https://doc.exponential.earth/exphelp/viewer/help/extension-development/part-3-extension-developer/performance-in-extensions.md

On this page

Performance in extensions

Part 3, chapter 36. An extension can make every page of a site slower: a listener on response/output, an operator in the pagelayout, a fetch in a loop. This chapter lists the usual causes and the tools that find them.

Measure first

ToolShows
The debug bar's timing tablehow long each part of a request took
[DatabaseSettings] SQLOutput=enabledevery query of a page; count them
{debug-timing-point id='...'}...{/debug-timing-point}the time of one part of a template
./console exp:benchmarkpage timings over HTTP, A/B between two servers, kernel probes, a regression check against a baseline (Benchmarking)

Measure the page before and after you switch your extension on; the difference is what it costs.

Database

  • Count queries. A page that runs the same query once per list item has a loop that should fetch once.
  • Fetch with limits and filters; never load a whole subtree to count it (subTreeCountByNodeID() and the _count fetch functions count in the database).
  • Do not load attributes you do not use: load_data_map false() for lists of names.
  • Index your own tables on the columns you query by.

Caching

LevelUse
The content view cachecontent views are cached already; do not defeat it by printing per-user data inside a full view template
cache-blockexpensive parts of the pagelayout: menus, footers (Caching and templates)
Your own cacheresults of slow work (an external API): store them in a cache file under the cache directory, or use the cluster file handler, with an expiry; clear them when your data changes
The view cache keyswhen a view's output depends on something new, add it with the content/view/cachekeys filter rather than switching caching off

Listeners and operators on every page

response/output, request/input and operators in the pagelayout run on every request. Keep them to a few microseconds: no database, no file reads, no network. Do the work elsewhere and store the result.

Persistent workers (Velocity)

Velocity, the recommended application server, keeps PHP processes alive between requests. That makes the kernel fast, and it changes the rules for your code:

  • No request state in statics. A worker puts every class's statics back between requests, but code that relies on a static being empty at the start of a request should not exist: compute per request, or key the value by request.

  • Register once per request with a request key, not with a true flag, as the Velocity documentation shows:

    if ( self::$registered !== eZExecution::requestKey() )
    {
        self::$registered = eZExecution::requestKey();
        register_shutdown_function( array( __CLASS__, 'flush' ) );
    }
  • New classes need a restart of the workers. After deploying new code, ./console exp:velocity deploy regenerates autoloads, clears caches and restarts the workers.

  • Never wrap a download plus eZExecution::cleanExit() in catch ( Exception ): under Velocity the clean exit throws to end the request.

See Velocity: running Exponential in a persistent-worker web server.

Front end

  • Load scripts and styles through the packer (one bundle, cached, with the time stamp in the name).
  • Require page-specific scripts with ezscript_require on that page only.
  • Images through image aliases, not full originals.

Become an Exponential Partner

Partners share their information, provide funding, contribute back and develop the products with us, and that is how Exponential grows. A partner website and dashboard are planned for mid-2027: please become a partner today to speed up our growth rate and land new features faster.

Something wrong on this page? Report an error

Documentation license

This documentation is free documentation, licensed under the GNU Free Documentation License 1.3 or later.

Exponential Copyright © 1998-2026 Exponential Foundation and 7x