c# - WCF - breaking the request is accepted at 100 concurrent requests -
faced following problem @ same time sending 100 requests server starts slow down adoption of new query, first 100 requests trigger function performed 1 minute , wait end of execution, 101 request send short call browser function prints string , number of how many requests still running in parallel.
so after 100 requests , began working in stream, 101 function quick , shows 100 threads running in parallel.
watched lot of information on internet, seems should still no result
using nf 4.5
class attributes set work in parallel c # code
[callbackbehavior(usesynchronizationcontext = false)] [servicebehavior(instancecontextmode = instancecontextmode.percall, concurrencymode = concurrencymode.multiple, maxitemsinobjectgraph = 2147483646)] [aspnetcompatibilityrequirements(requirementsmode = aspnetcompatibilityrequirementsmode.allowed)] [servicecontract(sessionmode = sessionmode.notallowed)] function emulation load 1 minute c # code
private static int threads11 = 0;
[operationcontract] [webget(bodystyle = webmessagebodystyle.bare, responseformat = webmessageformat.json)] public string loadconcurency() { threads11++; var count = 0; while (count < 6000) { count++; thread.sleep(10); } threads11--; return "1"; } function test statistic c # code
[operationcontract] [webget(bodystyle = webmessagebodystyle.bare, responseformat = webmessageformat.json)] public string reporttest() { try { stringbuilder response = new stringbuilder().appendline("threads=" + threads11.tostring() + "; "); response.appendline(); return response.tostring(); } catch (exception ex) { return ex.tostring() + (ex.innerexception == null ? "" : ex.innerexception.tostring()); } } servicethrottling set high
<behavior name="servicebehavior"> <servicemetadata httpgetenabled="true" /> <servicedebug includeexceptiondetailinfaults="true" /> <servicethrottling maxconcurrentcalls="3000" maxconcurrentsessions="30000" maxconcurrentinstances="3000" /> </behavior> i hope met such problem , prompt problem, or @ least give advice else dig
sorry automatic translation.
i did not consider factor pool of input , output streams default minimum pool number of cores cpu cycles, such i, equal 4 maximum value 1023, why had problems when trying make 100 threads??
the answer when go beyond minimum threshold, server not allocate new thread, , waits 0.5 seconds freed 1 of employees, , if still not found free allocates new thread .. taking account 100 connections need keep, first 4 taken process instantly, other 96 took approximately 96 seconds * 0.5 = 48 seconds, next 101 test call waiting 48 seconds!
solution:
threadpool.setminthreads (4, 100); i sure answer , work useful someone, , not give lot of time kill :)
sources:
http://msdn.microsoft.com/ru-ru/library/system.threading.threadpool.setminthreads.aspx
Comments
Post a Comment