Problem in using xsendfile apche+mongrel

Hii All, i loaded mod_xsendfile.so in apche , i added few line in
httpd.conf files

LoadModule xsendfile_module modules/mod_xsendfile.so

XSendFile on

XSendFileAllowAbove on

<VirtualHost * localhost:80>
ServerName src

DocumentRoot C:/InstantRails-2.0-win/rails_apps/src/public/

ProxyPass / http://localhost:3000/

ProxyPassReverse / http://localhost:3000/

now in my rails application i have a streams controller and inside
streams controller i have a function named download ,code for code
download is below

def download

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

filename = “#{@stream.location}”

response.headers[‘Content-Type’] = “application/force-download”

response.headers[‘Content-Disposition’] = “attachment;
filename="#{File.basename(filename)}"”

response.headers[“X-Sendfile”] = @stream.location

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

render :nothing => true

end

Problem is my rails application still handling this request but i would
like apache to handle this request ,can anyone tell me how i configure
apche to handle this request??

On Sep 27, 9:00 am, Amit T. [email protected] wrote:

Problem is my rails application still handling this request but i would
like apache to handle this request ,can anyone tell me how i configure
apche to handle this request??

So what happens when you hit that controller ? (and did you notice
that rails’ send_file method has an x_sendfile option)

Fred

Frederick C. wrote:

On Sep 27, 9:00?am, Amit T. [email protected] wrote:

Problem is my rails application still handling this request but i would
like apache to handle this request ,can anyone tell me how i configure
apche to handle this request??

So what happens when you hit that controller ? (and did you notice
that rails’ send_file method has an x_sendfile option)

Fred

Fred thanks for responding
Actully when i downloding files,mongrel rendering things,

Processing StreamsController#download (for 127.0.0.1 at 2010-09-27
16:50:47) [GET]
Parameters: {“id”=>“6655”}
?[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 = 6655) ?[0
Completed in 78ms (View: 0, DB: 0) | 200 OK
[http://src/streams/download/6655]

It is when i am trying to download 2.2GB of file ,file is downloaded
completely,but my worry is why mongrel is rendering things if apache is
handling download

Frederick C. wrote:

On Sep 27, 12:28?pm, Amit T. [email protected] wrote:

It is when i am trying to download 2.2GB of file ,file is downloaded
completely,but my worry is why mongrel is rendering things if apache is
handling download

That looks entirely normal to me - your rails code does need to be
invoked at some point in order for it to tell apache which file to
send.

Fred

But Fred lot of experts are saying ,mongerl doesn’t render anything
while apche handle the request and one more thing how do i make sure
apache is handling is request??

On Sep 27, 12:28 pm, Amit T. [email protected] wrote:

It is when i am trying to download 2.2GB of file ,file is downloaded
completely,but my worry is why mongrel is rendering things if apache is
handling download

That looks entirely normal to me - your rails code does need to be
invoked at some point in order for it to tell apache which file to
send.

Fred

On Monday 27 September 2010, Amit T. wrote:

Fred

But Fred lot of experts are saying ,mongerl doesn’t render anything
while apche handle the request and one more thing how do i make sure
apache is handling is request??

Amir, I’m not sure, but you might be misunderstanding what xsendfile is
for and how it works. This mechanism is not intended to serve “ordinary”
static files located in the public directory of an application. Rather,
it is a way for your controller to hand off serving a file to Apache
instead of doing it from within Rails.

So, your controller has to be involved. It’s the job of the controller
action to decide which file to return in the response and then call
send_file with that file as a parameter. In the production environment,
this has the effect that the Rails process does not respond with the
file itself. Instead, Rails sets a special header which in turn is
picked up by Apache (or nginx, lighttpd) and interpreted in such a way
that it now serves the named file.

Michael


Michael S.
mailto:[email protected]
http://www.schuerig.de/michael/

On Sep 27, 2:30 pm, Amit T. [email protected] wrote:

Thanks michel
but michel i downloaded 3.2 gb of streams,but when i trying download 4
gb of stream ,i am getting only 10 mb of data…
what could be the problem
is there any restriction on file size to be served using apache
mod_xsendfile.so
module

Well the version history for mod_xsendfile says that version 0.11
fixed large file support, so i’d check you’ve got that version.
Release notes for apache 2.2 state “httpd is now built with support
for files larger than 2GB on modern 32-bit Unix systems. Support for
handling >2GB request bodies has also been added.” (http://
Overview of new features in Apache 2.2 - Apache HTTP Server Version 2.2), so I’d also check
you’ve got that. ( according to
http://instantrails.rubyforge.org/wiki/wiki.pl?Release_Notes_For_Instant_Rails_2.0
instantrails 2 uses apache 1.3.33)

Fred

Michael S. wrote:

On Monday 27 September 2010, Amit T. wrote:

Fred

But Fred lot of experts are saying ,mongerl doesn’t render anything
while apche handle the request and one more thing how do i make sure
apache is handling is request??

Amir, I’m not sure, but you might be misunderstanding what xsendfile is
for and how it works. This mechanism is not intended to serve “ordinary”
static files located in the public directory of an application. Rather,
it is a way for your controller to hand off serving a file to Apache
instead of doing it from within Rails.

So, your controller has to be involved. It’s the job of the controller
action to decide which file to return in the response and then call
send_file with that file as a parameter. In the production environment,
this has the effect that the Rails process does not respond with the
file itself. Instead, Rails sets a special header which in turn is
picked up by Apache (or nginx, lighttpd) and interpreted in such a way
that it now serves the named file.

Michael


Michael S.
mailto:[email protected]
Michael Schürig | Sentenced to making sense

Thanks michel
but michel i downloaded 3.2 gb of streams,but when i trying download 4
gb of stream ,i am getting only 10 mb of data…
what could be the problem
is there any restriction on file size to be served using apache
mod_xsendfile.so
module

Thanks fred…
but Fred i m on windows machine ,and not able to compile
mod_xsendfile.c using apxs because i don’have apxs installedon windows
could you please help me out in installing apxs on windows an i also
trying
to include mod_xsendfile.so directly in httpd.conf but failed in doing
so…

and can get direct mod_xsendfile.so for version 0.11 without compiling
the source because the mod_sendfile.so am using now ,got directly

Thanks for your kind support…

On Sep 27, 4:25 pm, Amit T. [email protected] wrote:

Thanks fred…
but Fred i m on windows machine ,and not able to compile
mod_xsendfile.c using apxs because i don’have apxs installedon windows
could you please help me out in installing apxs on windows an i also
trying
to include mod_xsendfile.so directly in httpd.conf but failed in doing
so…

Afraid I’m not a windows user (also I’ve no idea what version of
mod_xsendfile you currently have - that may not be the problem)

Fred

Frederick C. wrote:

On Sep 27, 2:30?pm, Amit T. [email protected] wrote:

Thanks michel
but michel ?i downloaded 3.2 gb of streams,but when i trying download 4
gb of stream ,i am getting only 10 mb of data…
what could be the problem
is there any restriction on file size to be served using apache
mod_xsendfile.so
module

Well the version history for mod_xsendfile says that version 0.11
fixed large file support, so i’d check you’ve got that version.
Release notes for apache 2.2 state “httpd is now built with support
for files larger than 2GB on modern 32-bit Unix systems. Support for
handling >2GB request bodies has also been added.” (http://
Overview of new features in Apache 2.2 - Apache HTTP Server Version 2.2), so I’d also check
you’ve got that. ( according to
http://instantrails.rubyforge.org/wiki/wiki.pl?Release_Notes_For_Instant_Rails_2.0
instantrails 2 uses apache 1.3.33)

Fred

Thanks fred…
but Fred i m on windows machine ,and not able to compile
mod_xsendfile.c using apxs because i don’have apxs installedon windows
could you please help me out in installing apxs on windows an i also
trying
to include mod_xsendfile.so directly in httpd.conf but failed in doing
so…

Frederick C. wrote:

On Sep 27, 4:25?pm, Amit T. [email protected] wrote:

Thanks fred…
but Fred i m on windows machine ,and not able to compile
mod_xsendfile.c using apxs because i don’have apxs installedon windows
could you please help me out in installing apxs on windows an i also
trying
to include mod_xsendfile.so directly in httpd.conf but failed in doing
so…

Afraid I’m not a windows user (also I’ve no idea what version of
mod_xsendfile you currently have - that may not be the problem)

Fred

yaa Fred you are 100% right what you said about mod_xsendfile version
issue
i loaded 0.11 version in apache cong file and able to download 4.2 GB of
file
but it took 30 min. don’t you think its huge time.
Is there any way to
reduce time ,takes to serve files

Thanks for your help…

On Sep 28, 12:24 pm, Amit T. [email protected] wrote:

Frederick C. wrote:

yaa Fred you are 100% right what you said about mod_xsendfile version
issue
i loaded 0.11 version in apache cong file and able to download 4.2 GB of
file
but it took 30 min. don’t you think its huge time.
Is there any way to
reduce time ,takes to serve files

That’s averaging 1.8MB/s which seems pretty fast to me.

Fred