I noticed that when called by XHR, ASMX webservices can handle very few concurrent requests. Consider the following scenario:
ASPX Page:
<asp:ScriptManager ID="scrManager" runat="server">
<Services>
<asp:ServiceReference Path="~/WebService.asmx" />
</Services>
</asp:ScriptManager>
WebService Method:
[WebMethod]
public string HelloWorld()
{
Thread.Sleep(1000);
return "Hello World";
}
And the Javascript code that calls it:
$(document).ready(function () {
var ws = new WebApplication1.WebService();
for (var i = 0; i < 100; i++) {
var start = new Date().getTime();
function sucesso() {
var end = new Date().getTime();
var time = end - start;
console.log('Duração: ' + time);
}
ws.HelloWorld(sucesso, function () { alert("erro"); });
}
});
And the result is more or less this:
Iexpectedeachrequesttotakeapproximately1s,butforevery5ormorerequests,thewaitingtimeincreases.Thatis,therequestwasputonholdastherewereotheropenconnections.Myquestionis:howtoincreasethenumberofsimultaneousrequests,sothatmorecallstakethesametime.Iknowitwouldnotbegoodifthe100requestswereopenedatonetime,butIfindthenumberveryfewthatIcurrentlyhave.
Searchingaround,Ifoundthefollowingconfiguration(web.config)butitdidnotwork:
<system.net><connectionManagement><addaddress="*" maxconnection="40"/>
</connectionManagement>
</system.net>
Note: I know that web services made with asmx are a legacy technology, but I have a whole large system that uses them on the front end, similarly to the one exposed here. It is not an option now to change the technology.