IT:AD:Design:Blueprints:N-Tier Service Development
Summary
Separating a 3 Tier app into a 3 tier app involves
- Adding more layers of service (namely a ServiceAgent and a ServiceFacade layer)
- Using WCF
Note that adding Security to the Back Tier – the Application Tier – is not a concern unless the back tier's services are reachable by another means than the Front Tier's Presentation Tier.
The WCF trips up people, needlessly.
Process
ACID
- Advantages:
In the web, adding a middle tier has a very high cost, because the web server is already an app server. It already does database connection pooling across all users on that server. Adding an app server just adds overhead.
>The only exception here is where the web server is serving up a lot of static content and only some dynamic content. In that case, moving the data access to another machine may be beneficial because it can allow the web server to focus more on delivering the static content. It is important to realize that the dynamic content will still be delivered more slowly due to overhead, but the overall web site may work better.
>In Windows, adding a middle tier has a cost because the data needs to make two network hops to get to the user. Each network hop has a tangible cost. It would be foolish to ignore the cost of moving data over the wire, and the cost of serializing/deserializing the data on each end of the wire. These are very real, measurable costs.
>In both cases the middle tier means an extra machine to license, administer, maintain, power and cool. It is an extra point of failure, extra potential for network/CPU/memory/IO contention, etc. These costs come with every server you add into the mix. Anyone who’s ever been a manager or higher in an IT organization has a very good understanding of these costs, because they impact the budget at the end of every year.
>However, the security benefits of a middle tier are **real**.
- Disadvantages:
-
- http://www.lhotka.net/weblog/TheCostsAndSecurityBenefitsOfNtierOver2tier.aspx An important thing to remember when dealing with WCF, you only need to create a ServiceProxy for a Service you don't have access to. If you control both halves of the application – front and back – you are allowed to reuse the Service Contracts, by simply externalise the WCF Service Contracts to a Shared assembly.
O
nce externalised you gain several advantages:
- Build Servers will instantly update both Solutions (Front and Back) and break if the contact no longer works with one or the other.
- One can use the technique demonstrated below to debug in either 3 tier mode or 4 tier mode.