hi,

following discussions @ the high-perf group, etc. i've deployed a pound/ssl -> varnish -> apache2 -> pressflow6. perf improvements, compared to "just" drupal6 -> apache2/ssl are fairly dramatic.

i'm now considering Parallel (maybe 'real' CDN?) as a possible next-tweak.

atm, varnish is setup to generally always cache images & multimedia, CSS & javascript, and static files, as well as 'everything in most of the standard drupal directories, *.txt and *.ico'.

does this caching by varnish interfere with, or negate, the advantages Parallel provides? if so, what'd be the right 'mix' of config?

thanks!

Comments

mikeytown2’s picture

Varnish is in front of your web server, so if varnish is setup to cache the subdomains then it should work flawlessly.

PGNetDev’s picture

> it should work flawlessly.
great. makes sense to me if all the domains are http://.

if (www.)example.com is exposed @pound as https://...:443, with a cert installed as usual, then, if i wanted to ensure that all content is served only via ssl (so as to avoid the 'some content is not secure' browser warnings ...) each of cdn{1,2,3}.example.com -- facing outward from pound -- would need their own legitimate certs as well (or share a wildcard), correct?

iiuc -- and i realize i may be looking at this all wrong -- with Parallel's multiple (3) subdomains added to the picure, i've now got to properly 'route' among:

multiple listeners, certs & backends @pound
one (or multiple?) caches in varnish
multiple vhosts (main + 1 per subdomain) in apache

do you, perchance, know of a example config for a similar scenario?

thanks.

mikeytown2’s picture

A wildcard cert for https would be the best option IMHO. Be sure to test before buying; in spite of the advice from Google & Yahoo, sometimes this will make the site take longer to download. It really depends on your setup. Testing is key; use wireshark to test in browsers that don't have a plugin that provides waterfalls. Browsers that don't follow HTTP/1.1 (most modern ones), will probably not benefit.

I don't have a config for you. Long story short make the sub domains point to the webroot.

www.example.com
example.com
cdn1.example.com
cdn2.example.com
cdn3.example.com

These all go to the same directory on your server.

PGNetDev’s picture

hi,

> A wildcard cert for https would be the best option IMHO.

hm. i was afraid the multiple/wildcard cert might be required.

since a single cert is installed on a single IP-based (not named-) host, but valid only for a sinlge domain name (well, with & without 'www.')would it, instead, be possible to setup Parallel rather than on multiple subdomains,

https://(www.)example.com:443
https://cdn1.example.com:443
https://cdn1.example.com:443
https://cdn1.example.com:443

instead on multiple PORTS of the same domain? i.e.,

https://(www.)example.com:443
https://(www.)example.com:8081
https://(www.)example.com:8082
https://(www.)example.com:8083

? i'm _fairly_ sure that pound's HTTPS listener can be setup for any port, not just 443.

if this is doable, then Parallel could provide its perf boost with _one_ cert.

thoughts?

> Be sure to test before buying ...
> ... Testing is key ...

advice noted.

thanks!

mikeytown2’s picture

Using different ports instead of subdomains is an interesting idea. I believe it's valid html markup. Try //www.example.com:443 to be sure it works as expected. I don't know if the browser would download in parallel from the same domain though, even if its a different port. I don't think anyone has thought of this trick, so this is something that needs to be tested; I'm thinking it wont work though.

Cert is browser side, so doing a server side redirect wouldn't work (in case someone was thinking about doing it this way).

PGNetDev’s picture

> Try //www.example.com:443

unfortunately, that results in

An internal server error occurred. Please try again later.

and only this in logs,

==> /var/log/messages <==
Sep 24 19:25:50 edge pound: (b7c94b90) e500 response error read from 127.0.0.1:8080/GET /main/ HTTP/1.1: Connection timed out (15.004 secs)

==> /var/log/apache2/pressflow6.8081.log <==
mydomain.com xx.xx.xx.xx, 127.0.0.1 - - [24/Sep/2009:19:25:35 -0700] "GET /main/ HTTP/1.1" 200 8198 "-" "Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9) Gecko/2008052906 Firefox/3.0 FirePHP/0.3"

now to de-bork the site ...

PGNetDev’s picture

sanity check -- using just:

//www.example.com

works just fine ...

PGNetDev’s picture

hm. i lied.

*rebooted* the VM, then tried

//www.example.com:443

all's fine. well, at least the site serves, and there's no 'internal error'.

cache gremlins, methinks ... sorry :-/

PGNetDev’s picture

well, well.

i setup Parallel to use ports 808{1,2,3} as the 'CDN servers' for CSS, JS & IMG respectively ...

i mod'd pound.cfg, varnish's vcl.conf, apache's conf, and .... don't forget firewall (!) ... and i'm serving pages from drupal with, apparently, css links rewritten to come from the assigned ports.

JS & IMG are not working ... looks like relative vs absolute links? e.g.,

in the displayed page source,

...
<link type="text/css" rel="stylesheet" media="all" href="//www.example.com:8081/main/sites/all/modules/cck/modules/fieldgroup/fieldgroup.css?c" />
<link type="text/css" rel="stylesheet" media="all" href="//www.example.com:8081/main/themes/garland/style.css?c" />
<link type="text/css" rel="stylesheet" media="print" href="//www.example.com:8081/main/themes/garland/print.css?c" />
<script type="text/javascript" src="/main/sites/all/modules/jquery_update/replace/jquery.min.js?c"></script>
<script type="text/javascript" src="/main/misc/drupal.js?c"></script>
<script type="text/javascript" src="/main/sites/all/modules/panels/js/panels.js?c"></script>
...

one question: which IMG formats does Parallel support? atm, i'd presuming (?):

jpg|jpeg|gif|png|tiff|tif|ico

thanks.

mikeytown2’s picture

it uses the img html tag; so ico is not rewritten. Uses a regular expression for this.

For javascript, does your theme use the hook_preprocess_page?
http://api.drupal.org/api/function/template_preprocess_page/6
Do you do this somewhere?
$variables['scripts'] = drupal_get_js();
Odds are the javascript is getting rewritten. I have a special condition set just for css because of the recolorable theme option. css/js is grabbed from $variables['styles'] and $variables['scripts'] & thus i don't need a regular expression when changing the domain. Are you using "Use Hook Exit For CSS Replacement" right now?

all css images should be downloaded from the subdomain or other port in your case, so not all is lost ATM.

PGNetDev’s picture

> it uses the img html tag; so ico is not rewritten. Uses a regular expression for this.

ok, thanks.

> For javascript, does your theme use the hook_preprocess_page?
http://api.drupal.org/api/function/template_preprocess_page/6

yes, i use it. but note that the JS & IMG issues are also in the admin theme, which is, atm, drupal's default "Garland"

in any case, in my zen-subtheme's template.php,

...
function testtheme_preprocess_page(&$vars, $hook) {
  // var printing
  $vars['primary_menu_links'] = theme('links', $vars['primary_links'], array('class' => 'links primary-menu'));
  $vars['secondary_menu_links'] = theme('links', $vars['secondary_links'], array('class' => 'links secondary-menu'));

  // Make sure framework styles are placed above all others.
  $vars['css_alt'] = testtheme_css_reorder($vars['css']);   
  $vars['styles']  = drupal_get_css($vars['css_alt']);      
  
  // cref: http://drupal.org/project/conditional_styles
  $vars['styles'] .= $vars['conditional_styles'] = variable_get('conditional_styles_' . $GLOBALS['theme'], '');

  // Classes for body element. Allows advanced theming based on context
  // (home page, node of certain type, etc.)
  $classes = split(' ', $vars['body_classes']);
 
  // Optionally add the wireframes style
  if (theme_get_setting('testtheme_debug')) {
    $classes[] = 'show-grid'; 
  }
   
  $vars['body_classes_array'] = $classes;
  $vars['body_classes'] = implode(' ', $classes); // Concatenate with spaces.

    // "Different page templates depending on URL aliases"
    //  http://drupal.org/node/139766
    if (module_exists('path')) {
        $alias = drupal_get_path_alias(str_replace('/edit','',$_GET['q']));
        if ($alias != $_GET['q']) {
            $suggestions = array();
            $template_filename = 'page';
            foreach (explode('/', $alias) as $path_part) {
                $template_filename = $template_filename . '-' . $path_part;
                $suggestions[] = $template_filename;
            }
            $vars['template_files'] = array_merge((array) $suggestions, $vars['template_files']);
        }
    }
}
...

-------------------------

> Do you do this somewhere?
> $variables['scripts'] = drupal_get_js();

*i* don't use it anywhere... grep'ing the entire pressflow root,

grep -rlni drupal_get_js .
./sites/all/modules/advanced_help/advanced_help.module
./sites/all/modules/print/print.pages.inc
./sites/all/modules/geshifilter/geshi-extra/drupal5.php
./sites/all/modules/geshifilter/geshi-extra/drupal6.php
./sites/all/modules/jquery_update/jquery_update.module
./themes/chameleon/chameleon.theme
./includes/common.inc
./includes/theme.maintenance.inc
./includes/form.inc
./includes/theme.inc

> Are you using "Use Hook Exit For CSS Replacement" right now?

not at the moment.

> all css images should be downloaded from the subdomain or other port in your case, so not all is lost ATM.

still hopeful ;-)

PGNetDev’s picture

> Are you using "Use Hook Exit For CSS Replacement" right now?

if i DO enable it, theneven the CSS aren't rewritten ...

mikeytown2’s picture

hmmm nothing jumps out at me as to why its not working for those content types.

Here's the code

parallel_preprocess_page(&$variables) {
....
    if (variable_get('parallel_domain_css', '') != '') {
      $variables['styles'] = str_replace(' href="/', ' href="' . variable_get('parallel_domain_css', '') . '/', $variables['styles']);
    }
    if (variable_get('parallel_domain_js', '') != '') {
      $variables['scripts'] = str_replace(' src="/', ' src="' . variable_get('parallel_domain_js', '') . '/', $variables['scripts']);
    }

So i'm still thinking something sets $variables['scripts'] after parallel is done.

PGNetDev’s picture

switching to Garland to remoe my theme as a variable, it looks like _just_ js is, in fact, being 'missed'.

css is being rewritten to :8081, as above. i also note,

...
  <div class="content"><a href="http://drupal.org"><img  src="//www.example.com:8083/main/misc/powered-blue-80x15.png" alt="Powered by Pressflow, an open source content management system" title="Powered by Pressflow, an open source content management system" width="80" height="15" /></a></div>
...

imgs are as well.

hm ...

PGNetDev’s picture

found the problem -- jquery_update module.

disable it, and i've now:

<script type="text/javascript" src="//www.example.com:8082/main/misc/drupal.js?x"></script>

checking (again ... should've paid better attention above. teach me for working late ...),

 grep drupal_get_js .../sites/all/modules/jquery_update
  jquery_update.module: * so that a theme can't call drupal_get_js() and mess everything up.
  jquery_update.module:      $variables['scripts'] = drupal_get_js('header', $scripts);

as you suspected.

now, is it possible to modify jquery_update, or Parallel, to allow happy coexistence?

PGNetDev’s picture

looking closer, there's some selectivity ... note most, but not all, img & css are rewritten ... e.g., grep @ 'View Source' of the .../admin page:

egrep -i "\.css|\.js|img" tmp.txt

    <link type="text/css" rel="stylesheet" media="all" href="//www.example.com:8081/main/modules/node/node.css?x" />
<link type="text/css" rel="stylesheet" media="all" href="//www.example.com:8081/main/modules/system/admin.css?x" />
<link type="text/css" rel="stylesheet" media="all" href="//www.example.com:8081/main/modules/system/defaults.css?x" />
<link type="text/css" rel="stylesheet" media="all" href="//www.example.com:8081/main/modules/system/system.css?x" />
<link type="text/css" rel="stylesheet" media="all" href="//www.example.com:8081/main/modules/system/system-menus.css?x" />
<link type="text/css" rel="stylesheet" media="all" href="//www.example.com:8081/main/modules/user/user.css?x" />
href="//www.example.com:8081/main/sites/all/modules/cck/theme/content-module.css?x" />
href="//www.example.com:8081/main/sites/all/modules/ctools/css/ctools.css?x" />
href="//www.example.com:8081/main/sites/all/modules/logintoboggan/logintoboggan.css?x" />
href="//www.example.com:8081/main/sites/all/modules/panels/css/panels.css?x" />
href="//www.example.com:8081/main/sites/all/modules/tagadelic/tagadelic.css?x" />
href="//www.example.com:8081/main/sites/all/modules/cck/modules/fieldgroup/fieldgroup.css?x" />
<link type="text/css" rel="stylesheet" media="all" href="//www.example.com:8081/main/themes/garland/style.css?x" />
<link type="text/css" rel="stylesheet" media="print" href="//www.example.com:8081/main/themes/garland/print.css?x" />
    <script type="text/javascript" src="//www.example.com:8082/main/misc/jquery.js?x"></script>
<script type="text/javascript" src="//www.example.com:8082/main/misc/drupal.js?x"></script>
<script type="text/javascript" src="//www.example.com:8082/main/sites/all/modules/panels/js/panels.js?x"></script>
      <link type="text/css" rel="stylesheet" media="all" href="/main/themes/garland/fix-ie.css" />    <![endif]-->
        <h1><a href="/main/" title="mysite"><img src="/main/themes/garland/logo.png" alt="mysite" id="logo"
  <div class="content"><a href="http://drupal.org"><img  src="//www.example.com:8083/main/misc/powered-blue-80x15.png"
PGNetDev’s picture

as an experiment, i disabled Parallel (jquery_update is still disabled, too), pulled out its ..._image_replace & ..._preprocess_page code, and added it to the END of my subtheme's ..._preprocess_page block.

subtheme pages now seem to render correctly.

viewing PageSource for rendered pages (in the subtheme; default/other themes, now, of course, do NOT use the CDN/parallel-related code) still shows a mix of, e.g., css reference -- some WITH the https://www.example.com:8081/... rewrite, and some without --

however, according to my logs, _all_ css/js/img are passing, as intended, thru their respective "cdn ports".

so, that's a bit confusing to me ...

now to do some benchmarking.

mikeytown2’s picture

Status: Active » Closed (fixed)

jquery_update was probably to blame; closing this issue since it's old