Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
By Zach Harkey on
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
Yes, it is
'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.
Thank you. That is what I
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:
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
CLARIFICATION: AFAIK 'PRIVATE' Should only affect attachments
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.
The overhead created by
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:
to something like this:
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
Fair enough, and I shouldn't have said "attachments"...
... when what I really meant was "nodes."
did you find a solution for
did you find a solution for the overhead problem with many thumbnails/gallery?
Fast private file transfers for Drupal
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.