Service statelessness principle

Last updated

Service statelessness is a design principle that is applied within the service-orientation design paradigm, in order to design scalable services by separating them from their state data whenever possible. [1] This results in reduction of the resources consumed by a service as the actual state data management is delegated to an external component or to an architectural extension. By reducing resource consumption, the service can handle more requests in a reliable manner. [2]

Contents

Purpose

The interaction of any two software programs involves keeping track of the interaction-specific data as each subsequent interaction may depend upon the outcome of the previous interaction. This becomes more important in distributed architectures where the client and the server do not exist physically on the same machine. In two-tier architectures, the responsibility of tracking this interaction-specific data rested upon the rich clients, which was not an issue as each client used to reside on an individual computer. [3] However, within n-tier architectures, the state management responsibility shifted from the client to the application or the web server. This introduced the need for some middleware state management extensions so that the server could handle multiple concurrent client requests by deferring the actual activity-specific state data to such extensions e.g. storing session data in a database in ASP .NET applications. This helps freeing up the memory resources in favor of increasing server responsiveness and the ability to entertain more client requests.

In a service composition, a service may need to store activity-specific data in memory while it is waiting for another service to complete its processing. Consequently, in case of service-orientation, an efficient management of service activity related data becomes more important as service-orientation puts a lot of emphasis on service reuse. The service not only needs to deal with managing state data, which is created as a result of interacting with a consumer program, in the context of a particular business process but also in relation to the interactions with other types of consumer programs that are part of multiple business processes. As reusability goes up, so does the overhead of managing state data. The Service Statelessness principle provides guidelines in favor of making the service stateless by shifting away the state management overhead from the services to some other external architectural component. This further helps in the overall scalability of the service-oriented solution.

Application

The correct application of service statelessness requires an understanding of the various types of state information that need to be managed.

Context data

Within a service composition, service may be required to keep track of data that is specific to the running of a particular service activity, which is usually linked with the coordination of messages, e.g. workflows, and the associated rules that govern how the rules are to be interpreted.

Business data

This is the data that relates to the actual business process, run by the current service activity e.g. customer records, etc. on some occasions this type of data may need to be temporarily stored, especially if it acts as an input to the next stage within the service activity.

Session data

This relates to the connection information between the services e.g. when consumer programs and services are communicating back and forth, some sort of correlation may be required in order to fire the subsequent request only to the particular instance of the service as only that instance knows about the previous service interaction.

Statelessness and service types

The Service Statelessness principle could be applied to varying extents in relation to the type of the solution logic enclosed by the service.

Task services

The task services contain solution logic that is specific to a particular business process and hence their reuse level is low. However, these services contain context data (workflow rules) about the service activity, which is directly proportional to the size of the service composition that is being administered by the task service. As a result, designing such services with state deferral options reduces their memory footprint and makes them more responsive.

Utility services

These kinds of services may need to be stateful in order to provide statelessness for task and entity services. [4] On the other hand, a highly reusable utility service, e.g. a utility service that acts as a wrapper for a legacy system, needs to be moderately stateless so that it can entertain multiple concurrent requests.

Entity services

Being independent of any specific business process, these services are regarded as the most reusable services. Another important factor is that they process data related to business entities and as such require higher levels of statelessness so that they are not burdened with keeping track of business data that they may need to retain in order to provide the required functionality.

The statelessness could either be achieved by delegating state management to some shared architectural extension, e.g. a middleware product that exists outside of the service implementation boundary or to a dedicated mechanism that exists inside the service boundary e.g. a dedicated database. [5]

Considerations

It may not always be possible to provide a dedicated state deferral option for each service as this clearly requires additional investment. On the other hand, using a shared state deferral option may create a dependency for the service, which may stand in way of service evolution.

The storage and retrieval of state information may inadvertently affect the response time of the service as both of these tasks may prove computationally intensive as first the data needs to be converted into the native format of the storage extension and vice versa when it comes to retrieving the same information.

Designing stateless services requires extra efforts and time as the service needs to contain logic that interfaces with the state deferral extensions. This in turn would require additional code and testing.

Related Research Articles

Jakarta Enterprise Beans is one of several Java APIs for modular construction of enterprise software. EJB is a server-side software component that encapsulates business logic of an application. An EJB web container provides a runtime environment for web related software components, including computer security, Java servlet lifecycle management, transaction processing, and other web services. The EJB specification is a subset of the Java EE specification.

The term Web service (WS) is either:

In computing, a stateless protocol is a communications protocol in which no session information is retained by the receiver, usually a server. Relevant session data is sent to the receiver by the client in such a way that every packet of information transferred can be understood in isolation, without context information from previous packets in the session. This property of stateless protocols makes them ideal in high volume applications, increasing performance by removing server load caused by retention of session information.

Service-oriented architecture (SOA) is a style of software design where services are provided to the other components by application components, through a communication protocol over a network. A SOA service is a discrete unit of functionality that can be accessed remotely and acted upon and updated independently, such as retrieving a credit card statement online. SOA is also intended to be independent of vendors, products and technologies.

In computer science and networking in particular, a session is a temporary and interactive information interchange between two or more communicating devices, or between a computer and user. A session is established at a certain point in time, and then ‘torn down’ - brought to an end - at some later point. An established communication session may involve more than one message in each direction. A session is typically stateful, meaning that at least one of the communicating parties needs to hold current state information and save information about the session history in order to be able to communicate, as opposed to stateless communication, where the communication consists of independent requests with responses.

Representational state transfer (REST) is a software architectural style which uses a subset of HTTP. It is commonly used to create interactive applications that use Web services. A Web service that follows these guidelines is called RESTful. Such a Web service must provide its Web resources in a textual representation and allow them to be read and modified with a stateless protocol and a predefined set of operations. This approach allows interoperability between the computer systems on the Internet that provide these services. REST is an alternative to, for example, SOAP as way to access a Web service.

Web Services Resource Framework (WSRF) is a family of OASIS-published specifications for web services. Major contributors include the Globus Alliance and IBM.

A web framework (WF) or web application framework (WAF) is a software framework that is designed to support the development of web applications including web services, web resources, and web APIs. Web frameworks provide a standard way to build and deploy web applications on the World Wide Web. Web frameworks aim to automate the overhead associated with common activities performed in web development. For example, many web frameworks provide libraries for database access, templating frameworks, and session management, and they often promote code reuse. Although they often target development of dynamic web sites, they are also applicable to static websites.

A mashup, in web development, is a web page or web application that uses content from more than one source to create a single new service displayed in a single graphical interface. For example, a user could combine the addresses and photographs of their library branches with a Google map to create a map mashup. The term implies easy, fast integration, frequently using open application programming interfaces and data sources to produce enriched results that were not necessarily the original reason for producing the raw source data. The term mashup originally comes from creating something by combining elements from two or more sources. In recent English parlance it can refer to music, where people seamlessly combine audio from one song with the vocal track from another - thereby mashing them together to create something new.

A service delivery platform (SDP) is a set of components that provides a service(s) delivery architecture for a type of service delivered to consumer, whether it be a customer or other system. Although it is commonly used in the context of telecommunications, it can apply to any system that provides a service. Although the TM Forum (TMF) is working on defining specifications in this area, there is no standard definition of SDP in industry and different players define its components, breadth, and depth in slightly different ways.

Oracle Fusion Middleware consists of several software products from Oracle Corporation. FMW spans multiple services, including Java EE and developer tools, integration services, business intelligence, collaboration, and content management. FMW depends on open standards such as BPEL, SOAP, XML and JMS.

The Spring Framework is an application framework and inversion of control container for the Java platform. The framework's core features can be used by any Java application, but there are extensions for building web applications on top of the Java EE platform. Although the framework does not impose any specific programming model, it has become popular in the Java community as an addition to the Enterprise JavaBeans (EJB) model. The Spring Framework is open source.

SOA Governance is a set of processes used for activities related to exercising control over services in a service-oriented architecture (SOA). One viewpoint, from IBM and others, is that SOA governance is an extension (subset) of IT governance which itself is an extension of corporate governance. The implicit assumption in this view is that services created using SOA are just one more type of IT asset in need of governance, with the corollary that SOA governance does not apply to IT assets that are "not SOA". A contrasting viewpoint, expressed by blogger Dave Oliver and others, is that service orientation provides a broad organising principle for all aspects of IT in an organisation — including IT governance. Hence SOA governance is nothing but IT governance informed by SOA principles.

ItsNat Natural AJAX, is an open-source Java component-based Ajax framework.

In information systems, applications architecture or application architecture is one of several architecture domains that form the pillars of an enterprise architecture (EA).

A single-page application (SPA) is a web application or website that interacts with the user by dynamically rewriting the current web page with new data from the web server, instead of the default method of the browser loading entire new pages. The goal is faster transitions that make the website feel more like a native app.

Service-orientation design principles are proposed principles for developing the solution logic of services within service-oriented architectures (SOA).

Service autonomy is a design principle that is applied within the service-orientation design paradigm, to provide services with improved independence from their execution environments. This results in greater reliability, since services can operate with less dependence on resources over which there is little or no control.

In computing, service composability is a design principle, applied within the service-orientation design paradigm, that encourages the design of services that can be reused in multiple solutions that are themselves made up of composed services. The ability to recompose the service is ideally independent of the size and complexity of the service composition.

ASP.NET Web Forms is a web application framework and one of several programming models supported by the Microsoft ASP.NET technology. Web Forms applications can be written in any programming language which supports the Common Language Runtime, such as C# or Visual Basic. The main building blocks of Web Forms pages are server controls, which are reusable components responsible for rendering HTML markup and responding to events. A technique called view state is used to persist the state of server controls between normally stateless HTTP requests.

References

  1. Wojciech Cellary, Sergiusz Strykowski E-Government Based on Cloud Computing and Service-Oriented Architecture[Online].Date accessed: 19 April 2010.
  2. IBM Red Books Power Systems and SOA Synergy[Online].Date accessed: 21 April 2010.
  3. "Thin Client vs Thick Client Architecture". RichHewlett.com. 2 December 2008. Retrieved 10 March 2019.
  4. "Stateful Services design pattern". Archived from the original on 1 March 2010. Retrieved 28 February 2010.
  5. Reddy. et al.Evaluating legacy assets in the context of migration to SOA[Online].pp 58.Date accessed: 19 April 2010.

Further reading