We regularly have a hundred thousand sockets open, and an Erlang process per socket. We don't do high throughput I/O to each of those clients, but Erlang processes are *not* operating system level threads.<div>Also, binaries on the heap are shared across processes, if they are bigger than some limitation -- I think it's 64 bytes.</div>
<div><br></div><div>Thus, you COULD have some process that pre-loads files into binaries. Then, when a socket connects and asks for data, you ask for that binary from that process, and then write that binary to the socket. One Erlang process per socket.</div>
<div>This would be a super simple implementation and probably very robust. I don't know if it will scale to the I/O throughput that you request, but it certainly would have a chance to do so.</div><div><br></div><div>
Sincerely,</div><div><br></div><div>jw</div><div><br clear="all"><br>--<br>Americans might object: there is no way we would sacrifice our living standards for the benefit of people in the rest of the world. Nevertheless, whether we get there willingly or not, we shall soon have lower consumption rates, because our present rates are unsustainable. <br>
<br>
<br><br><div class="gmail_quote">On Wed, Dec 14, 2011 at 3:35 PM, Max Lapshin <span dir="ltr"><<a href="mailto:max.lapshin@gmail.com">max.lapshin@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div class="im">On Thu, Dec 15, 2011 at 2:23 AM, Lukas Larsson<br>
<<a href="mailto:lukas@erlang-solutions.com">lukas@erlang-solutions.com</a>> wrote:<br>
> You might be interested in the new (R15B) file:sendfile function, if having<br>
> the data on disc is an option.<br>
><br>
<br>
</div>I think, that something like vmsplice may be an option. I see in<br>
sources of file, that prim_inet:getfd is no here (yes, I know that it<br>
is undocumented =)<br>
and that is why I may use some weird tricks with optimizing.<br>
<br>
sendfile is a bad option because:<br>
1) I need to serve from memory<br>
2) I need to serve several thousands of connections. Threads are not<br>
the way to go.<br>
<br>
However, I think that I will need to patch efile_drv for using<br>
something like vmsplice<br>
<div class="HOEnZb"><div class="h5">_______________________________________________<br>
erlang-questions mailing list<br>
<a href="mailto:erlang-questions@erlang.org">erlang-questions@erlang.org</a><br>
<a href="http://erlang.org/mailman/listinfo/erlang-questions" target="_blank">http://erlang.org/mailman/listinfo/erlang-questions</a><br>
</div></div></blockquote></div><br></div>