Bu konuyla ilgili bir sürü soru olduğunu anlıyorum ama denediğim şeyden bağımsız olarak, benim sorunumdan farklı bir çözüm var gibi görünüyor. düzeltiyorum.WCF Servis sadece yaptığım işten bağımsız olarak 10 eşzamanlı çağrıyı idare ediyor
İşte sorun: Basit bir WCF hizmetim var. Sadece 10 eşzamanlı çağrıya izin veriyor gibi görünüyor, bundan daha fazlasını desteklemem gerekiyor. Bu, benim yapılandırmda maxConcurrentCalls
ayarlamamı ne olursa olsun. Bu durumda, sorunu basitleştirmek için bile gerçek bir Net WCF istemcisi bile istemiyorum, sadece birkaç makinede fiddler kullanarak hizmete bir grup HTTP gönderimi yapıyorum. Hepsi ayrı ayrı çalışıyorlar, ama bir seferde 10 tane geldiklerini görüyorum. # 1 bitince, # 11 başlar ve devam eder.
Hizmetim bu örnek için basit bir "30 saniye uyku ve bir dizi döndür".
Web.config'im aşağıdadır. Görebildiğim kadarıyla maxConcurrentCalls
ve maxConcurrentSessions
benim varsayılanlarımdan fazlasına krank yaptım. Bu sadece bir seferde sadece 10 eş zamanlı istek gördüğümden hiç bir etkisi yok gibi görünüyor.
Daha fazla eşzamanlı isteklere izin vermek için bunu kestirmek için hangi bölümü kaçırıyorum?
Düzenleme: Bu, IIS 7.5'de barındırılmaktadır.
Web.config:
<configuration>
<system.web>
<compilation debug="true" targetFramework="4.0" />
</system.web>
<system.webServer>
<modules runAllManagedModulesForAllRequests="true" />
<security>
<authentication>
<anonymousAuthentication enabled="true" />
</authentication>
</security>
</system.webServer>
<system.serviceModel>
<behaviors>
<serviceBehaviors>
<behavior name="">
<serviceMetadata httpGetEnabled="true" />
<serviceDebug includeExceptionDetailInFaults="false" />
<serviceThrottling
maxConcurrentCalls="32"
maxConcurrentInstances="2147483647"
maxConcurrentSessions="20"/>
</behavior>
</serviceBehaviors>
</behaviors>
<serviceHostingEnvironment multipleSiteBindingsEnabled="true" />
</system.serviceModel>
</configuration>
Hizmeti:
using System;
using System.ServiceModel;
namespace WCFTestService
{
using System.Diagnostics;
using System.Threading;
[ServiceBehavior(InstanceContextMode = InstanceContextMode.PerCall, ConcurrencyMode = ConcurrencyMode.Single)]
public class TestService : ITestService
{
public string RequestIdentifier { get; set; }
public int i;
public string DoWork(string id)
{
var secondsBeforeResponding = 20;
i++;
this.RequestIdentifier = id;
Debug.WriteLine("Request: " + id + " Instance:" + i.ToString() + " Thread:" + Thread.CurrentThread.ManagedThreadId.ToString() + " Time:" + DateTime.Now.ToString());
Thread.Sleep(secondsBeforeResponding * 1000);
Debug.WriteLine(" Done with request: " + this.RequestIdentifier);
return "Done with request: " + this.RequestIdentifier;
}
}
}
ITestService:
[ServiceContract(SessionMode = SessionMode.NotAllowed)]
public interface ITestService
{
[OperationContract]
string DoWork(string requestIdentifier);
}
Çıktı:
Request: b3 Instance:1 Thread:54 Time:4/13/2013 1:50:31 PM <!--- this is the first 10, they all start at pretty much the same time
Request: b4 Instance:1 Thread:47 Time:4/13/2013 1:50:31 PM
Request: b1 Instance:1 Thread:48 Time:4/13/2013 1:50:31 PM
Request: b2 Instance:1 Thread:45 Time:4/13/2013 1:50:31 PM
Request: b5 Instance:1 Thread:44 Time:4/13/2013 1:50:31 PM
Request: b6 Instance:1 Thread:42 Time:4/13/2013 1:50:31 PM
Request: b7 Instance:1 Thread:41 Time:4/13/2013 1:50:32 PM
Request: b8 Instance:1 Thread:39 Time:4/13/2013 1:50:32 PM
Request: b9 Instance:1 Thread:40 Time:4/13/2013 1:50:33 PM
Request: b10 Instance:1 Thread:38 Time:4/13/2013 1:50:34 PM
Done with request: b3
Done with request: b4
Done with request: b1
Done with request: b2
Request: b11 Instance:1 Thread:35 Time:4/13/2013 1:50:51 PM <--- this request only starts after the first one finishes
Request: b13 Instance:1 Thread:45 Time:4/13/2013 1:50:51 PM
Request: b14 Instance:1 Thread:54 Time:4/13/2013 1:50:51 PM
Request: b12 Instance:1 Thread:37 Time:4/13/2013 1:50:51 PM
Done with request: b5
Request: b15 Instance:1 Thread:44 Time:4/13/2013 1:50:51 PM
Done with request: b6
Request: b16 Instance:1 Thread:42 Time:4/13/2013 1:50:51 PM
Done with request: b7
Request: b17 Instance:1 Thread:41 Time:4/13/2013 1:50:52 PM
Done with request: b8
Request: b18 Instance:1 Thread:39 Time:4/13/2013 1:50:52 PM
Done with request: b9
Request: b19 Instance:1 Thread:40 Time:4/13/2013 1:50:53 PM
Done with request: b10
Request: b20 Instance:1 Thread:38 Time:4/13/2013 1:50:54 PM
...
...
...
Bu hizmet IIS'de barındırılıyor mu (hangi sürüm?) Veya kendi kendine barındırma yapıyor musunuz? –
IIS'de barındırılıyor. IIS sürüm 7.5. –
Hangi bağlayıcı kullanıyorsunuz? Ayrıca, "maxConcurrentCalls" için varsayılan değer 16 değil, 10'dur. "MaxConcurrentSesions" için varsayılan değer 10'dur. Max conccurency'i test etmek için bir istemci (bir kanal oluşturan) oluşturmak için basit bir konsol uygulaması yazmanızı öneririm. Bu durumda çalıştığını görmek için şaşırmayın. – Tim