[Eventmachine-talk] Image sending performance

19 views
Skip to first unread message

Brian Takita

unread,
Aug 27, 2008, 9:05:13 PM8/27/08
to eventmachine-talk
Hello, we are sending image files using EventMachine and for some
reason the image files take significantly longer to send than their
text counterparts.
We are using send_data(File.read). Does anybody else have this issue?

Does ruby handle binary data inefficiently?

Thanks,
Brian
_______________________________________________
Eventmachine-talk mailing list
Eventmac...@rubyforge.org
http://rubyforge.org/mailman/listinfo/eventmachine-talk

Tony Arcieri

unread,
Aug 27, 2008, 9:15:09 PM8/27/08
to eventmac...@rubyforge.org
On Wed, Aug 27, 2008 at 7:05 PM, Brian Takita <brian....@gmail.com> wrote:
Hello, we are sending image files using EventMachine and for some
reason the image files take significantly longer to send than their
text counterparts.
We are using send_data(File.read).

Well, the problem you're going to run into is that you're first reading the entire file into memory in a single buffer, then EventMachine is building its own buffer of data to write to the connection.

I believe there's some fast file streaming stuff for EventMachine available

--
Tony Arcieri
medioh.com

Aman Gupta

unread,
Aug 28, 2008, 12:44:46 PM8/28/08
to eventmac...@rubyforge.org

Kirk Haines

unread,
Aug 28, 2008, 12:47:50 PM8/28/08
to eventmac...@rubyforge.org
Brian, if you are smaller files, use send_file_data.  Smaller is somewhat variable, but probably sits between 16k and 32k.

If you are sending larger files, use stream_file_data.

You should be able to get high transfer rates with these methods.


Kirk Haines
Reply all
Reply to author
Forward
0 new messages