Chapter 23 - Three-Tier Architecture
Three-Tier Architecture lets you spread the processing of Ektron data among Three-Tiers, illustrated below. Each tier should reside on its own server.
NOTE: You may run all three tiers on a single server for development purposes only.
The following table explains the three tiers.
| Tier | Description |
|---|---|
| Data | Contains SQL and Ektron database objects (stored procedures, views, tables, etc.) |
| Application |
Full Ektron installation.
|
| Presentation |
|
Versions of Ektron that were previous to 8.5 featured Two Tier Architecture, in which the Application and Presentation tiers resided on the same server.
In Three-Tier Architecture, you can locate the Application tier in the client’s environment or an Ektron hosting environment. This represents a true separation of the Web server from the database. The Application tier does the bulk of the work, while the Presentation tier does basic processing.
IMPORTANT: You are not required to use Three-Tier Architecture—Ektron continues to run successfully on Two Tier Architecture.
NOTE: Three-Tier Architecture is different from MVC coding style, which consists of a data layer, business logic layer, and an API layer.
Three-Tier Architecture provides the following benefits.
The Presentation tier was added in Ektron Version 8.5.
The Ektron Framework API uses the Microsoft Unity Framework to inject business logic implementations into our Framework API. When running in Three-Tier mode, the Framework API on the Presentation tier uses a WCF service client implementation, thereby routing Framework API calls through WCF services, while the actual logic is running on the Application server.
To minimize network requests the between Presentation and Application tiers, Ektron includes a caching tier.
Because the business logic executes on the Application tier, its Web site directory must be identical to the Presentation tier's.
You may use eSync to move files among tiers and sites, but eSync is not a prerequisite of Three-Tier Architecture.
You can use eSync to move changes from the development to the staging to the production sites. You also can use eSync to move changes from the Data to Application tier. Then, use Web Services to move files from the Application tier to the Presentation tier. However, see Limitations of Three-Tier Architecture.
The Unity Framework provides the same developer experience, whether you use Two or Three-Tier Architecture, by defining which container to use in the web.config file. See Also: http://msdn.microsoft.com/en-us/library/dd203319.aspx, Creating a Sample Content Block in Three-Tier Architecture
NOTE: Knowledge of the Unity Framework is not required – it is mentioned to help you understand how Ektron achieves this.
Ektron has 3 main containers, which transmit data between tiers.
NOTE: Caching uses a provider model. By default, web caching is implemented, but you can replace it with other caching options.
The following shows how the Framework API uses the containers.
The following steps explain the previous illustration.
Content manager gets initialized and implements the IContentManager interface.
The Presentation tier decides which container to use, based on web.config settings. In web.config, if defaultContainer= “Default”, the Presentation tier first looks in cache for the requested data object. If the data object is not there, the Presentation tier looks in the ChildContainer property value, which is WCF by default.
On your Web Application server, install an Ektron Web site to the site root folder (if you don’t already have one). During installation, install the Ektron database to a remote SQL Server.
NOTE: The 8.5 installation includes a startersites\3TierMin\Content folder that contains files needed for the Presentation tier.
On the Web application server, copy the C:\ Program Files (x86)\Ektron\CMS400v85\startersites\3TierMin\Content folder.
On the Presentation tier server, paste that folder to the Web site root folder.
On the Presentation tier server, open IIS and make the new folder a Web Site. See Also: Creating a Web Site in IIS
On the Presentation tier server, open the site root/web.config file.
Update ek_ServicesPath to point to the workarea/services folder on your Application tier server.
<appSettings>
<!-- This is the path to your CMS App Site.
It should always end in workarea/services/ -->
<add key="ek_ServicesPath" value="http://[YOUR_CMS_SERVER]/workarea/services/" />
</appSettings>
If you want to turn on caching, set the following values in the web.config file:
<ektron.cacheProvider defaultProvider="webCache">
<providers>
<add name="webCache" cacheTimeSeconds="300" type="Ektron.Cms.Providers.Caching.WebCacheProvider,
Ektron.Cms.Providers" />
</providers>
</ektron.cacheProvider>
framework defaultContainer tag is cache, and the framework childContainer tag is WCF.<framework defaultContainer="cache"childContainer="WCF">
Open a browser and browse to your site.
This section list files in the startersites\3TierMin\Content folder. These files are copied from the Application tier server to initialize the Presentation tier when you follow Setting up Three-Tier Architecture.
App_Code folder—contains URL Aliasing module See Also: Aliasing with Three-Tier ArchitectureBin folder—subset of full bin folder; contains binaries for Presentation tier onlyWorkarea folder—subset of full Workarea folder; Framework UI is required to run templated controls and PageBuilder controls on Presentation tierEktron.cms.framework.ui—contains default templates for templated server controlsEktron.cms.framework.unity—has mapping interfaces and implementationEktron.cms.framework.ui.unity—has mapping for templated control to services<configsections> tags— <sectionGroup> settings define how the Presentation tier communicates with the Application tierek_ServicesPath—defines the path to the Application tier's Web services file
<ui.unity configSource="ektron.cms.framework.ui.unity.config" /> <ui configSource="ektron.cms.framework.ui.config" />
<ektron.framework.services> tag defines the container. See Also: Ektron's Use of the Unity Framework<ektron.framework.services> <unity configSource="ektron.cms.framework.unity.config"/> <framework defaultContainer="Default" childContainer="WCF"/> </ektron.framework.services>
If defaultContainer= “Default”, the Presentation tier first looks in cache for the requested data object. If the data object not there, the Presentation tier looks in the ChildContainer property value, which is WCF by default.
<pages> tag. Controls used by PageBuilder and templated server controls.<modules> section manages Aliasing. See Also: Aliasing with Three-Tier Architecture<system.webServer> <modules runAllManagedModulesForAllRequests="true"> <add name="EkUrlAliasModule" type="UrlAliasingModule" preCondition="integratedMode"/> </modules> </system.webServer>
This example illustrates how the same code can work in the Application and Presentation tiers. Ektron uses the Framework API to get a content item.
<asp:Label ID=”contentblock1” runat=”server”> </asp:Label>
NOTE: This example assumes that ID 30 is a valid content item in Ektron.
long id = 30;
if (!string.isNullorEmpty(Request.QueryString[“id”]))
{
long.TryParse(Request.QueryString[“id”].ToString(), out id);
}ContentManager contentManager = new ContentManager();
ContentData data = contentManager.GetItem(id); contentblock1.Text = data.Html;
This section explains how Aliasing works within Three-Tier Architecture. See Also: Creating User-Friendly URLs with Aliasing
NOTE: Aliasing code is stored in the App_Code/CSCode/UrlAliasingModule.cs file.
Three-Tier Architecture requires the Aliasing module files (UrlAliasingModule.cs and UrlAliasingBase.cs in the App_Code/CSCode folder), and the registration of that module in the web.config file. To verify the registration, follow these steps.
siteroot/web.config. See Also: Setting up Three-Tier Architecture<Modules> tag. <modules runAllManagedModulesForAllRequests="true">
<add name="EkUrlAliasModule" type="UrlAliasingModule" preCondition="integratedMode" />
</modules>
Prerequisites:
NOTE: While a Three-Tier site contains many widgets, only those built using the Framework API work on the Presentation tier.
content.pb.aspx) that exists on the Application and Presentation tiers.content.pb.aspx wireframe template is applied.The following webinar walks through each step of creating a Web site displaying news stories using the Three-Tier model: http://www.ektron.com/Resources-And-Tools/Webinars/Screencasts/Advanced-Development-in-a-3-Tier-Environment/
The following webinar introduces Three-Tier Architecture.