3-Tier Architecture

3-Tier Architecture lets you spread the processing of Ektron data among 3-Tiers, illustrated below. Each tier should reside on its own server.

NOTE: You may run all 3 tiers on a single server for development purposes only.

 

The following explains the 3 tiers.

—3 Tiers—
  • Data—Contains SQL and Ektron database objects (stored procedures, views, tables, and so on).
  • Application—Full Ektron installation.
    • Ektron DLLs
    • Ektron Workarea
    • Ektron Windows Services
    • Ektron WCF Services
    • Custom WCF Services
  • Presentation
    • Handles site visitor requests and displays Web pages
    • Minimal footprint, lightweight
    • Requires IIS
    • No Ektron installation
    • Contains
      • Standard ASP.NET Web site
      • Minimal set of Ektron.dlls in bin folder
      • Configuration files (web.config, unity.config)
      • Workarea required only if Web site uses PageBuilder or templated server controls.

      See Also: The Presentation Tier

NOTE: To communicate between servers, you can choose any unused port. If you choose a port other than 80, Ektron recommends using one outside of the well-known port range (0 to 1023).

Versions of Ektron previous to 8.5 featured 2-Tier Architecture, in which the Application and Presentation tiers resided on the same server. In 3-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 3-Tier Architecture—Ektron continues to run successfully on 2-Tier Architecture.

NOTE: 3-Tier Architecture is different from MVC coding style, which consists of a data layer, business logic layer, and an API layer.

Benefits of 3-tier architecture

Benefits of 3-Tier Architecture

3-Tier Architecture provides the following benefits.

  • Scalability—Each tier can scale horizontally. For example, you can load-balance the Presentation tier among 3 servers to satisfy more Web requests without adding servers to the Application and Data tiers.
  • Performance—Because the Presentation tier can cache requests, network utilization is minimized, and the load is reduced on the Application and Data tiers. If needed, you can load-balance any tier.
  • Availability—If the Application tier server is down and caching is sufficient, the Presentation tier can process Web requests using the cache.
The presentation tier

The Presentation Tier

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 3-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.

Limitations of 3-tier architecture

Limitations of 3-Tier Architecture

  • You must manually push templates, assets, private assets, uploaded images, and uploaded files from the Application tier to the Presentation tier. You may use a tool like Robocopy to do this.
  • You create content (HTML, assets, PageBuilder pages, and so on) only in the Application tier. You can only view content from Presentation tier.
  • Because 3-Tier Architecture uses WCF, it requires:
    • the 8.5 or higher Framework API and databinding. You cannot use API calls outside of the Framework API.
    • templated server controls.
    • widgets created by the Framework API.
  • Because the business logic executes on the Application tier, its Web site directory must be identical to the Presentation tier's.

Using eSync with 3-tier architecture

Using eSync with 3-Tier Architecture

You may use eSync to move files among tiers and sites, but eSync is not a prerequisite of 3-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 3-Tier Architecture.

Impact of 3-tier setup on developer

Impact of 3-Tier Setup on Developer

The Unity Framework provides the same developer experience, whether you use 2- or 3-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 3-Tier Architecture

Ektron's use of the Unity Framework

Ektron's Use of the Unity Framework

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.

  • Business object (BusinessObjects.Content)
    • contains the implementation of business logic for Ektron
    • used in 2-Tier Architecture
    • in 3-Tier Architecture, executed in the Application tier
  • WCF service proxy (Framework.Services.Content.ContentServiceClient)
    • used in 3-Tier Architecture to communicate between Application and Presentation tiers
  • Cache (BusinessObjects.Caching.Content)
    • Ektron uses the Unity Framework to insert a caching layer.
    • When an API call is made (or a templated server control is used) from the Presentation tier, Ektron caches frequently-used objects.
    • Caching minimizes API calls between Application and Presentation 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.

  1. Content manager gets initialized and implements the IContentManager interface.

  2. 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.

Setting up 3-tier architecture

Setting up 3-Tier Architecture

  1. 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 and higher installation includes a startersites\3TierMin\Content folder that contains files needed for the Presentation tier.

  2. On the Web application server, copy the C:\ Program Files (x86)\Ektron\CMS400v8x\startersites\3TierMin\Content folder.

  3. On the Presentation tier server, paste that folder to the Web site root folder.

  4. On the Presentation tier server, open IIS and make the new folder a Web Site. See Also: Creating a Web Site in IIS

     

  5. On the Presentation tier server, open the site root/web.config file.

  6. 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>
  7. 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>
  8. And make sure the value of the framework defaultContainer tag is cache, and the framework childContainer tag is WCF.
    <framework defaultContainer="cache" childContainer="WCF">
  9. Open a browser and browse to your site.

  10. Deploy templates and supporting files to the Presentation server.
Files copied to the presentation tier

Files Copied to the Presentation Tier

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 3-Tier Architecture.

  • App_Code folder—contains URL Aliasing module See Also: Aliasing with 3-Tier Architecture
  • Bin folder—subset of full bin folder; contains binaries for Presentation tier only
  • Workarea folder—subset of full Workarea folder; Framework UI is required to run templated controls and PageBuilder controls on Presentation tier
  • The following configuration files:
    • Ektron.cms.framework.ui—contains default templates for templated server controls
    • Ektron.cms.framework.unity—has mapping interfaces and implementation
    • Ektron.cms.framework.ui.unity—has mapping for templated control to services
  • Within web.config
    • Within <configsections> tags— <sectionGroup> settings define how the Presentation tier communicates with the Application tier
    • ek_ServicesPath—defines the path to the Application tier's Web services file

    • The following UI elements for templated server controls
      <ui.unity configSource="ektron.cms.framework.ui.unity.config" />
      <ui configSource="ektron.cms.framework.ui.config" />
  • The <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.

  • content of <pages> tag. Controls used by PageBuilder and templated server controls.
  • The <modules> section manages Aliasing. See Also: Aliasing with 3-Tier Architecture
    <system.webServer>
    <modules runAllManagedModulesForAllRequests="true">
    <add name="EkUrlAliasModule" type="UrlAliasingModule" preCondition="integratedMode"/>
    </modules>
    </system.webServer>
Creating a sample content block in 3-tier architecture

Creating a Sample Content Block in 3-Tier Architecture

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.

  1. In Visual Studio, open the Presentation tier's Web site. See Also: Setting up 3-Tier Architecture
  2. Add a new Web form.
  3. Add a label control that can render a content block.
    <asp:Label ID=”contentblock1” runat=”server”> </asp:Label>
  4. Open the form’s code-behind file.
  5. Insert the following code.

    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);
    }
  6. While in the code-behind file, initialize content manager as the logged in user.
    ContentManager contentManager = new ContentManager();
  7. Get the content and return it to the asp Label control.
    ContentData data = contentManager.GetItem(id);
    contentblock1.Text = data.Html;
  8. Build and run.
  9. Open a Web browser.
  10. Insert the Presentation server/page you just created into your browser address field, where you will see Ektron content through the Presentation tier.
Aliasing with 3-tier architecture

Aliasing with 3-Tier Architecture

This section explains how Aliasing works within 3-Tier Architecture. See Also: Creating User-Friendly URLs with Aliasing

NOTE: Aliasing code is stored in the App_Code/CSCode/UrlAliasingModule.cs file.

Requirements

Requirements

3-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:

  1. In the Presentation Web site, open siteroot/web.config. See Also: Setting up 3-Tier Architecture
  2. Go to the <Modules> tag.
  3. Verify that the URL alias module is registered, as shown below.
    <modules runAllManagedModulesForAllRequests="true">
    <add name="EkUrlAliasModule" type="UrlAliasingModule" preCondition="integratedMode" />
    </modules>
Testing URL aliasing

Testing URL Aliasing

  1. Go to the Application tier Web site.
  2. Create a content block.
  3. On its Alias tab, enter a manual alias.
     

  4. On the Template tab, choose a template that exists on the Application and Presentation tiers.
  5. Publish the content.
  6. Verify that Aliasing works on the Application tier.
  7. Verify that Aliasing works on the Presentation tier.
Using PageBuilder with 3-tier architecture

Creating a PageBuilder Page with 3-Tier Architecture

Prerequisites:

  • A PageHost file in the Presentation tier used specifically to support 3-Tier Architecture. The file lets you view only; you cannot edit.
  • A widget built using the Framework API (for example, the sample Content Block widget)

    NOTE: While a 3-Tier site contains many widgets, only those built using the Framework API work on the Presentation tier.

  • A wireframe template (content.pb.aspx) that exists on the Application and Presentation tiers.
  1. Go to the Application tier Web site's Workarea.
  2. Create a sample PageBuilder page. See Also: Building Pages
  3. Navigate to a folder to which the content.pb.aspx wireframe template is applied.
  4. Create new Page Layout.
  5. Drag and drop a content block widget onto the page layout and assign an Ektron content item.
  6. Publish.
  7. Browse to the Presentation Web site to see the content.
Use case for setting up 3-tier architecture

Use Case for Setting up 3-Tier Architecture

The following webinar walks through each step of creating a Web site displaying news stories using the 3-Tier model: http://www.ektron.com/Resources-And-Tools/Webinars/Screencasts/Advanced-Development-in-a-3-Tier-Environment/

The following webinar introduces 3-Tier Architecture.