MalcomTucker
MalcomTucker

Reputation: 7477

Is breaking apart a WCF service into separate, more cohesive services a good idea?

I have a number of different units of functionality that need to be implemented within a WCF service (or services). It strikes me that there are a number of advantages to splitting apart these units into their own services:

But there are costs:

I'm particularly interested in the last cost. Does the overhead of running two services outweigh the benefits where those services are small (say two or three very light operations)?

If breaking them apart is a good idea, on what lines should I undertake the division? I could split services strictly by function, or by their InstanceMode, or by their hosting type (IIS v Windows). Is there a general approach or set of advice that applies here?

Appreciate any advice.

Upvotes: 1

Views: 322

Answers (2)

Henk Holterman
Henk Holterman

Reputation: 273179

Splitting it into multiple services does not necessarily mean splitting it into multiple applications.
But you might as well, to get robustness and scalability.

So, Yes, do split them into the smallest cohesive units.
It's better to do so early, breaking up an existing service will be much more complicated.


Additional

You should break up by functionality, that just means defining multiple [ServiceContract] definitions.

And you simply have to separate by hosting type (IIS/WinService).

That leaves the question whether multiple Services (eg on IIS) should be 1 app, sharing datalayers etc. That has some short-term benefits, and services that are tightly couples should probably be combined.

But in general, creating separate apps provides the best scalability and availability and better options to change.

Upvotes: 1

Preet Sangha
Preet Sangha

Reputation: 65476

Like all things it depends. Personally with things like appfabric you can just scale out the services easily and use IIS and Windows to help with robustness.

Sure smaller surface area is good, but why bother unless there are metrics that prove you need it. Use the WCF infrastructure first.

Upvotes: 0

Related Questions