Hosting more than 25 WCF services in Azure -
we're running azure's limit of 25 internal endpoints our wcf services. in keeping soa principles, our wcf services small, 1 per "noun" in our system. defining 1 azure internalendpoint per service contract. want add our 26th wcf service can't because of limit of 25 endpoints. don't want arbitrarily start combining service contracts because of azure limitation.
question: there better way host lots of wcf services doesn't require 1 endpoint per service contract?
here's example csdef file snippet:
<servicedefinition name="mydeployment" xmlns="http://schemas.microsoft.com/servicehosting/2008/10/servicedefinition"> <workerrole name="myworkerrole" vmsize="small"> <endpoints> <internalendpoint protocol="tcp" name="iuserservice" /> <internalendpoint protocol="tcp" name="iarticleservice" /> <internalendpoint protocol="tcp" name="idocumentservice" /> <internalendpoint protocol="tcp" name="icommentingservice" /> <internalendpoint protocol="tcp" name="ilocationservice" /> <internalendpoint protocol="tcp" name="iauthorizationservice" /> <internalendpoint protocol="tcp" name="iauthenticationservice" /> <internalendpoint protocol="tcp" name="iloggingservice" /> <internalendpoint protocol="tcp" name="iservice09" /> <internalendpoint protocol="tcp" name="iservice10" /> <!-- , on --> <internalendpoint protocol="tcp" name="iservice24" /> <internalendpoint protocol="tcp" name="iservice25" /> <internalendpoint protocol="tcp" name="iservicewewanttoaddbutcannot" /> </endpoints> </servicedefinition>
as mentioned in comment question, don't think need of internalendpoints
have. pairing one-to-one wcf endpoints. wrong. instead, pair them wcf bindings/behaviors (i.e. 1 per port, really). in our case, have ~250 different wcf services going through 1 endpoint. here 100% of our endpoints our csdef
file:
<endpoints> <inputendpoint name="wcfconnections" protocol="tcp" port="8080" localport="8080" /> </endpoints>
(while use inputendpoint
instead of internalendpoint
, there should no difference question's perspective.)
that single endpoint utilized 3 different nettcpbindings
in our self-hosted tcp service application. have web app version of our tcp services (for easy local dev hosting/testing in iis) , bindings use are:
<bindings> <nettcpbinding> <binding name="a" maxbufferpoolsize="5242880" maxbuffersize="5242880" maxreceivedmessagesize="5242880" listenbacklog="100" maxconnections="1000"> <readerquotas maxdepth="256" maxstringcontentlength="16384" maxarraylength="16384" maxbytesperread="4096" maxnametablecharcount="16384" /> <security mode="transport"> <transport clientcredentialtype="certificate" /> </security> </binding> <binding name="b" maxbufferpoolsize="15728640" maxbuffersize="15728640" maxreceivedmessagesize="15728640" listenbacklog="100" maxconnections="1000"> <!-- 15mb max size --> <readerquotas maxdepth="256" maxstringcontentlength="15728640" maxarraylength="15728640" maxbytesperread="204800" maxnametablecharcount="15728640" /> <security mode="transport"> <transport clientcredentialtype="certificate" /> </security> </binding> <binding name="c" maxbufferpoolsize="524288" maxbuffersize="524288" maxreceivedmessagesize="524288" listenbacklog="100" maxconnections="1000"> <!-- 0.5mb max size --> <readerquotas maxdepth="256" maxstringcontentlength="524288" maxarraylength="524288" maxbytesperread="204800" maxnametablecharcount="524288" /> <security mode="transport"> <transport clientcredentialtype="certificate" /> </security> </binding> </nettcpbinding> </bindings>
in end, long you're willing share multiple services per port (except very high-load situations, should fine proper self-hosting app), you're doing unnecessary.
perhaps larger problem , question need learn ask is, "how can host multiple services on single port in self-hosted wcf app?" if that's case, check out code (note, endpoint
object use in loop struct holds few key pieces of each wcf endpoint):
// build services var hosts = new list<servicehost>(); foreach (var endpoint in endpoints) { var host = new servicehost(endpoint.servicetype, new uri(string.format("net.tcp://{0}:{1}", fullyqualifiedhostname, sharedtcpportnumber))); hosts.add(host); foreach (var behavior in mybehaviorsettings) { if (behavior servicedebugbehavior) host.description.behaviors.find<servicedebugbehavior>().includeexceptiondetailinfaults = (behavior servicedebugbehavior).includeexceptiondetailinfaults; else host.description.behaviors.add(behavior); } if (endpoint.servicecontract == null) throw new exception(); if (endpoint.servicebinding == null) throw new exception(); if (endpoint.endpointurl == null) throw new exception(); if (endpoint.listenurl == null) throw new exception(); // add endpoint myservice host.addserviceendpoint(endpoint.servicecontract, endpoint.servicebinding, endpoint.endpointurl, new uri(endpoint.listenurl)); host.open(); }
Comments
Post a Comment