Trying to weigh the advantages of Public vs Private download method. It seems like using a (rewritten)query string (private download method) would require more server resources than using a physical file path (public download method).

Is this correct?, or do I misunderstand how these things work?

I'm trying to troubleshoot massive CPU usage and MySQL errors on a site where it is not uncommon to have 1500 simultaneous connections to a page with 20+ images on it. Wondering if having "Download method" set to private could have something to do with it. (Caching enabled)

Comments

Arto’s picture

'Public' allows the web server itself to serve the files, while 'private' forces everything to be passed through PHP and Drupal, which is going to increase resource consumption. With the figures you gave for simultaneous connections, this could indeed be significantly affecting your server load.

--
Arto Bendiken -- currently working on static page caching for Drupal 4.7.

Zach Harkey’s picture

Thank you. That is what I was afraid of.

Now the big question is: I need to switch from 'private' to 'public' download method, but of course this option is followed by the ominous warning:

You can change this at any time, however all download URLs will change and there may be unexpected problems so it is not recommended.

What do I need to be scared of here? I'm pretty sure that I never directly address images in my content. I've always used inline [img_assist] filter tags or <img source="image/view/x" /> style html tags. So I can't really think of what links are going to break.

Of course it also now occurs to me that both of the afore mentioned methods probably tax the server just as much.

-zach
--
harkey design

: z

escoles’s picture

While Arto is correct that it would entail an increased server load, that increase should be a trivial contribution to the total resource consumption unless you're serving every image in your UI via private method.

To answer the question of whether you need to modify your approach, you need to assess how many times per page the private method will be used to serve an image file. If it's not very many, or your traffic is low, then it shouldn't really be much of an issue.

Zach Harkey’s picture

The overhead created by non-filesystem image paths can easily become non-trivial, especially in situations like image gallery templates.

My biggest problem was my cavalier use of image/view/x/thumbnail style paths in my templates. Changing all of my templates to only use public file system style paths (<img source="sites/example.com/files/images/example-image.preview.jpg" />).

For example with my image gallery templates, in image_gallery.tpl.php I changed instances like this:

<img src="/image/view/<?php print $image->nid ?>/thumbnail" alt="" />

to something like this:

<img src="<?php print base_path() . file_create_path($image->images['thumbnail']) ?>" alt="" />

The difference in performance was staggering. Of course, it was a popular site with many images. But it didn't take much to overwhelm the server. Too many requests... et al.

Had I not switched my system settings to use the public file method, even this new code would have rendered a path like system/files/etc, which, if I'm not mistaken still requires parsing (or does it use mod_rewrite voodo or something?).

-zach
--
harkey design

: z

escoles’s picture

... when what I really meant was "nodes."

marcoka’s picture

did you find a solution for the overhead problem with many thumbnails/gallery?

Arto’s picture

BTW, you may be interested in a patch I posted that provides efficient private file transfers for Drupal, essentially solving this problem.

--
Arto Bendiken -- currently working on static page caching for Drupal 4.7.