We're trying to build an app that uses ibrowse to make concurrent requests. We are not able to get more than a few concurrent requests at a time to return successfully. We repeatedly get "conn_failed" (when we know the sites are available). It seems like we are running out of sockets when we loop through our list of URLs.<br>
<br>Here's how it happens. We start ibrowse and run our test code. The first loop of about 60 requests so goes fine. A few seconds later, a second loop returns fewer; the third loop fewer still. The more requests we make, the fewer successful requests we have.<br>
<br>Others appear to have had this problem (see <a href="http://www.trapexit.org/forum/viewtopic.php?p=44231">http://www.trapexit.org/forum/viewtopic.php?p=44231</a>). We've tried tweaking the settings of two machines with different distros (openSUSE 10.3 and Fedora Core 4). After making the adjustments on each machine, csh limit says we have 30000 descriptors (set through a modification we made to /etc/security/limits.conf. The /etc/sysctl.conf file has the following settings.<br>
<br>net.ipv4.conf.all.rp_filter = 1<br>#net.ipv6.conf.all.forwarding = 1<br>fs.inotify.max_user_watches = 65536<br>net.core.rmem_max = 16777216<br>net.core.wmem_max = 16777216<br>net.ipv4.tcp_rmem = 4096 87380 16777216<br>
net.ipv4.tcp_wmem = 4096 65536 16777216<br>net.ipv4.tcp_syncookies = 1<br>net.ipv4.ip_local_port_range = 1024 4999<br>net.ipv4.tcp_mem = 50576 64768 98152<br>net.core.netdev_max_backlog = 2500<br>kern.maxfiles = 25000<br>
kern.maxfilesperproc = 20000<br><br>We'd be happy if we could get a few thousand requests to return successfully. What are we doing wrong?<br><br>Here is one way we have tried invoking ibrowse (probably the simplest).<br>
<br>-module(test7).<br>-export([run/0, send_reqs/0, do_send_req/1]).<br><br>run() -><br> proc_lib:spawn(?MODULE, send_reqs, []).<br> <br>some_urls() -><br>
["<a href="http://www.url1.com">http://www.url1.com</a>",<br>
"<a href="http://www.url2.com">http://www.url2.com</a>"<br>
%% and so on...<br>
].<br>send_reqs() -><br> spawn_workers(some_urls()).<br><br>spawn_workers(Urls) -><br> lists:foreach(fun do_spawn/1, Urls).<br><br>do_spawn(Url) -><br> proc_lib:spawn_link(?MODULE, do_send_req, [Url]).<br>
<br>do_send_req(Url) -><br> Result = (catch ibrowse:send_req(Url, [], get, [], [], 10000)),<br> case Result of <br> {ok, SCode, _H, _B} -><br> io:format("~p ~p~n", [Url, SCode]);<br>
Err -><br> io:format("~p~p~n", [Url, Err])<br> end.<br> <br>Here are some references that have helped us get this far (which unfortunately isn't that far at all). :)<br><br>Sockets/File Descriptors<br>
<a href="http://oscar.hellstrom.st/blog/2007/04/benchmarking-with-tsung">http://oscar.hellstrom.st/blog/2007/04/benchmarking-with-tsung</a><br><a href="http://www.cs.uwaterloo.ca/~brecht/servers/openfiles.html">http://www.cs.uwaterloo.ca/~brecht/servers/openfiles.html</a><br>
<br>TCP<br><a href="http://www.metabrew.com/article/tag/http/">http://www.metabrew.com/article/tag/http/</a><br><a href="http://ipsysctl-tutorial.frozentux.net/ipsysctl-tutorial.html">http://ipsysctl-tutorial.frozentux.net/ipsysctl-tutorial.html</a><br>
<br>Any help will be much appreciated!<br><br>Steve<br>