Slow streaming of several images

54 views
Skip to first unread message

VP

unread,
Oct 10, 2010, 11:30:01 PM10/10/10
to web2py-users
I want to display several images (some type of gallery) at once.
These images are quite small. Sometimes, it is very slow to load the
page. This happens when I just open up the application or refresh
the page (sometime) (using Ctr-R).

I am unsure this is because:

1. I'm running in "prototype" mode with sqlite, built-in server
(rocket), or
2. These small images are being streamed simultaneously. I don't know
if this makes a difference, but I'd prefer these images are "static",
not streamed. But I don't know how to do this in web2py.

Any idea?

Thanks.
VP

cjrh

unread,
Oct 11, 2010, 4:21:16 AM10/11/10
to web2py-users
On Oct 11, 5:30 am, VP <vtp2...@gmail.com> wrote:
> 2. These small images are being streamed simultaneously.  I don't know
> if this makes a difference, but I'd prefer these images are "static",
> not streamed. But I don't know how to do this in web2py.

If your images are stored in 'upload' fields, then they are indeed
being pulled off the filesystem, and not out of the DB. DB Fields of
type 'upload' store the image data on disk, and the filename only in
the DB. Or are you storing the images as blobs?

mdipierro

unread,
Oct 11, 2010, 9:07:49 AM10/11/10
to web2py-users
There should be no overhead in serving uploaded images unless:
1) you use uploadfiled='a blob field'
2) you set db.table.field.authorize!=None

Massimo

VP

unread,
Oct 11, 2010, 6:06:22 PM10/11/10
to web2py-users
These images are stored in "upload" (not a blob) and I did not set
authorize!=None.

I am supposing that this has to do with the built-in server streaming
multiple images at the same time?

(I also notice that the problem seems to be worse (slow loading) with
Safari than with Firefox).

Thanks.

Mariano Reingart

unread,
Oct 11, 2010, 7:36:07 PM10/11/10
to web...@googlegroups.com
Are you using default download()?

Maybe modifying cache http headers helps you:

http://web2pyslices.com/main/slices/take_slice/83

(it is a "faster/smarter" download function)

Regards,

Mariano Reingart
http://www.sistemasagiles.com.ar
http://reingart.blogspot.com

VP

unread,
Oct 18, 2010, 4:28:25 PM10/18/10
to web2py-users
To follow up on this...

(1) To recap, I have a dozen of thumbnails of sizes ranging from 5kb
to 15kb on one page (a gallery type of things). Observed occasional
slow rendering of the page, on local server.

(2) I think this slowness has to do with rocket server. After trying
on another server with Apache. This slowness disappeared.

(3) That said, there's still an observed slow rendering as a result of
web2py streaming images. Massimo claimed that there should be NO
overhead. To my eyes, the overhead in streaming these small images
are noticeable. I think Massimo might have underestimated the
sensitivity of the eyes. The download is fast, but not fast enough
for my eyes to still see flickering. And this can be quite
*annoying*.


(4) THE FIX: is the *fast_download* slice by Mariano Reingart!!!
This does the trick.
A comment to Mariano: you might want to add "import os, time" to the
code. People might neglect to do this (as I did initially); without
these imports, it of course doesn't work, without telling you why.

VP

unread,
Oct 18, 2010, 4:37:14 PM10/18/10
to web2py-users
Another comment is that.... cache.ram (both controller and view)
doesn't seem to improve that much (in this particular case).
Reply all
Reply to author
Forward
0 new messages