Hello, I''m new to providing image content online and I need to take the right approach early in my development to avoid any significant performance or storage hits later on. I''m using Ruby on Rails to provide large image content on my website. However, I''m not sure if I should store images on server or in database for faster retrieval. The images that will be saved are uploaded by website visitors. I tried finding content online on this subject and I''ve come across the three approaches of: * Storing images as binary in the database. * Storing only the URL of the images that point to the file system actual image on the server. * Dynamically build the URL (relative path) of the images that are saved on the file system under the server. I would greatly appreciate if you can provide me with your professional advice on this topic or direct me to good resources where I can read further on that subject. Thanks, SS
Exactly what does "large image content" mean? Are they large images, or will you have a large amount of images? Is the typical workload characterized by read operations or write operations? Do some of the images require access authorization? Reading from the filesystem is faster than from the database. What''s best for you depends on your specific situation. -- Roderick van Domburg http://www.nedforce.com -- Posted via http://www.ruby-forum.com/.
May I add that by storing your images in on filesystem within public will allow any request to bypass your app server and serve directly by web server. And less database hit, means faster response time :) Strongly suggest don''t store in database, if later on you want to manipulate the images using external application, you can do it easily if everything on filesystem. And using paperclip for example, allows you to store multiple copies of the images in different sizes, created immediately after upload. But yeah, if you could provide more info on what you want to achieve, the implementation could differ :) Cheers! Arzumy On Jul 8, 10:47 pm, Roderick van Domburg <rails-mailing-l...@andreas- s.net> wrote:> Exactly what does "large image content" mean? Are they large images, or > will you have a large amount of images? Is the typical workload > characterized by read operations or write operations? Do some of the > images require access authorization? > > Reading from the filesystem is faster than from the database. What''s > best for you depends on your specific situation. > > -- > Roderick van Domburghttp://www.nedforce.com > -- > Posted viahttp://www.ruby-forum.com/.
I''m storing files(images) outside document root. I have special action for serving these files. It checks user permissions for file and sends X-Sendfile header with filename and Apache serves the actual file to user. It does not block your ruby processes. If you are using Passenger, than uploading large files are handled by Passenger and your script is only called for processing, so it''s not bocked either. For Apache there is a module: http://tn123.ath.cx/mod_xsendfile/ ; Nginx has this funtionality implemented. M. On Wed, Jul 8, 2009 at 8:46 PM, Arzumy<hello-/do3P1lf25I@public.gmane.org> wrote:> > May I add that by storing your images in on filesystem within public > will allow any request to bypass your app server and serve directly by > web server. And less database hit, means faster response time :) > > Strongly suggest don''t store in database, if later on you want to > manipulate the images using external application, you can do it easily > if everything on filesystem. And using paperclip for example, allows > you to store multiple copies of the images in different sizes, created > immediately after upload. > > But yeah, if you could provide more info on what you want to achieve, > the implementation could differ :) > > Cheers! > Arzumy > > On Jul 8, 10:47 pm, Roderick van Domburg <rails-mailing-l...@andreas- > s.net> wrote: >> Exactly what does "large image content" mean? Are they large images, or >> will you have a large amount of images? Is the typical workload >> characterized by read operations or write operations? Do some of the >> images require access authorization? >> >> Reading from the filesystem is faster than from the database. What''s >> best for you depends on your specific situation. >> >> -- >> Roderick van Domburghttp://www.nedforce.com >> -- >> Posted viahttp://www.ruby-forum.com/. > > >
Thank you all for your responses. What I''m trying to achieve is allowing users to post their photos on the website and give them ability to search for photos of others. Therefore, I''m dealing with large number of files, not so much with large size of files. Arzumy, you mentioned the Paperclip library. I''ve been looking into integrating it with my Rails code to do most of the image management. I installed the latest ImageMagick version on Windows Vista, however I keep getting problems. The ImageMagick installed correctly, the problem is after I tried to submit my Rails form with a .jpg or .gif photo it gives me the error: "Photo C:/Users/.../AppData/Local/Temp/stream.1556.0 is not recognized by the ''identify'' command." I read that I get this error message, because I need to install dependency such as delegates for each file type allowed to be processed, i.e. jpeg, by ImageMagick but all of the articles that I came across they are not clear and straight to the point how to install and configure those delegates on Win Vista. I believe that you have ImageMagick running on your machine and I was hoping that you can direct me to a good resource on how to get it working with Rails. I would greatly appreciate any recommendations! SS On Jul 8, 12:46 pm, Arzumy <he...-/do3P1lf25I@public.gmane.org> wrote:> May I add that by storing your images in on filesystem within public > will allow any request to bypass your app server and serve directly by > web server. And lessdatabasehit, means faster response time :) > > Strongly suggest don''t store indatabase, if later on you want to > manipulate the images using external application, you can do it easily > if everything on filesystem. And using paperclip for example, allows > you to store multiple copies of the images in different sizes, created > immediately after upload. > > But yeah, if you could provide more info on what you want to achieve, > the implementation could differ :) > > Cheers! > Arzumy > > On Jul 8, 10:47 pm, Roderick van Domburg <rails-mailing-l...@andreas- > > s.net> wrote: > > Exactly what does "large image content" mean? Are they large images, or > > will you have a large amount of images? Is the typical workload > > characterized by read operations or write operations? Do some of the > > images require access authorization? > > > Reading from the filesystem is faster than from thedatabase. What''s > > best for you depends on your specific situation. > > > -- > > Roderick van Domburghttp://www.nedforce.com > > -- > > Posted viahttp://www.ruby-forum.com/.
Storing in the filesystem avoids database and app overhead, while also allowing files to be moved to a different server if desired. As for Imagemagick and rMagick and Rails, the IM part is simply to install it and make sure your PATH includes IM''s bin directory, as the conversion process is pretty much just a system call to the `convert` utility. -eric On Jul 10, 11:18 am, SS <stoyan.stoitch...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Thank you all for your responses. What I''m trying to achieve is > allowing users to post their photos > on the website and give them ability to search for photos of others. > Therefore, I''m dealing with large > number of files, not so much with large size of files. > > Arzumy, you mentioned the Paperclip library. I''ve been looking into > integrating it with my Rails code > to do most of the image management. I installed the latest ImageMagick > version on Windows Vista, however I keep > getting problems. The ImageMagick installed correctly, the problem is > after I tried to submit my Rails form with > a .jpg or .gif photo it gives me the error: > > "Photo C:/Users/.../AppData/Local/Temp/stream.1556.0 is not recognized > by the ''identify'' command." > > I read that I get this error message, because I need to install > dependency such as delegates for each file type > allowed to be processed, i.e. jpeg, by ImageMagick but all of the > articles that I came across they are not clear and > straight to the point how to install and configure those delegates on > Win Vista. I believe that you have > ImageMagick running on your machine and I was hoping that you can > direct me to a good resource > on how to get it working with Rails. > > I would greatly appreciate any recommendations! > > SS > > On Jul 8, 12:46 pm, Arzumy <he...-/do3P1lf25I@public.gmane.org> wrote: > > > May I add that by storing your images in on filesystem within public > > will allow any request to bypass your app server and serve directly by > > web server. And lessdatabasehit, means faster response time :) > > > Strongly suggest don''t store indatabase, if later on you want to > > manipulate the images using external application, you can do it easily > > if everything on filesystem. And using paperclip for example, allows > > you to store multiple copies of the images in different sizes, created > > immediately after upload. > > > But yeah, if you could provide more info on what you want to achieve, > > the implementation could differ :) > > > Cheers! > > Arzumy > > > On Jul 8, 10:47 pm, Roderick van Domburg <rails-mailing-l...@andreas- > > > s.net> wrote: > > > Exactly what does "large image content" mean? Are they large images, or > > > will you have a large amount of images? Is the typical workload > > > characterized by read operations or write operations? Do some of the > > > images require access authorization? > > > > Reading from the filesystem is faster than from thedatabase. What''s > > > best for you depends on your specific situation. > > > > -- > > > Roderick van Domburghttp://www.nedforce.com > > > -- > > > Posted viahttp://www.ruby-forum.com/. > >