Site Coordination Models

From ControlTier

Jump to: navigation, search

Contents

Overview

It's unlikely you have just a few isolated Service deployments in your environment. It is more likely that you have sets of like services spread across multiple hosts. If you are running multi-tier applications, you will also have dependencies between some of those services.

Services can be grouped together so you can control them as one logical entity, through a Site. A Site is an object that aggregates a set of Services. You can also roll up multiple Site objects into a root Site object. This allows you to scale up your management and consolidate control into a single point.

This document describes several ways you can organize the services in your environment to help cope with large scale and coordinated control across homogeneous and heterogeneous sets of services.

Command dispatching

Sites really play the role of a logical control point, relaying the requested action to set of Services (or Sites). Sites and Services share a common set of workflows, including: Stop, Start, Status, Deploy. When a Site is asked to execute "Status", it relays the Status command to each of its Service resources and invokes each of them to run Status.

Topological Structures: Tier, Slice, Pool

One can describe the way the constituent services of an application are interrelated and arranged comprise that software system's structure, or topology.

A Site object allows you to arrange any number of Service and Site objects. You are free to invent any arrangement to suit your environment but there three patterns that are commonplace:

Site-structures.png

Ultimately, Site objects allow you to provide the shape for how you want to manage sets of Services. Sites allow you define hierarchical control structures, important when you want to have activity governed by the application topology.

Ordering

Ordering the progression of action is important for controlling application deployments with runtime state. You can establish an ordering to the Site's control dispatching in one of several ways discussed below.

Relative ranking

Even among like Service resources it is sometimes desirable to have the Site dispatch commands in a particular order.

Both Service and Site objects have a property called "startuprank" that allow you assign a ranking position. By default, Sites use startuprank as a key to sort the Service resources in ascending order.

The graphic below depicts a set of Services that range from a startuprank of 1 through 3.

Note that this works as long as the thread count is 1

Service-ranking.png

Given that arrangement, the "staging" Site will dispatch first to rank=1, rank=2 and finally, to rank=3. For example, if "Start" command was called on the Site, it would first invoke Start on dev-catalog , next tomcat1, then apache1. This ensures that dev-catalog is up and running before tomcat1 starts, presumably because Tomcat will need to connect to a running dev-catalog database.

The "Stop" command is an notably different. It sorts by startuprank in descending order. This supports the assumption that you want to shut down in the reverse order of Start. It is best practice to shutdown clients before their servers to avoid hanging connections or cause transactional interruptions. So for this example, the Stop action will first stop apache1 (closing connections to tomcat1), then stop tomcat1 (closing connections to dev-catalog), finally stopping dev-catalog.

Hierarchical

The next manner in which actions can be ordered is based on the topology of the Site and Service resources. Using this approach, A top-level Site dispatches to intermediate Site objects, which in turn dispatch to their Services.

The graphic below describes an example showing how a set of services arranged as a tier, and another set arranged as a slice is managed via a top level Site.

Nested-sites.png

Combined

The two methods of ordering can be combined to first sort by relative ranking, and then via topological structure.

Pool-example1.png

Setup

The following sections provide examples of project XML files that define the various arrangements of Services and Sites.

Tier

The following project.xml defines two Apache HTTPD server instances grouped together in a Site.

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE project PUBLIC "-//ControlTier Software Inc.//DTD Project Document 1.0//EN" 
    "project.dtd">
<project>
  <!--
      **
      ** Describes set of homogeneous Services mediated via a Site
      **
  -->
  
  <!--
      **
      ** Describes an Apache web server:
      **
  -->
  <deployment 
      type="Service"
      name="apache1" 
      description="The Apache server."
      startuprank="3"/>

 
  <deployment 
      type="Service"
      name="apache2" 
      description="The Apache server."
      startuprank="3"/>

  <!--
      **
      ** Describes the site:
      **
  -->
  <deployment 
      type="Site"
      name="apacheTier" 
      description="The integrated site in the staging environment." >

     <!--
      **
      ** References the services as child dependencies
      **
      -->
     <resources>
      <resource name="apache1" type="Service" />
      <resource name="apache2" type="Service" />
     </resources>
  </deployment>

</project>	

Slice

The following project.xml provides an example for defining a set of interrelated set of heterogeneous Services.

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE project PUBLIC "-//ControlTier Software Inc.//DTD Project Document 1.0//EN" 
    "project.dtd">
<project>
  <!--
      **
      ** Describes an integrated set of Services mediated via a Site
      **
  -->
  

  <!--
      **
      ** Describes a Mysql relational database
      **
  -->
  <deployment 
      type="RdbService"
      name="dev-catalog" 
      description="The Mysql database." 
      startuprank="1"/>

  <!--
      **
      ** Describes a Tomcat server
      **
  -->
  <deployment 
      type="Service"
      name="tomcat1" 
      description="The tomcat server." 
      startuprank="2">
     <!--
      **
      ** References the dev-catalog as a child dependency
      **
      -->
     <resources>
      <resource name="dev-catalog" type="RdbService" />
     <resources>
  </deployment>

  <!--
      **
      ** Describes an Apache web server:
      **
  -->
  <deployment 
      type="Service"
      name="apache1" 
      description="The Apache server."
      startuprank="3">
     <!--
      **
      ** References the tomcat as a child dependency
      **
      -->
     <resources>
      <resource name="tomcat1" type="Service" />
     <resources>
  </deployment>


  <!--
      **
      ** Describes the site:
      **
  -->
  <deployment 
      type="Site"
      name="slice" 
      description="The integrated site in the staging environment." >

     <!--
      **
      ** References the services as child dependencies
      **
      -->
     <resources>
      <resource name="apache1" type="Service" />
      <resource name="tomcat1" type="Service" />
      <resource name="dev-catalog" type="RdbService" />
     </resources>
  </deployment>

</project>	

Pool

The following project.xml example shows two sets of Services arranged as tiers grouped together under a common Site.

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE project PUBLIC "-//ControlTier Software Inc.//DTD Project Document 1.0//EN" 
    "project.dtd">
<project>
  <!--
      **
      ** Describes pool of Tiers
      **
  -->
  
  <!--
      **
      ** Describes tier 1
      **
  -->
  <deployment 
      type="Site"
      name="webTier-evens" 
      description="The even numbered apache web server instances .">
     <resources>
      <resource name="apache2" type="Service" />
      <resource name="apache4" type="Service" />
      <resource name="apache6" type="Service" />
     </resources>
  </deployment>

  <!--
      **
      ** Describes tier 2
      **
  -->
  <deployment 
      type="Site"
      name="webTier-odds" 
      description="The odd numbered apache web server instances .">
     <resources>
      <resource name="apache1" type="Service" />
      <resource name="apache3" type="Service" />
      <resource name="apache5" type="Service" />
     </resources>
  </deployment>

  <!--
      **
      ** Describes the pool
      **
  -->
  <deployment 
      type="Site"
      name="webPool" 
      description="Combines all the web slices into one pool .">
     <resources>
      <resource name="webTier-evens" type="Site" />
      <resource name="webTier-odds" type="Site" />
     </resources>
  </deployment>

</project>	

Execution

This section describes how to execute commands against Services via a Site.

The general usage to run a command via a Site is:

ctl -p project -t Site -r resource -c command

Example: Dispatch the Status command to the Services in the webTier Site:

ctl -p default -t Site webTier -c Status

Service management

Site objects can dispatch the following standard commands to Service resources: Prepare, Restart, Start, Status, Stop, Change-Dependencies, Configure, Deploy, Install, Properties, Update

Ad-hoc filtered dispatching

Besides using the standard Service management commands described above, you can also dispatch abitrarily via the command, dispatchCmd.

For example, if you want to tell each of the Service resources to run Status:

ctl -p default -t Site -r webTier -c dispatchCmd -- -command Status

... which is equivalent to:

ctl -p default -t Site webTier -c Status

A more interesting usage is to dispatch a command only to a subset of the Services using filtering. There are two options enabling filtering: -resourcename, to filter by the Service's name, and -resourcetype to filter by the Service's type. By default, these options are defaulted to wild card patterns to match all the Services.

Here's a couple examples showing off filtering. The first example dispatches to just the Services that have names starting with "tomcat":

ctl -p default -t Site -r webTier -c dispatchCmd -- -command Status \
	-resourcename "tomcat.*" 

This would match names like tomcat1 and tomcat2.

To match on the Service's type use the -resourcetype option:

ctl -p default -t Site -r webTier -c dispatchCmd -- -command Status \
	-resourcetype RdbService 

Both options can be combined:

ctl -p default -t Site -r webTier -c dispatchCmd -- -command Status \
	-resourcename ".*" -resourcetype ".*" 

In this case, all the Services are matched (the default).

You can order the execution via the -sortorder option:

ctl -p default -t Site -r webTier -c dispatchCmd -- -command Status \
	-sortorder ascending 

That will sort the Service resources based on their startuprank in ascending order.

Appendix

File listing: coordinated-sites.xml

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE project PUBLIC "-//ControlTier Software Inc.//DTD Project Document 1.0//EN" 
"project.dtd">
<project>
  <!--
      **
      ** Describes set of homogeneous Services mediated via a Site
      **
  -->
  
  <!--
      **
      ** Describes the services
      **
  -->
  <deployment 
      type="Service"
      name="sc_svc1" 
      description="The svc service."
      startuprank="1">
    <referrers replace="false">
      <resource type="Node" name="strongmad"/>
    </referrers>
  </deployment>

  
  <deployment 
      type="Service"
      name="sc_svc2" 
      description="The svc server."
      startuprank="2">
    <referrers replace="false">
      <resource type="Node" name="strongmad"/>
    </referrers>
  </deployment>

  <!--
      **
      ** Describes the site:
      **
  -->
  <deployment 
      type="Site"
      name="sc_tier" 
      description="The tier Site."
      startuprank="1">

    <!--
	**
	** References the services as child dependencies
	**
    -->
    <resources>
      <resource name="sc_svc1" type="Service" />
      <resource name="sc_svc2" type="Service" />
    </resources>
    <referrers replace="false">
      <resource type="Node" name="strongmad"/>
    </referrers>
  </deployment>



  <!--
      **
      ** Describes the services
      **
  -->
  <deployment 
      type="Service"
      name="sc_svc3" 
      description="The svc service."
      startuprank="3">
    <referrers replace="false">
      <resource type="Node" name="strongmad"/>
    </referrers>
  </deployment>

  
  <deployment 
      type="Service"
      name="sc_svc4" 
      description="The svc server."
      startuprank="4">
    <referrers replace="false">
      <resource type="Node" name="strongmad"/>
    </referrers>
  </deployment>

  <!--
      **
      ** Describes the site:
      **
  -->
  <deployment 
      type="Site"
      name="sc_slice" 
      description="The slice Site."
      startuprank="2">

    <!--
	**
	** References the services as child dependencies
	**
    -->
    <resources>
      <resource name="sc_svc3" type="Service" />
      <resource name="sc_svc4" type="Service" />
    </resources>
    <referrers replace="false">
      <resource type="Node" name="strongmad"/>
    </referrers>
  </deployment>


  <!--
      **
      ** Describes the site:
      **
  -->
  <deployment 
      type="Site"
      name="sc_pool" 
      description="The pool Site.">

    <!--
	**
	** References the services as child dependencies
	**
    -->
    <resources>
      <resource name="sc_slice" type="Site" />
      <resource name="sc_tier" type="Site" />
    </resources>
    <referrers replace="false">
      <resource type="Node" name="strongmad"/>
    </referrers>
  </deployment>

</project>	

Run load-resources

ctl -p demo -m ProjectBuilder -c load-resources -- \
    -filename coordinated-sites.xml

Run ctl-project

ctl-project -p demo -a install --name 'sc_.*'
Personal tools
Namespaces
Variants
Actions
Navigation
Communication
Development
Toolbox
Print/export