Re: How to store fixed size images? - Mailing list pgsql-general

From Alan Hodgson
Subject Re: How to store fixed size images?
Date
Msg-id 1587340.KArM26OA1M@skynet.simkin.ca
Whole thread Raw
In response to Re: How to store fixed size images?  (Andy Colson <andy@squeakycode.net>)
List pgsql-general
On Thursday, June 19, 2014 10:21:56 AM Andy Colson wrote:
> On 06/16/2014 08:10 PM, sunpeng wrote:
> > We have many small size(most fixed size) images, how to store them? There
> > are two options: 1. Store images in folders, managed by os file system,
> > only store path in postgresql 2. Store image as bytea in postgresql
> > How do you usually store images?
> > Thanks!
> >
> > peng
>
> I think it depends on how you are going to use them.  I, for example, have
> lots of images that are served on a web page, after benchmarks I found it
> was faster to store them on filesystem and let apache serve them directly.
>
> -Andy

That will always be the (much) faster option. There's basically no CPU
overhead, the web server can tell the kernel to copy the image from the
filesystem cache directly into a network buffer, and off it goes. Even apache can
serve line speed like that.

It's a lot easier to manage the images if they're in the database, though,
especially if you run off multiple web servers. If CPU overhead is actually an
issue, you can eliminate most of the speed hit by sticking a caching proxy
server like Varnish in front of your site, or by offloading the image serving to
a pass-through CDN. Just make sure images get a new URL path if they change
content.


pgsql-general by date:

Previous
From: Khangelani Gama
Date:
Subject: Re: pg_restore: custom archiver unexpected end of file , ERROR: missing data for column
Next
From: John R Pierce
Date:
Subject: Re: Best backup strategy for production systems