Open Architecture For Developing Multitenant Software-as-a-Service Applications
Open Architecture For Developing Multitenant Software-as-a-Service Applications
Abstract. As cloud computing infrastructures are growing, in Customers access the application over the Internet using
terms of usage, its requirements about software design, industry-standard browsers or Web Services clients [4][6].
management and deployment are increasing as well. Software- Online software delivery is now conceived and defined as
as-a-Service (SaaS) platforms play a key role within this cloud Software-as-Service (SaaS). SaaS has become a well
environment. SaaS, as a part of the cloud offer, allows to established phenomenon in some areas of enterprise IT.
the software providers to deploy and manage their own It is growing into a mainstream option for software-based
applications in the clouds in a subscription basis. The problem solutions and this will impact most of the enterprise IT
with the current SaaS offers is the lack of openness of in their departments over the next three years [9]. Chou [5] declares
platforms and the need for learning a whole new paradigm
that SaaS is the next step in the software industry, not
when trying to initiate in the SaaS market. Big players,
such as: Amazon, Google or Microsoft, offer their proprietary
because it is a “cool idea”, but because it fundamentally
SaaS solutions. Another consideration is the amount of current alters the economics of software.
Web applications that need to be re-engineered into this
cloud paradigm. This research work aims to reduce the effort A wide range of online applications, including e-mail,
required to enter into the SaaS market by presenting an human resources, business analytics, customer relationship
architecture based on open source components for developing, and enterprise planning, are available [6]. According to
deploying and managing SaaS applications. Gartner [8], the SaaS market will be growing in the next
years, by 2009 100% of tier 1 consulting firms will have a
Keywords - cloud computing; software-as-a-service; software SaaS practice and by 2011, 25% of new business software
architecture; open source. will be delivered as SaaS. Also, IDC estimates customers
spending on SaaS solutions will increase to $14.8 billion by
I. INTRODUCTION 2011 [11]; two out of three businesses are either buying or
Software-as-a-Service (SaaS) has become the new considering buying software via the subscription model [10]
buzz-word around software industry. From a successful and McKinsey reports that the proportion of CIOs
business such as [Link] towards new SaaS software considering adoption of SaaS applications in the coming year
architectures with legacy solutions [3], SaaS solutions have has grown from 38% a year to 61% [7]. With previous
been converted into state-of-the-art technology. In spite of business facts, is possible to realize the importance and
the growth of this industry, there is a lack of established quantity of software that will be delivered throughout SaaS
software architectures that enable the delivery of business environments.
applications as services. Big players (e.g., Microsoft, Google,
Amazon) have developed their own SaaS infrastructure in Unfortunately, several SaaS providers offer their own
order to deliver their next-generation software applications. architecture and their own implementation requirements.
As the number and scale of cloud-computing systems [Link], for example, provides the [Link]
continues to grow, significant research is required to development platform and it uses a proprietary development
determine the strategy towards the goal for making future model (custom classes and user interfaces) for building SaaS
cloud computing platforms successful. Currently, most applications. Furthermore, transition from current Web
cloud-computing offerings are either proprietary or depend applications or Application Service Providers (ASPs)
on software that is not amenable to experimentation or solutions to this development model is not a trivial task.
instrumentation [1][3][4]. Concha, et al. [3] and Espadas, et al. [4] identify a number of
steps about transitioning from an ASP solution to a SaaS
New Internet-enabled platforms have appeared, thus implementation:
enabling open collaboration and creation. These platforms Current ASPs define a single static revenue models
represent a new way of delivering software applications (e.g., embedded & hard-coded within the application
[2][3]. While the practice of outsourcing business functions implementation). When the dynamic nature of
such as payroll has been around for decades, its realization as markets asks ASPs to modify their revenue model,
an online software service has until recently became popular. ASPs are not able to change it in a cost-effective
In the online service model, the provider develops an way, mainly because the revenue model is hard-
application and also operates the servers that host it. coded into the application.
Traditional ASPs provide a portal mechanism the application that will be delivered as a service to
for accessing their applications. The current the customers. Each service application is deployed as a
implementation of ASP only supports the notion of common Web application within the Tomcat container and
one service provider. This is the host platform it-self. it manages its own resources, such as data sources, libraries,
The benefits of shifting to a multi-provider approach and views. The main difference with common Web
include an easy integration with associates that deployments is about how the SaaS components manage and
complement the platform administrator. Migrating interact with these Web applications. The main interaction
to a multiple provider with multiple e-services point of the service application with the platform is done
also provides the ability to deploy and manage through a SaaS Application Programming Interface (API).
independent sets of applications. The SaaS API provides the common libraries that are used
Presently, ASP services are designed, developed and by the applications to access the basic SaaS services, such as:
deployed as Web applications. They are managed by authentication, account information, public resources and
the platform through a Web container and there is no so on. In the view layer, the platform offers components
other support for them (such as: billing, monitoring, (SaaS Tag Libraries) for an easy integration with the SaaS
customization, etc.). In other words, we could see context (such as: public/private menus, templates, layouts).
SaaS applications as desktop applications running The Deployment Manager is a listener component that
within an operating system. configures each application according to its configuration
file ([Link]). Every time a Web application is
This research work addresses these issues, by proposing deployed within the Tomcat container, the Deployment
an open architecture for achieving an implementation Manager reads the configuration file and analyzes
capable of deploying applications over the Internet on the application code for detect updated or new modules,
the service premise. This paper is structured as follows: security roles or deployment changes. The access point to the
Section II describes the software architecture and core SaaS platform is the SaaS Core Web Application (SCWA).
technologies of the SaaS platform; Section III outlines a set This component is a Web application that is used to access to
of business services that support SaaS applications; Section all other applications and components. SCWA is in charge of
IV defines a SaaS application and its components; Section V loading common resources and views, such as security
explains the SaaS core application that is used to access to context, authenticated user, view filters, etc.
the platform and Sections VI and VII describe multitenant
TABLE I. OPEN SAAS PLATFORM TECHNOLOGIES
implementation of applications and subscriptions.
II. SAAS ARCHITECTURE Requirement Technology
The architecture bases the communication layer on a Language Platform J2EE (Java 1.6)
Service Oriented Architecture (SOA) that supports
Web Container Apache Tomcat 6
techniques for constructing reliable services on cloud
computing infrastructures [15]. Web Framework Struts 2
Deployment
Auth, Log, Account
Manager
SaaS TagLibs
Communications Service
(Mail, SMS)
A Java Libraries Persistence API (JPA)
XML Configuration Files
Database Management MySQL 5
Integrations Service
(Google Apps) Infrastructure Management
As Table I outlines, the core technologies of the SaaS
implementation are open source projects. In Figure 1 it is
possible to find a set of business services that are consumed
Multi‐tentant SaaS DB through a platform. These business services were designed,
developed and deployed by following a Service Oriented
Figure 1. SaaS architecture Architecture (SOA) design in order to be completely
The SaaS platform is composed of several components decoupled to the SaaS platform. Each business component
that allow the deployment of applications as services exposes a set of Web Services that can be consumed through
(Fig. 1). Each component is integrated in an Apache the platform (or even others platforms) as a client. But this
Tomcat container as a Web application (.war), a packaged schema can be bidirectional; a business component can be a
library (.jar) or a business services (Web application + client of the platform as well. The implementation of these
Web Services). A ‘service application’ is defined as business services will be explained in a further section.
III. BUSINESS SERVICES deployed as common Web applications but with specific
A set of support business services is available for service features and configurations that are interpreted by
applications. As such, the SaaS applications do not the platform in order to create a SaaS execution environment.
implement code for these mechanisms as they are provided The common frameworks and libraries used to develop
by the platform. The implemented services are: SaaS applications in the platform are the same as outlined in
Table 1. As stated, each application manages its own data
Metering & monitoring. SaaS platform provides
sources (e.g., databases, Web services, etc.). The SaaS
automatic and non-intrusive support for metering
platform automatically detects configuration such as:
applications and tenant-based monitoring.
business modules, roles, menus, permissions, etc. Once the
Mailing. A component for sending/managing Web application is deployed and configured, it can be
electronic mail within applications without complex offered as a SaaS solution to multiple customers through a
configuration and programming. subscription basis. The principal configuration file for
Application customization. The customization deploying a Web application as a SaaS application is
component allows the subscriber to customize their the [Link] file. It defines the principal information
own data by adding fields to their business objects of a SaaS application.
(e.g., contact, lead, bill, etc.). By adding custom
fields to business object it is possible to generate <?xml version="1.0" encoding="UTF-8"?>
personalized capture and search forms and to create <appService>
filters for these custom properties. <name>Contact Manager</name>
<label>[Link]</label>
Each business component is developed as a Web <version>1.0</version>
application, but it exposes a set of Web services through <description>...</description>
WSO2 framework [16], which integrates web services <defaultProvider>TGHEWFS</defaultProvider>
deployed through Apache Axis2 and dependency injection <Role name="manager" description="...">
<Menu>
with Spring 2. Each business component application <MenuItem label="Contacts" path="/contacts/[Link]"/>
implements its own Web services and they are referenced in <MenuItem label="Configure" path="/config/[Link]"/>
the [Link] Spring file. In this way, any </Menu>
application in the platform can expose its own Web services </Role>
through simple classes, without having to implement <Role name="user" description="...">
complex mechanism to generate WSDL documents. Same <Menu>
implementations were followed for other business services <MenuItem label="Contacts" path="/contacts/[Link]"/>
(e.g., metering, subscriptions, customization). Though, </Menu>
the business services implement other functionalities for </Role>
</appService>
their own management and configuration. For example,
Mail Service application offers the possibility for configure
In the last snippet, the XML tag appService encloses a set
manage their mail queue and the providers' mail accounts.
of attributes for the application, such as name, label,
IV. SAAS DEVELOPMENT & DEPLOYMENT description and the default provider which owns the
application. The Role tag specifies available roles for the
A SaaS application is a Web application deployed within application permissions. These roles are updated in the
the SaaS platform with a particular configuration. A service platform database when the platform is initialized in the
application is a set of Web components that can be seen as a application server. Within these role tags it is possible to
whole software application. It provides a set of functions specify application's menus that are presented when the
separated by modules that can be deployed on demand into a authenticated user has such role. A SaaS application is
SaaS platform. In a simple way a service application only packaged as a .war Java component.
has:
Views. All the screens and forms that the user can / (root folder)
‐ WEB‐INF/
interact with. [Link]
Business Logic. Code for actions, business logic and [Link]
data source accesses. service‐[Link] [Link]
Configuration files. XML or properties files. [Link]
classes
Database. Storage for application data; logically ‐ pages
separated for each subscriber. ‐ images
That is, the SaaS application must not implement code Figure 2. Folder structure of a SaaS application
for authentication and authorization, application metering,
customization, etc, because they must be provided by Figure 2 shows the structure followed by any Web
the SaaS platform (as described in Section III). In the SaaS application that is deployed as a SaaS application.
platform, the applications’ services are developed and This structure shows the location of [Link] file in
order to be recognized as a SaaS application by the platform.
The following steps are performed during each SaaS UserVO authUser =
application initialization: getUserFromAdminContext(contextAuth,SAASADMIN_SESSIONID
1. A platform component called Deployment Manager );
reads the [Link] file. This component retrieves if (authUser==null){throw new NotAuthenticatedUserException();}
return authUser; }
information from the service, such as name, version, etc. private static UserVO getUserFromAdminContext(ServletContext
It inserts or updates the application information in the context, String ssosessionid) {
platform database. ServletContext sidelcontext =
2. Deployment Manager reads the [Link] to [Link](SAAS_CORE_APP );
create or update the application roles. Hashtable<String, UserVO> shareddata =
3. Deployment Manager inspects the application code (Hashtable<String, UserVO>)[Link](
for Action classes. This inspection looks up all Java AuthConstants.SAAS_USERS );
packages that end with '.actions' and the classes whose name if (shareddata!=null && ssosessionid!=null) {
ends with 'Action'. For example: // get the right User using the sessionid
return (UserVO)[Link](ssosessionid);}
[Link] else return null;
[Link] }
These action classes will be inserted or updated in the The static method getAuthenticatedUser() can be called
platform database as modules. from any application and it retrieves the session cookie of
4. Platform inspects each method of a Action class the authenticated user from the SCWA context (represented
(module). With the use of the @SaaSFunction Java by SAAS_CORE_APP variable). UserVO is the value
annotation it is possible to define functions for each module. object that holds information about the subscriber and
This function declaration allows having a method-level the authenticated user.
granularity about restricted access for each application role.
5. Both modules and functions are synchronized with VI. PERSISTENCE MULTITENANT IMPLEMENTATION
the platform database. There are different mechanisms for supporting multi-
V. SAAS CORE WEB APPLICATION tenancy. The applications services deployed within our SaaS
platform implements a Shared Database - Shared Schemas
The access point for the whole SaaS platform and its mechanism [12][13][14], by separating (logically) the data
deployed applications is known as SaaS Core Web App corresponding to each tenant with a subscriber ID field in
(SCWA). This component is a Web application with specific the database's tables. This shared schema approach has
characteristics for managing tenant-based authentication, the lowest hardware and backup costs, because it allows
security and control access lists. Each user belongs to one or serving the largest number of tenants per database server
more subscriber or tenant (these terms will be used [14]. As described, each service application implements its
indistinctly). Once the user has been authenticated through own database, separating the multitenant information with a
an email and password, SCWA links the user to its subscriber ID key. An example of a multitenant data model
subscriber ID. If the user belongs to two or more subscribers, is showed in Figure 3:
a selection screen is displayed to select which to work with.
After that, SCWA searches for the user within an Access Contact
and filter the contacts in the persistence layer. The SaaS VII. MULTITENANT SUBSCRIPTIONS
platform uses an object-oriented mechanism for multi- Basically, the subscription service is a Web application.
tenancy which is implemented in the application side and It uses the same open technologies as the SaaS platform (see
it is called Multi-Tenant Persistence layer. This layer uses Table 1). Its architecture defines a set of components for the
JoSQL [17], a LINQ-like [18] technology for perform SQL- subscription management. The storage layer is composed
like queries over collections and the ability of Struts2 to of the multi-tenant database and the logical persistence
create Aspect-Oriented interceptors that allows to separate in separation. Different types of subscriptions are handled by
a logical way the information of each subscriber, supposing a component called Subscription Type Management. As each
the need to retrieve the contacts from a given subscriber. provider can define its resources for their applications,
The persistent layer is based on Object Relational Mapping the Restriction Management is in charge of managing
technologies (JPA + Hibernate). We can use a simple object- these resources and linked them to a Restriction definition.
oriented query to do that: The Resource Management Remote layer performs access
// JPA query in the persistence layer to distributed resource managers from different and
String sql = "SELECT contact FROM Contact contact" heterogeneous sources. This is an important concept of
Query query = [Link](sql); the subscription component because it has the ability to
return [Link](); manage distributed resources in different scenarios, either for
on-premise ASPs applications or SaaS solutions. As such,
Simple as is, it is important to notice that there is no filter the subscription component uses a distributed architecture
by subscriber in the query sentence. The persistence layer based on SOA in order to be adaptable to several scenarios.
will return a set of ‘Contact’ objects. By using the Each entity can define its own resource managers as Web
interceptor feature of Struts2 is possible to pre-process these services and these can be consumed for the subscription
results before they can be accessed by the presentation layer. component dynamically. With this approach it is not only
Within a Struts2 action we can declare an annotated possible to have applications using the subscription
property: component as well as entire platforms consuming the web
services. These resources can be any type of accountable and
@Multitenant(attribute=”subscriberId”)
List<Contact> contacts = //get contacts from persistence layer billable resources such as persistent rows (e.g., contacts,
leads, bills, surveys, etc.) or hardware (e.g., CPU cycles,
The previous code declares that this particular list of bandwidth, storage, etc.). A Resource Manager interface
objects will be filtered before they are accessible from defines a set of methods to be implemented by SaaS services.
another component of the application (a Java Server Page It defines methods that can be called externally due to
view for example). This pre-processing implementation is the fact that each resource manager implementation is
achieved by setting a Struts2 interceptor in the call stack. exposed as a Web Service in order to be consumed for
This interceptor can access to the invocation action: the subscription service. This approach allows the dynamic
integration of heterogeneous providers. Resource Manager
Object action = [Link]().getAction(); registration is performed when a provider (e.g., a subscriber
//getting the subscriber ID from the authentication context per se) defines a Restriction for each resource. Therefore,
long subscriberId = [Link](); a Restriction (in the Subscription component side) will
for (Field field : [Link]() ){ access its Resource Manager (in the application side).
if ([Link]([Link])){
Multitenant filter = External providers can define their restrictions by using
(Multitenant)[Link]([Link]); the Subscription Web Application front-end and this is done
String attribute = [Link](); through the Restriction Management internal component.
String property = [Link]() ; Internal applications of the SaaS platform are automatically
Object objList = [Link](action, property); String analyzed by discovering their Resource Managers. The Web
className = getClassName( objList ); Services implementation in the SaaS platform is done
Query q = new Query ();// create and perform a query over the list with Apache Axis2, Spring2 and the integration library
[Link]("SELECT * FROM "+className+" WHERE "+attribute+" between them called WSO2 [16]. Each SaaS application
= "+subscriberId); implements its own resource manager, which is referenced
QueryResults qr = [Link] (list);
List newList = [Link](); in the [Link] Spring file. The subscription
//setting back the filtered list by tenant service implements multi-tenancy subscriptions with logical
[Link](action,property,newList); separations in its database, by using a subscriber ID field, in
}} order to manage multiple subscribers and subscriptions. A
In the example, the ‘Contacts’ list will be reduced to only subscriber can be any entity that has resources to bill or to
the objects which their “subscriberId” property matches with consume. A subscription is a tree-relationship entity
the authenticated subscriber. With this mechanism it is composed by two subscribers (client and provider) and a
possible to create multi-tenant pre-processing behavior SaaS application. Therefore, we can say that “subscriber A is
within the SaaS applications. In fact, it is feasible to create a subscribed to the Contact Manager SaaS application
transparent support for multi-tenant persistence without provided by subscriber B through the subscription number
affecting the on-premise applications. 1234”, as depicted in Figure 4: