Problem in downloading large file with apache+mongrel

hii all,
am using apache as frontend to mongrel and loaded xsendfile
module in apache ,am looking for 1 GB of download .this is download
routine

def download

@stream = Stream.find(params[:id])

send_file(@stream.location,:filename => @stream.name,:disposition >
‘attachment’,:x_sendfile => true )

and

And this is how it is processed

Processing StreamsController#download (for 127.0.0.1 at 2010-09-22
12:32:10) [GET] Parameters: {“id”=>“6596”}

<-[4;36;1mSQL (0.0ms)?[0m ?[0;1mSET NAMES ‘utf8’?[0m

<-[4;35;1mSQL (0.0ms)?[0m ?[0mSET SQL_AUTO_IS_NULL=0?[0m

<-[4;36;1mStream Columns (15.0ms)?[0m ?[0;1mSHOW FIELDS FROM streams?[0m

<-[4;35;1mStream Load (0.0ms)?[0m ?[0mSELECT * FROM streams WHERE
(streams.id = 6596) ?[0m

<-[4;36;1mCACHE (0.0ms)?[0m ?[0;1mSELECT * FROM streams WHERE
(streams.id = 596) ? ?[0m

Sending X-Sendfile header
d:/dm/predator_720x480_5mbps_30fps_17minclip.264.filepart Completed in
57513ms (View: 0, DB: 15) | 200 OK [http://src/streams/download/6596]

very first times its okk i getting full 1.1 GB of file getting
downloaded,but when i am trying to download this 1.1 gb of file again,
am getting failed to allocate memroy what could be soultion?? and can i
use cache.clear before send_file function??
and more thing to again download 1.1 gb of file i have to restart my
servers…

thanks??

On Wed, Sep 22, 2010 at 10:01 AM, Amit T. [email protected]
wrote:

hii all,
am using apache as frontend to mongrel and loaded xsendfile
module in apache ,am looking for 1 GB of download .this is download
routine

Replied your previous message to the list also. Please provide the
answers to my questions.

Luis L.
AREA 17

Perfection in design is achieved not when there is nothing more to add,
but rather when there is nothing more to take away.
Antoine de Saint-Exupéry

Luis L. wrote:

On Wed, Sep 22, 2010 at 10:01 AM, Amit T. [email protected]
wrote:

hii all,
am using apache as frontend to mongrel and loaded xsendfile
module in apache ,am looking for 1 GB of download .this is download
routine

Replied your previous message to the list also. Please provide the
answers to my questions.

Luis L.
AREA 17

Perfection in design is achieved not when there is nothing more to add,
but rather when there is nothing more to take away.
Antoine de Saint-Exupé²¹

just now i seen your message…
i am running apache 2.2.11 that comes with XAMPP 1.7.1 and mongrel
version is
1.1.2,
ruby version is ruby 1.8.6

luis you are saying

Rails is serving the request, the 1.1GB, not Apache
but how do i know rails is serving the request…or Apache

  1. d:/dm is not a network drive…its folder on d drive
    how do i know whther it available to apache ??

i am sending you access logs of apache after few mintues

when i am trying to downnload following happen in logs of apache

127.0.0.1 - - [22/Sep/2010:19:11:12 +0530] “GET /streams/download/6598
HTTP/1.1” 500 1024 “http://src/streams/6598” “Mozilla/5.0 (Windows; U;
Windows NT 5.1; en-US) AppleWebKit/534.3 (KHTML, like Gecko)
Chrome/6.0.472.33 Safari/534.3”

where 6598 is id of file to be downloaded

soory but how do i setup s virtual server configuration??
and i have to install that plugin??

On Wed, Sep 22, 2010 at 11:22 AM, Amit T. [email protected]
wrote:

soory but how do i setup s virtual server configuration??

Read apache documentation.

and i have to install that plugin??

No, in your controller action set the headers, do not install the
plugin.

Luis L.
AREA 17

Perfection in design is achieved not when there is nothing more to add,
but rather when there is nothing more to take away.
Antoine de Saint-Exupéry

On Wed, Sep 22, 2010 at 10:50 AM, Amit T. [email protected]
wrote:

just now i seen your message…
i am running apache 2.2.11 that comes with XAMPP 1.7.1 and mongrel
version is
1.1.2,
ruby version is ruby 1.8.6

Rails is serving the request, the 1.1GB, not Apache
but how do i know rails is serving the request…or Apache

Please answer all the questions I put, analyze the process memory usage.

If you don’t see in apache serving the X-Sendfile request, then is not.

Try setting the headers on your own and render nothing:

Implement the first code example of this page:

http://john.guen.in/past/2007/4/17/send_files_faster_with_xsendfile/

Not the plugin.

  1. d:/dm is not a network drive…its folder on d drive
    how do i know whther it available to apache ??

Try to setup a virtual server configuration that access D: and see if it
works.


Luis L.
AREA 17

Perfection in design is achieved not when there is nothing more to add,
but rather when there is nothing more to take away.
Antoine de Saint-Exupéry

Luis L. wrote:

On Wed, Sep 22, 2010 at 11:22 AM, Amit T. [email protected]
wrote:

soory but how do i setup s virtual server configuration??

Read apache documentation.

and i have to install that plugin??

No, in your controller action set the headers, do not install the
plugin.

Luis L.
AREA 17

Perfection in design is achieved not when there is nothing more to add,
but rather when there is nothing more to take away.
Antoine de Saint-Exupé²¹

luis i change my code as you said

filename = “#{@stream.location}”
response.headers[‘Content-Type’] = “application/force-download”
response.headers[‘Content-Disposition’] = “attachment;
filename="#{File.basename(filename)}"”
response.headers[“X-Sendfile”] = filename
response.headers[‘Content-length’] = File.size(filename)
render :nothing => true

this is how it is processed…

On Wed, Sep 22, 2010 at 12:00 PM, Amit T. [email protected]
wrote:

this is how it is processed…

This? How? can you provide answers to my previous questions about
process memory usage? Please?


Luis L.
AREA 17

Perfection in design is achieved not when there is nothing more to add,
but rather when there is nothing more to take away.
Antoine de Saint-Exupéry

Amit T. wrote:

Luis L. wrote:

On Wed, Sep 22, 2010 at 11:22 AM, Amit T. [email protected]
wrote:

soory but how do i setup s virtual server configuration??

Read apache documentation.

and i have to install that plugin??

No, in your controller action set the headers, do not install the
plugin.

Luis L.
AREA 17

Perfection in design is achieved not when there is nothing more to add,
but rather when there is nothing more to take away.
Antoine de Saint-Exupé²¹

luis i change my code as you said

filename = “#{@stream.location}”
response.headers[‘Content-Type’] = “application/force-download”
response.headers[‘Content-Disposition’] = “attachment;
filename="#{File.basename(filename)}"”
response.headers[“X-Sendfile”] = filename
response.headers[‘Content-length’] = File.size(filename)
render :nothing => true

this is how it is processed…

Processing StreamsController#download (for 127.0.0.1 at 2010-09-22
20:22:06) [GET]
Parameters: {“id”=>“6600”}
?[4;36;1mSQL (0.0ms)?[0m ?[0;1mSET NAMES ‘utf8’?[0m
?[4;35;1mSQL (0.0ms)?[0m ?[0mSET SQL_AUTO_IS_NULL=0?[0m
?[4;36;1mStream Columns (0.0ms)?[0m ?[0;1mSHOW FIELDS FROM
streams?[0m
?[4;35;1mStream Load (0.0ms)?[0m ?[0mSELECT * FROM streams WHERE
(streams.id = 6600) ?[0m
?[4;36;1mCACHE (0.0ms)?[0m ?[0;1mSELECT * FROM streams WHERE
(streams.id = 6600) ?[0m
0) ?[0m
Completed in 65347ms (View: 0, DB: 0) | 200 OK
[http://src/streams/download/6600]

Amit T. wrote:

Amit T. wrote:

Luis L. wrote:

On Wed, Sep 22, 2010 at 11:22 AM, Amit T. [email protected]
wrote:

soory but how do i setup s virtual server configuration??

Read apache documentation.

and i have to install that plugin??

No, in your controller action set the headers, do not install the
plugin.

Luis L.
AREA 17

Perfection in design is achieved not when there is nothing more to add,
but rather when there is nothing more to take away.
Antoine de Saint-Exupé²¹

luis i change my code as you said

filename = “#{@stream.location}”
response.headers[‘Content-Type’] = “application/force-download”
response.headers[‘Content-Disposition’] = “attachment;
filename="#{File.basename(filename)}"”
response.headers[“X-Sendfile”] = filename
response.headers[‘Content-length’] = File.size(filename)
render :nothing => true

this is how it is processed…

Processing StreamsController#download (for 127.0.0.1 at 2010-09-22
20:22:06) [GET]
Parameters: {“id”=>“6600”}
?[4;36;1mSQL (0.0ms)?[0m ?[0;1mSET NAMES ‘utf8’?[0m
?[4;35;1mSQL (0.0ms)?[0m ?[0mSET SQL_AUTO_IS_NULL=0?[0m
?[4;36;1mStream Columns (0.0ms)?[0m ?[0;1mSHOW FIELDS FROM
streams?[0m
?[4;35;1mStream Load (0.0ms)?[0m ?[0mSELECT * FROM streams WHERE
(streams.id = 6600) ?[0m
?[4;36;1mCACHE (0.0ms)?[0m ?[0;1mSELECT * FROM streams WHERE
(streams.id = 6600) ?[0m
0) ?[0m
Completed in 65347ms (View: 0, DB: 0) | 200 OK
[http://src/streams/download/6600]

and these are the lines i added in httpd.conf
<Directory “d:/dm”>
Options Indexes FollowSymLinks
AllowOverride FileInfo
Order allow,deny
Allow from all

for virtual server configuration to access D:
what should i do now

Amit T. wrote:

yaa am looking to provide answer for that also memory usage

Luis when i download file
httpd.exe is varied from at 49,892k to 50,264k
while ruby.exe 934800 k to 1,208688k

On Wed, Sep 22, 2010 at 12:01 PM, Amit T. [email protected]
wrote:

?[4;36;1mCACHE (0.0ms)?[0m ?[0;1mSELECT * FROM streams WHERE
(streams.id = 6600) ?[0m
0) ?[0m
Completed in 65347ms (View: 0, DB: 0) | 200 OK
[http://src/streams/download/6600]

Rails log do not help, we need to know Apache headers, responses and
also mongrel headers sent to apache via the proxy.

Please use curl --head on mongrel to request the URL and provide the
complete output
Also do the same from apache.

Beyond that, I cannot help you more because I don’t have time to
attempt replicate your environment and scenario.

Luis L.
AREA 17

Perfection in design is achieved not when there is nothing more to add,
but rather when there is nothing more to take away.
Antoine de Saint-Exupéry

Amit T. wrote:

Amit T. wrote:

yaa am looking to provide answer for that also memory usage

Luis when i download file
httpd.exe is varied from at 49,892k to 50,264k
while ruby.exe 934800 k to 1,208688k

and louis as soon while getting downloded memoryuse of httd.exe is
getting decrerase to 768 k and the when the file completely downloded
memory use get down to 324 k

Amit T. wrote:

Amit T. wrote:

Amit T. wrote:

yaa am looking to provide answer for that also memory usage

Luis when i download file
httpd.exe is varied from at 49,892k to 50,264k
while ruby.exe 934800 k to 1,208688k

and louis as soon while getting downloded memoryuse of httd.exe is
getting decrerase to 768 k and the when the file completely downloded
memory use get down to 324 k

yaa louis tahnks for your help…
you must be very good person…

yaa am looking to provide answer for that also memory usage

On Wed, Sep 22, 2010 at 12:29 PM, Amit T. [email protected]
wrote:

Amit T. wrote:

yaa am looking to provide answer for that also memory usage

Luis when i download file
httpd.exe is varied from at 49,892k to 50,264k
while ruby.exe 934800 k to 1,208688k

That makes then clear that Ruby is trying to read the file, not apache.

Sorry, I can’t help you more if you don’t keep an structure
conversation and you investigate also.

Luis L.
AREA 17

Perfection in design is achieved not when there is nothing more to add,
but rather when there is nothing more to take away.
Antoine de Saint-Exupéry

but louis,how do i force apache to read the file and this problem can
occur with Apache also??

On 22 Sep 2010, at 12:00, Amit T. wrote:

luis i change my code as you said

filename = “#{@stream.location}”
response.headers[‘Content-Type’] = “application/force-download”
response.headers[‘Content-Disposition’] = “attachment;
filename=”#{File.basename(filename)}""

The problem is here ^^^^

response.headers[“X-Sendfile”] = filename
response.headers[‘Content-length’] = File.size(filename)

File.size should fail, as rails will be in Dir.pwd == Rails.root, and as
such, File.size(filename) for filename with no path should fail. This
should be raising Errno::ENOENT.

On 23 Sep 2010, at 02:42, Amit T. wrote:

response.headers[“X-Sendfile”] = filename
response.headers[‘Content-length’] = File.size(filename)

File.size should fail, as rails will be in Dir.pwd == Rails.root, and as
such, File.size(filename) for filename with no path should fail. This
should be raising Errno::ENOENT.

but tucker, i am getting failed to allocate memory and that is also of
second time…

You confuse me for someone that doesn’t read. You also clearly don’t
understand “should”, or what I’ve just told you.