WCF 3.5 vs 4.0 RESTful Services Performance
I have some WCF RESTful services that were developed with WCF 3.5 + RESTful Starter Kit. I have ran into many of the same complaints where it is not extremely performant and does not handle a burst of requests very well. I am thinking that part of this reason was that the RESTful features in 开发者_Python百科3.5 were more of a community add-on.
Now that WCF 4.0 RESTful services have been out for a while, I presumed that there are some people who have developed with it and are using it in a production environment.
I was looking at using the WCF REST Service Template 40(CS) and was seeing if anyone has had any performance/scalability issues with it. I was also checking to see if there has been any comparisons done for performance/scalability between WCF 3.5 and WCF 4.0's RESTful services. Doing a quick Google search didn't yield a lot of results.
Any feedback would be much appreciated.
Edit
Per request here is my configuration:
<bindings>
<webHttpBinding>
<binding name="TransportWeb">
<security mode="Transport">
<transport clientCredentialType="None"/>
</security>
</binding>
</webHttpBinding>
</bindings>
<services>
<service behaviorConfiguration="SecureBehavior" name="Service">
<endpoint address="" binding="webHttpBinding" bindingConfiguration="TransportWeb" behaviorConfiguration="REST" contract="IServce"/>
<endpoint address="mex" binding="mexHttpsBinding" contract="IMetadataExchange"/>
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior name="SecureBehavior">
<serviceMetadata httpGetEnabled="false" httpsGetEnabled="true"/>
<serviceDebug includeExceptionDetailInFaults="true"/>
</behavior>
</serviceBehaviors>
<endpointBehaviors>
<behavior name="REST">
<webHttp/>
</behavior>
</endpointBehaviors>
</behaviors>
Before we blame the framework technology you built on, tell us more about your particular implementation. I've personally found every facet of WCF itself to be scalable beyond belief when properly leveraged. More often than not, you'll find it's the specific implementation/configuration that one has put together that is to blame.
So here's some questions about your implementation that can hopefully help the community help you better:
- What kind of requests are you fielding?
- What features of the starter kit are you using?
- How are your bindings configured?
- Are you streaming any binary data in or out?
- Are you using any security? (SSL, user/pass, etc.)
- Are you performing any long running tasks for any requests?
Update 1
So everything looks good from a bindings perspective and from what you're explaining it sounds like you've got a pretty "vanilla" WCF service here. It doesn't sound like you're using any of the WCF 3.5 REST Starter Kit framework at all from your description though, so I'm not sure if you're leaving some details out or if you were just mistaken in saying that you use it.
One thing that I noticed you did not do however in your service configuration was set any explicit <serviceThrottling>
values. By default in .NET 3.5 the max number of concurrent calls is only 16. So, depending on the duration of your calls and the saturation at any given point from your clients, you could be held up there. If you check out this MSDN section titled Optimizing WCF Web Service Performance you'll see some guidance that recommends actually configuring maxConcurrentCalls
to be 16 per core. That's one place where .NET 4 differs because they actually do the 16 * number of cores automatically for you if you don't specify an explicit value of your own. Naturally the only way to find the sweet spot for your application is through load testing and playing with the number.
All that said, there's not much more I can see being wrong from the information you've provided. If you tell us more about the internals of your web service perhaps we can make some better recommendations on how to achieve better performance. For all we know at this point your bottleneck could be at some database that you interact with.
So, to answer the title of this question: At this point I don't think there's anything holding you back because you're using 3.5. There are certainly some performance improvements in 4.0, but you're not talking mega-scale here or anything and, like I said, you're not really doing any complicated WCF customization or anything according to your description.
See http://blogs.msdn.com/b/endpoint/archive/2011/05/04/wcf-scales-up-slowly-with-bursts-of-work.aspx for more information about a reason and solution to this.
You do have a database call according to your comment. Considering how the threadpool works you should always be vary against synchronous IO bound operations where you need high throughput.
精彩评论