[Zope-dev] Streaming Response

Casey Duncan casey@zope.com
Thu, 24 Apr 2003 09:04:28 -0400


On Thursday 24 April 2003 05:41 am, Toby Dickenson wrote:
> (caution; old thread)
>=20
> On Monday 21 April 2003 2:51 pm, Chris Withers wrote:
> > Dieter Maurer wrote:
> > >  > If the whole thing is indeed loaded into memory, then it pretty =
much
> > >  > defeats the purpose of this code.
>=20
> One purpose of this code is to reduce latency by allowing the first chu=
nk to=20
> be written to the http socket before the last chunk is loaded from disk=
=2E
>=20
> > > Change it to:
> > >
> > >        while data is not None:
> > > =09     RESPONSE.write(data.data)
> > > =09     ndata=3D data.next
> > > =09     data._p_deactivate()
> > > =09     data=3D ndata
> >
> > Has anyone tested this works?
> >
> > If so, has anyone checked it in?
> >
> > If not, could someone open a collector issue so I can check it in ;-)
>=20
> Deactivating *every* block looks like a bad idea. This defeats the in-m=
emory=20
> cache that will be a big win for small files.=20

I agree.
=20
> The memory cache is only a disadvange if your files are large enough th=
at=20
they=20
> have enough chunks to disrupt LRU cache policy. How about comparing the=
=20
> number of chunks to a fraction of the cache target size?

I think possibly a better solution is to have an explicit switch on the f=
ile=20
like "Disable ZODB caching (recommended for large files)" so that it can =
be=20
decided as policy on a case-by-case basis.

-Casey