Forums / Developer / eZ Publish 4 performance & Varnish

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

eZ debug

Timing: Jan 18 2025 10:20:38
Script start
Timing: Jan 18 2025 10:20:38
Module start 'content'
Timing: Jan 18 2025 10:20:38
Module end 'content'
Timing: Jan 18 2025 10:20:38
Script end

Main resources:

Total runtime0.2947 sec
Peak memory usage2,048.0000 KB
Database Queries141

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0139 589.6719180.8281
Module start 'content' 0.01390.0216 770.5000106.4063
Module end 'content' 0.03540.2591 876.9063537.3281
Script end 0.2946  1,414.2344 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.00602.0398200.0003
Check MTime0.00260.8697200.0001
Mysql Total
Database connection0.00371.261610.0037
Mysqli_queries0.202168.58631410.0014
Looping result0.00160.53331390.0000
Template Total0.258287.610.2582
Template load0.00240.807910.0024
Template processing0.255886.798510.2558
Override
Cache load0.00200.691510.0020
Sytem overhead
Fetch class attribute can translate value0.00100.355310.0010
XML
Image XML parsing0.00030.113710.0003
General
dbfile0.01635.5413200.0008
String conversion0.00000.002130.0000
Note: percentages do not add up to 100% because some accumulators overlap

CSS/JS files loaded with "ezjscPacker" during request:

CacheTypePacklevelSourceFiles
CSS0extension/community/design/community/stylesheets/ext/jquery.autocomplete.css
extension/community_design/design/suncana/stylesheets/scrollbars.css
extension/community_design/design/suncana/stylesheets/tabs.css
extension/community_design/design/suncana/stylesheets/roadmap.css
extension/community_design/design/suncana/stylesheets/content.css
extension/community_design/design/suncana/stylesheets/star-rating.css
extension/community_design/design/suncana/stylesheets/syntax_and_custom_tags.css
extension/community_design/design/suncana/stylesheets/buttons.css
extension/community_design/design/suncana/stylesheets/tweetbox.css
extension/community_design/design/suncana/stylesheets/jquery.fancybox-1.3.4.css
extension/bcsmoothgallery/design/standard/stylesheets/magnific-popup.css
extension/sevenx/design/simple/stylesheets/star_rating.css
extension/sevenx/design/simple/stylesheets/libs/fontawesome/css/all.min.css
extension/sevenx/design/simple/stylesheets/main.v02.css
extension/sevenx/design/simple/stylesheets/main.v02.res.css
JS0extension/ezjscore/design/standard/lib/yui/3.17.2/build/yui/yui-min.js
extension/ezjscore/design/standard/javascript/jquery-3.7.0.min.js
extension/community_design/design/suncana/javascript/jquery.ui.core.min.js
extension/community_design/design/suncana/javascript/jquery.ui.widget.min.js
extension/community_design/design/suncana/javascript/jquery.easing.1.3.js
extension/community_design/design/suncana/javascript/jquery.ui.tabs.js
extension/community_design/design/suncana/javascript/jquery.hoverIntent.min.js
extension/community_design/design/suncana/javascript/jquery.popmenu.js
extension/community_design/design/suncana/javascript/jScrollPane.js
extension/community_design/design/suncana/javascript/jquery.mousewheel.js
extension/community_design/design/suncana/javascript/jquery.cycle.all.js
extension/sevenx/design/simple/javascript/jquery.scrollTo.js
extension/community_design/design/suncana/javascript/jquery.cookie.js
extension/community_design/design/suncana/javascript/ezstarrating_jquery.js
extension/community_design/design/suncana/javascript/jquery.initboxes.js
extension/community_design/design/suncana/javascript/app.js
extension/community_design/design/suncana/javascript/twitterwidget.js
extension/community_design/design/suncana/javascript/community.js
extension/community_design/design/suncana/javascript/roadmap.js
extension/community_design/design/suncana/javascript/ez.js
extension/community_design/design/suncana/javascript/ezshareevents.js
extension/sevenx/design/simple/javascript/main.js

Templates used to render the page:

UsageRequested templateTemplateTemplate loadedEditOverride
1pagelayout.tpl<No override>extension/sevenx/design/simple/templates/pagelayout.tplEdit templateOverride template
 Number of times templates used: 1
 Number of unique templates used: 1

Time used to render debug report: 0.0001 secs