eZ Publish 4 performance & Varnish

Author Message

Pablo Pernot

Tuesday 31 March 2009 8:19:39 am

Hi,

I'm using ez 4.0.3 and I'm NOT using ezvlogin
BUT

I added to the index.php


// added rev. 21377 from nextgen: trunk/index.php

        $currentUser = eZUser::currentUser();
        $ini = eZINI::instance();
        $wwwDir = eZSys::wwwDir();
        // On host based site accesses this can be empty, causing the cookie to be set
        //for the current dir,
        // but we want it to be set for the whole eZ publish site
        $cookiePath = $wwwDir != '' ? $wwwDir : '/';

        if ( $currentUser->isLoggedIn() )
        {
             setcookie( 'is_logged_in', 'true', 0, $cookiePath );
             header( 'Etag: ' . $currentUser->attribute( 'contentobject_id' ) );
        }
        else
        {
             setcookie( 'is_logged_in', false, 0, $cookiePath );
        }
// END rev. 21377.


thanks for the help

Pablo Pernot
http://www.smartview.fr
http://www.areyouagile.com

Pablo Pernot

Tuesday 31 March 2009 8:29:54 am

If I put an ugly :

var_dump( $currentUser->isLoggedIn()); 

I noticed I'm first connected (return true) then I redirected to the login page.
Somewhere I lose the connected state.

I also get 2 warnings about session :

session_module_name() [<a href='function.session-module-name'>function.session-module-name</a>]: A session is active. You cannot change the session module's ini settings at this time. in /********/lib/ezutils/classes/ezsession.php on line 319

A session had already been started - ignoring session_start() in /********/lib/ezutils/classes/ezsession.php on line 372

Pablo Pernot
http://www.smartview.fr
http://www.areyouagile.com

Pablo Pernot

Tuesday 31 March 2009 9:39:45 am

Gosh... I get it.

session was at auto-start in php.ini.....

Pablo Pernot
http://www.smartview.fr
http://www.areyouagile.com

Ivo Lukac

Wednesday 13 May 2009 7:03:34 am

Hello everyone,

Just want to share some things which we discovered. We have a web with nice number of visitor so we plan to use varnish for better performance. Problem is that this web has also non-anonymous users. We want to make varnish cache anonymous only. For testing purposes first we upgrade it to eZ 4.1.1 and compiled varnish 2 from source.
Then we configured everything following:
http://ez.no/developer/contribs/documentation/varnish_and_ez_publish_setup_guide

First tests showed that using varnish is much faster of course. On very old and bad PC with virtual ubuntu machine we had about 300 trans/sec (siege test).
Also we verified that 'is_logged_in' cookie introduced in eZ 4.1 functions well with varnish configuration.

Problem was that this setup was not functioning well from the client side: after user logs in client web browser starts to cache (it receives cache and max-age headers ) and then if the user logs out browser is showing that cached pages (with user details).
We considered several solutions:
- to make user details with ajax (to much work),
- to rewrite cache headers for client in varnish (to difficult, we are varnish beginners),
- to use s-maxage header (didn't find any information about how varnish support this),
but none of them was optimal.

So we finally found rather easy solution:
- on eZ side we disabled all custom headers and use default (let varnish do everything and client will receive no-cache headers)
- in varnish configuration we changed order of execution in vcl_fetch like this:

sub vcl_fetch {
        # default time to live for cache objects
        set obj.ttl = 300s;
        if (obj.http.Set-Cookie ~ "is_logged_in=deleted(.*)") {
                deliver;
        }
        if (obj.http.Set-Cookie) {
                pass;
        }
        if (req.request == "GET" && req.url ~ "\.(css|js|gif|jpg|jpeg|bmp|png|ico|wmf|svg|swf|ico|mov|avi|wmv)$") {
                set obj.ttl = 600s;
                deliver;
        }
        if (!obj.cacheable) {
                pass;
        }
        deliver;
}

So noncacheable objects are passed but only after we cache anonymous pages and css, js and multimedia stuff.

We will test this more, but for now it seems to work very nice.

Cheers

http://www.linkedin.com/in/ivolukac
http://www.netgen.hr/eng/blog
http://twitter.com/ilukac

André R.

Wednesday 13 May 2009 7:44:06 am

You can also test using the OnlyForAnonymous setting for http headers, it was introduced in 4.0.2.

[HTTPHeaderSettings]
OnlyForAnonymous=enabled

Logged in users will get default headers instead when this is enabled.

eZ Online Editor 5: http://projects.ez.no/ezoe || eZJSCore (Ajax): http://projects.ez.no/ezjscore || eZ Publish EE http://ez.no/eZPublish/eZ-Publish-Enterprise-Subscription
@: http://twitter.com/andrerom

Ivo Lukac

Wednesday 13 May 2009 10:07:10 am

Khm khm :)

Andre, thanks, I will check it out.
Could be that this is exactly what we need, didn't see that setting before.

http://www.linkedin.com/in/ivolukac
http://www.netgen.hr/eng/blog
http://twitter.com/ilukac

Powered by eZ Publish™ CMS Open Source Web Content Management. Copyright © 1999-2014 eZ Systems AS (except where otherwise noted). All rights reserved.

eZ debug

Timing: Jan 18 2025 14:53:05
Script start
Timing: Jan 18 2025 14:53:05
Module start 'layout'
Timing: Jan 18 2025 14:53:05
Module start 'content'
Timing: Jan 18 2025 14:53:06
Module end 'content'
Timing: Jan 18 2025 14:53:06
Script end

Main resources:

Total runtime0.9880 sec
Peak memory usage4,096.0000 KB
Database Queries67

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0050 588.4453152.6250
Module start 'layout' 0.00500.0027 741.070339.9063
Module start 'content' 0.00770.9789 780.9766634.9141
Module end 'content' 0.98660.0014 1,415.890622.2891
Script end 0.9880  1,438.1797 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.00330.3374160.0002
Check MTime0.00150.1513160.0001
Mysql Total
Database connection0.00070.069410.0007
Mysqli_queries0.900391.1206670.0134
Looping result0.00080.0766650.0000
Template Total0.951096.320.4755
Template load0.00190.193520.0010
Template processing0.949196.056420.4745
Template load and register function0.00010.013110.0001
states
state_id_array0.00110.109610.0011
state_identifier_array0.00200.203420.0010
Override
Cache load0.00160.1660540.0000
Sytem overhead
Fetch class attribute can translate value0.00090.091530.0003
Fetch class attribute name0.00060.064290.0001
XML
Image XML parsing0.00700.705030.0023
class_abstraction
Instantiating content class attribute0.00000.0025120.0000
General
dbfile0.00780.7944300.0003
String conversion0.00000.000640.0000
Note: percentages do not add up to 100% because some accumulators overlap

Templates used to render the page:

UsageRequested templateTemplateTemplate loadedEditOverride
1node/view/full.tplfull/forum_topic.tplextension/sevenx/design/simple/override/templates/full/forum_topic.tplEdit templateOverride template
6content/datatype/view/ezimage.tpl<No override>extension/sevenx/design/simple/templates/content/datatype/view/ezimage.tplEdit templateOverride template
6content/datatype/view/ezxmltext.tpl<No override>extension/community_design/design/suncana/templates/content/datatype/view/ezxmltext.tplEdit templateOverride template
16content/datatype/view/ezxmltags/paragraph.tpl<No override>extension/ezwebin/design/ezwebin/templates/content/datatype/view/ezxmltags/paragraph.tplEdit templateOverride template
7content/datatype/view/ezxmltags/line.tpl<No override>design/standard/templates/content/datatype/view/ezxmltags/line.tplEdit templateOverride template
4content/datatype/view/ezxmltags/literal.tpl<No override>extension/community/design/standard/templates/content/datatype/view/ezxmltags/literal.tplEdit templateOverride template
1print_pagelayout.tpl<No override>extension/community/design/community/templates/print_pagelayout.tplEdit templateOverride template
 Number of times templates used: 41
 Number of unique templates used: 7

Time used to render debug report: 0.0001 secs