Distributed Systems


image1

Distributed System

A distributed system in its simplest definition is a group of computers working together as to appear as a single computer to the end-user.

These machines have a shared state, operate concurrently and can fail independently without affecting the whole system’s up-time.

I propose we incrementally work through an example of distributing a system so that you can get a better sense of it all:

IMAGE2


Let’s go with a database! Traditional databases are stored on the file system of one single machine, whenever you want to fetch/insert information in it — you talk to that machine directly.

For us to distribute this database system, we’d need to have this database run on multiple machines at the same time.

The user must be able to talk to whichever machine he chooses and should not be able to tell that he is not talking to a single machine — if he inserts a record into node#1, node #3 must be able to return that record.

IMAGE3


Distributed System Categories


  • Distributed Data Stores
  • Distributed Computing
  • Distributed File Systems
  • Distributed Messaging
  • Distributed Applications
  • Distributed Ledgers

Examples of Distributed Systems


1) The Internet: net of nets global access to “everybody”
(data, service, other actors; open ended)
  •  enormous size (open-ended)
  •  no single authority
  • communication types
⇒interrogation, announcement, stream
⇒data, audio, video 




image5
2) Intranets ( CoDoKi, Fig. 1.2)

  • a single authority
  •  protected access
⇨a firewall
⇨total isolation
  • maybe worldwide
  •  typical services:
⇨infrastructure services: file service, name service
⇨application services 



3)Mobile and ubiquitous


im6
 computing ( CoDoKi Fig 1.3 )

  •  Portable devices
  • laptops
  •  handheld devices
  •  wearable devices
  •  devices embedded in appliances
  •  Mobile computing
  •  Location-aware computing
  •  Ubiquitous computing, pervasive computing

Distributed Computing


Distributed computing is the key to the influx of Big Data processing we’ve seen in recent years. It is the technique of splitting an enormous task (e.g aggregate 100 billion records), of which no single computer is capable of practically executing on its own, into many smaller tasks, each of which can fit into a single commodity machine. You split your huge task into many smaller ones, have them execute on many machines in parallel, aggregate the data appropriately and you have solved your initial problem. This approach again enables you to scale horizontally — when you have a bigger task, simply include more nodes in the calculation.

Known Scale — Folding@Home had 160k active machines in 2012
An early innovator in this space was Google, which by the necessity of their large amounts of data had to invent a new paradigm for distributed computation — MapReduce. They published a paper on it in 2004 and the open source community later created Apache Hadoop based on it.

MapReduce


MapReduce can be simply defined as two steps — mapping the data and reducing it to something meaningful.

Let’s get at it with an example again:

Say we are Medium and we stored our enormous information in a second distributed database for warehousing purposes. We want to fetch data representing the number of claps issued each day throughout April 2017 (a year ago).

This example is kept as short, clear and simple as possible, but imagine we are working with loads of data (e.g analyzing billions of claps). We won’t be storing all of this information on one machine obviously and we won’t be analyzing all of this with one machine only. We also won’t be querying the production database but rather some “warehouse” database built specifically for low-priority offline jobs.

IMAGE4


Each Map job is a separate node transforming as much data as it can. Each job traverses all of the data in the given storage node and maps it to a simple tuple of the date and the number one. Then, three intermediary steps (which nobody talks about) are done — Shuffle, Sort, and Partition. They basically further arrange the data and delete it to the appropriate reduce job. As we’re dealing with big data, we have each Reduce job separated to work on a single date only.

This is a good paradigm and surprisingly enables you to do a lot with it — you can chain multiple MapReduce jobs for example.

Better Techniques


MapReduce is somewhat legacy nowadays and brings some problems with it. Because it works in batches (jobs) a problem arises where if your job fails — you need to restart the whole thing. A 2-hour job failing can really slow down your whole data processing pipeline and you do not want that in the very least, especially in peak hours.

Another issue is the time you wait until you receive results. In real-time analytic systems (which all have big data and thus use distributed computing) it is important to have your latest crunched data be as fresh as possible and certainly not from a few hours ago.

As such, other architectures have emerged that address these issues. Namely Lambda Architecture (mix of batch processing and stream processing) and Kappa Architecture (only stream processing). These advances in the field have brought new tools enabling them — Kafka Streams, Apache Spark, Apache Storm, Apache Samza.


 Difference between a Distributed System and Distributed Computing


Distributed-Computing: Distributed computing is where multiple computing units are connected to achieve a common task. 

The larger computing power enables a lot more tasks to be performed than in a single unit, and searches can be coordinated for efficiency. Successes usually give the finder credit.

Distributed computing projects include hunting large prime number, and analyzing DNA codes.

Distributed-System: A distributed system consists of a collection of autonomous computers, connected through a network and distribution middleware, which enables computers to coordinate their activities and to share the resources of the system so that users perceive the system as a single, integrated computing facility.

I tend to think of distributed computing as more algorithm focused (like a submarine simulation) and distributed systems as more of a way to design systems for high availability and storing or processing big data (like an internet search engine).


Advantages of Distributed Systems

Some advantages of Distributed Systems are as follows:

  • All the nodes in the distributed system are connected to each other. So nodes can easily share data with other nodes.
  • More nodes can easily be added to the distributed system i.e. it can be scaled as required.
  • Failure of one node does not lead to the failure of the entire distributed system. Other nodes can still communicate with each other.
  • Resources like printers can be shared with multiple nodes rather than being restricted to just one.

Disadvantages of Distributed Systems

Some disadvantages of Distributed Systems are as follows:

  • It is difficult to provide adequate security in distributed systems because the nodes, as well as the connections, need to be secured.
  • Some messages and data can be lost in the network while moving from one node to another.
  • The database connected to the distributed systems is quite complicated and difficult to handle as compared to a single user system.
  • Overloading may occur in the network if all the nodes of the distributed system try to send data at once.

The key goals of a distributed system include:


Transparency: Achieving the image of a single system image without concealing the details of the location, access, migration, concurrency, failure, relocation, persistence and resources to the users

Openness: Making the network easier to configure and modify

Reliability: Compared to a single system, a distributed system should be highly capable of being secure, consistent and have a high capability of masking errors.

Performance: Compared to other models, distributed models are expected to give a much-wanted boost to performance.

Scalability: Distributed systems should be scalable with respect to geography, administration or size.

Challenges for distributed systems include:


  • Security is a big challenge in a distributed environment, especially when using public networks.
  • Fault tolerance could be tough when the distributed model is built based on unreliable components.
  • Coordination and resource sharing can be difficult if proper protocols or policies are not in place.
  • Process knowledge should be put in place for the administrators and users of the distributed model.

Standalone

A standalone computer is exactly what its name implies: a computer that stands on its own. 

Any tasks or data associated with that computer stay inside it and are not accessible from anywhere else. Any peripherals, such as printers, must be directly connected to it in order to work.

Advantages & Disadvantages of Standalone Computers

Standalone Advantages

One advantage of a standalone computer is damage control. For example, if something goes wrong, only the standalone will be affected.

 Simplicity is another advantage because it takes a lot less expertise to manage one computer than it does to set up or troubleshoot several. Standalone computers can also be more convenient. 

For example, printing on a network may require you to walk some distance from the computer to the printer. Inversely, any peripherals on a standalone have to be in arm's reach.

 Finally, a standalone does not affect other computer users. 

With a network, one user may waste space by watching movies or listening to music.

 In turn, everyone else using the network may see slower computer performance.

Standalone Disadvantages


Standalone computers have drawbacks. First of all, users are restricted to a single computer.

 On a network, users can access their files from any connected computer.

 Second, the same software cannot be installed simultaneously. 

While a network allows everything to be changed at once, a standalone requires that any new programs must be set up one-by-one, which is much more time-consuming. 

Third, it is much cheaper to connect every computer to one printer than to buy a printer for each standalone computer. 

Finally, standalone are harder to monitor. On a network, certain software can be used to simultaneously view each user's activity.

Elements of distributed computing


Departing from the focus on shared memory and synchronous systems commonly taken by other texts, this is the first useful reference based on an asynchronous model of distributed computing, the most widely used in academia and industry.

 The emphasis of the book is on developing general mechanisms that can be applied to a variety of problems.

 Its examples-clocks, locks, cameras, sensors, controllers, slicers, and synchronizers-have been carefully chosen so that they are fundamental and yet useful in practical contexts.

Web Architecture Patterns

The three most common patterns are:

Thin Web Client 

The Thin Web Client architectural pattern is useful for Internet-based applications, for which only the most minimal client configuration can be guaranteed. 

All business logic is executed on the server during the fulfillment of page requests for the client browser.

Applicability 

This pattern is most appropriate for Internet-based Web applications or for those environments in which the client has minimal computing power or no control over its configuration.

Known Uses 

Most e-commerce Internet applications use this pattern, as it doesn't make good business sense to eliminate any sector of customers just because they do not have sufficient client capabilities. 

A typical e-commerce application tries to reach the largest customer pool possible; after all, a Commodore Amiga user's money is just as good as a Windows NT user's.

Structure 

The major components of the Thin Web Client architecture pattern exist on the server.

 In many ways, this architecture represents minimal Web application architecture. 

The major components are as follows:

Client browser 

Any standard forms-capable HTML browser. The browser acts as a generalized user interface device.

 When used in a Thin Web Client architecture, the only other service it provides is the ability to accept and to return cookies. 

The application user uses the browser to request Web pages: either HTML or server. The returned page contains a fully formatted user interface - text and input controls-which is rendered by the browser on the client display. 

All user interactions with the system are through the browser.

Web server 

The principal access point for all client browsers. Client browsers in the Thin Web Client architecture access the system only through the Web server, which accepts requests for Web pages - either static HTML or server pages. Depending on the request, the Web server may initiate some server-side processing. If the page request is for a server scripted page, CGI, ISAPI, or NSAPI module, the Web server will delegate the processing to the appropriate script interpreter or executable module. In any case, the result is an HTML-formatted page, suitable for rendering by an HTML browser.

HTTP connection 

  The most common protocol in use between client browsers and Web servers.

 This architectural element represents a connectionless type of communication between client and server. 

Each time the client or the server sends information to the other, a new and separate connection is established between the two.

 A variation of the HTTP connection is a secure HTTP connection via Secure Sockets Layer (SSL). 

This type of connection encrypts the information being transmitted between client and server, using public/private encryption key technology.

HTML page 

 A Web page with the user interface and content information that does not go through any server-side processing.

 Typically these pages contain explanatory text, such as directions or help information, or HTML input forms.

 When a Web server receives a request for an HTML page, the server simply retrieves the file and sends it without filtering back to the requesting client.

Server page 

Web pages that go through some form of server-side processing. 

Typically, these pages are implemented on the server as scripted pages (Active Server Pages, Java Server Pages, Cold Fusion pages) that get processed by a filter on the application server or by executable modules (ISAPI or NSAPI). 

These pages potentially have access to all server-side resources, including business logic components, databases, legacy systems, and merchant account systems.

Application server

The primary engine for executing server-side business logic.

 The application server is responsible for executing the code in the server pages, can be located on the same machine as the Web server, and can even execute in the same process space as the Web server.

 The application server is logically a separate architectural element since it is concerned only with the execution of business logic and can use a completely different technology from the Web server.

The figure below shows a diagram of the logical view for the Thin Web Client architecture.


im111



The minimal Thin Web Client architecture is missing some common optional components that are typically found in web applications; most notably the database. Most web applications use a database to make the business data persistent. 

In some situations, the database may also be used to store the pages themselves (this use of a database, however, represents a different architectural pattern). 

Since web applications can use any number of technologies to make business data persistent, the architectural component is labeled with the more generic term: Persistence. 

The Persistence component also includes the possible use of a Transaction Processing Monitor (TPM).

The simplest way to connect a database to the system is to allow the scripts in the server pages direct access to the Persistence component. 

Even this direct access utilizes standard data access libraries like RDO, ADO, ODBC, JDBC, DBLib, etc. to do the dirty work. In this situation, the server pages are knowledgeable of the database schema. 

For relational database systems, they construct and execute the necessary SQL statements to gain access to data in the database.

 In smaller and less complicated web applications this can be sufficient. For larger and more robust systems however the use of a full business object layer is preferred.

A business object component encapsulates business logic.

 This component is usually compiled and executed on the application server.

 One of the advantages of having a business object architectural component is that other web or client-server systems can use the same components to invoke the same business logic. 

For example, an Internet-based storefront may use server pages and the Thin Web Client architectural pattern for all consumer activity, however, the billing division may require more sophisticated access to the data and business logic and prefer to use a client-server system over a web-based one.

 The billing divisions system can utilize the same business components on the same application server as the web front, yet use their own and more sophisticated client software.

Since relational databases are the most common type of database in mainstream businesses, an additional architectural component is usually present between the application server and the database. 

It provides a mapping service between objects and relational databases.

 This mapping layer itself can be implemented in a number of ways. 

Detailed discussions of this component are beyond the scope of this page.

Other options that are commonly added to this architectural pattern are integration with legacy systems and for e-commerce applications; a merchant account system. 

Both are accessed via the business objects (or the application server for those systems without a formal business object component).

 Legacy systems could represent an accounting system or manufacturing scheduling system.

 The merchant account system enables an Internet web application to accept and process credit card payments. 

There are many merchant account systems available for small businesses wanting to get into the online market. 

For larger businesses, this component would most likely be an interface to an already existing system capable of processing credit card requests.

With these optional components in place, the logical view of the Thin Web Client architectural pattern becomes more complete. The logical view is shown in the figure below.


ima222


Much of a web applications server components can be found on non-web based applications as well.

 The design and architecture of web applications back end are not unlike the design of any mainframe or client/server system.

 Web applications employ the use of databases and transaction processing monitors (TPM) for the same reasons that other systems do.

 Enterprise Java Beans (EJB) and Microsoft’s Transaction Server (MTS) are new tools and technologies that were introduced with Web applications in mind but are equally suited for use in other application architectures.

The architecture and design of web applications server-side components are treated exactly like that of any client-server system.

 Since this architectural pattern focuses on the web and the components specific to web applications, a detailed review of possible back end server architectures is beyond the scope of this pattern.

Dynamics 

The underlying principle of the dynamics of this architectural pattern is that business logic only gets executed in response to a web page request by the client. 

Clients use the system by requesting web pages from the web server with the HTTP protocol.

 If the requested page is an HTML file on the web servers file system, it simply fetches it and sends it back to the requesting client.

If the page is a scripted page, that is a page with interpretable code that needs to be processed before it can be returned to the client, then the web server delegates this action to the application server. 

The application server interprets the scripts in the page, and if directed to, interacts with server-side resources like databases, email services, legacy systems, etc.

 The scripted code has access, through the application and web server, to special information accompanying the page request.

 This information includes form field values entered by the user, and parameters appended to the page request. 

The ultimate result is a properly formatted HTML page suitable for sending back to the client.

The page may also be an executable module like an ISAPI or NSAPI DLL.

 A DLL or dynamic link library is a compiled library that can be loaded and executed at run time by the application server. 

The module has access to the same details about the page request (form field values and parameters) that scripted pages have.

The key point of the dynamic behavior of this pattern is that business logic is only invoked during the processing of a page request. 

Once the page request has been fulfilled, the result is sent back to the requesting client, and the connection between the client and server is terminated. 

It is possible for a business process to linger on after the request is fulfilled, but this is not the norm.

Consequences 

This type of architecture is best suited to applications whose server response can be completed within the acceptable response time expected by the user (and within the timeout value allowed by the client browser).

 This is usually on the order of no more than a few seconds. 

This may not be the most appropriate architecture pattern if the application needs to allow the user to start and monitor a business process that lasts a long time. 

The use of push technologies, however, can be employed to allow the client to monitor long running processes. For the most part push technologies just employ periodic polling of the server.

Another major consequence of this architectural pattern is the limited ability for sophisticated user interfaces.

 Since the browser acts as the entire user interface delivery mechanism, all user interface widgets and controls must be available via the browser. 

In the most common browsers, and in the HTML specifications these are limited to a few text entry fields and buttons. On the other hand, it could be argued that such a severely limited user interface is a plus.

 Sparse user interface offerings prevent the development team from spending effort on "cool" and "neat" interfaces when more simpler ones would suffice.

Thick Web Client 


The Thick Web Client architectural pattern extends the Thin Web Client pattern with the use of client-side scripting and custom objects like ActiveX controls and Java Applets.

 The Thick Web Client pattern gets its name from the fact that the client can actually execute some of the business logic of the system and hence becomes more than just a generalized user interface container.

Applicability 

The Thick Web Client architectural pattern is most appropriate for web applications where a certain client configuration and browser version can be assumed, a sophisticated user interface is desired, and/or a certain amount of the business logic can be executed on the client. 

Much of the distinction between the Thin Web Client and Thick Web Client patterns is in the role the browser plays in the execution of the systems business logic.

The two strong motivations for Thick Web Client usage are enhanced user interface capability and client execution of business logic.

 A sophisticated user interface could be used to view and modify three-dimensional models or animate a financial graph.

 In some instances, the ActiveX control can be used to communicate with client-side monitoring equipment. 

For example, health care equipment that can measure blood pressure, sugar count, and other vital signs could be used by an agency that needs to monitor geographically remote patients on a daily basis and be able to cut down on personal visits to twice a week.

In some situations, business logic can be executed on the client alone. 

In these situations, all the data required to carry out the process should be available on the client.

 The logic may be as simple as validating entered data. Dates can be checked for accuracy, or compared with other dates (for example the birth date should be before the date first admitted to the hospital). 

Depending upon the business rules of the system some fields may or may not be enabled depending upon the currently entered values.

Known Uses 

The most obvious uses of client-side scripts, applets, controls, and plug-ins are on the Internet in the form of enhanced user interfaces. 

Java Scripts are often used to change the color or image of a button or menu item in HTML pages. 

Java Applets and ActiveX controls are often used to create sophisticated hierarchical tree view controls.

The Shockwave ActiveX control and the plug-in is one of the most common user interface components in use on the Internet today.

 It enables interactive animations, and is primarily used to spice up Internet sites with attractive graphics, but is also being used to display simulations and monitor sporting events.

Microsoft's agent control is used by several Internet sites to accept voice commands and execute actions in the browser that assist the user navigating the web site.

Off of the Internet, a healthcare software company has developed a web-based intranet application to manage patient records and billing. 

The web-based user interface makes heavy use of client-side scripting to perform data validations and assist the user in navigation of the site. In addition to scripts, the application uses several ActiveX controls to manage XML content, which is used as the primary encoding scheme for information.

Structure 

All communication between client and server, like in the Thin Web Client pattern, is done with HTTP.

 Since HTTP is a "connectionless" type of protocol, most of the time there is no open connection between client and server.

 Only during page requests does the client send information. 

This means that client-side scripting, ActiveX controls, and Java Applets are limited to interacting with objects only on the client.

The Thick Web Client pattern utilizes certain browser capabilities like ActiveX controls or Java Applets to execute business logic on the client. 

ActiveX controls are compiled, binary executables that can be downloaded to the client via HTTP, and invoked by the browser.

 Since they are ActiveX controls are essentially COM objects, they have full reign over client-side resources.

 They can interact with both the browser as well as the client system itself.

 For this reason, ActiveX controls, especially those on the Internet, are typically "authenticated" by a third trusted party

The most recent versions of common HTML browsers also allow client-side scripting. HTML pages can be embedded with scripts written in JavaScript or VB Script. This scripting capability enables the browser itself to execute (or rather interpret) code that may be part of the business logic of the system. The term "maybe" is used since it is very common for client scripts to contribute only to extraneous aspects of the user interface, and not actually be part of the business logic. In either case, there are potentially architecturally significant elements (i.e. scripts) embedded inside HTML pages that need to be expressed as such.

Since the Thick Web Client pattern is really just an extension to the Thin Web Client pattern, most of the architecturally significant elements are the same. The additional elements that the Thick Web Client pattern introduces are:

Client Script 

JavaScript or Microsoft® VirtualBasic® script embedded in HTML formatted pages.
The browser interprets the script. 

The W3C (an Internet standards body) has defined the HTML and Document Object Model interface that the browser offers to client scripts.

XML Document 

 A document formatted with the eXtensible Markup Language (XML).

 XML Documents represent content (data) without user interface formatting.

ActiveX Control 

 A COM object that can be referenced in a client script and "downloaded" to the client if necessary. Like any COM object, it has full access to client resources. 

The principal security mechanism for protecting client machines is through authentication and signing. 

Internet browsers can be configured to not accept, or warn the user when ActiveX controls are about to be downloaded to the client. 

The authentication and signing mechanisms merely establish the identity of the author of the control through a trusted third party.

Java Applet 

 A self-contained and compiled component that runs in the context of a browser. For security reasons, it has limited access to client-side resources.

 Java Applets are used both as sophisticated user interface elements and for non-user interface purposes such as parsing XML documents or to encapsulate complicated business logic.

Java Bean 

 A Java component that implements a certain set of interfaces that enable it to be easily incorporated into larger more complex systems. 

The term bean reflects the small nature and single purpose the component should have. 

A full cup of coffee usually takes more than one bean. ActiveX is the analog to the Java Bean in Microsoft centered architectures.

The figure below shows a diagram of the Logical View for the Thick Web Client Architecture.


ima2223



Dynamics 

The principal dynamics of the Thick Web Client pattern include those of the Thin Web Client pattern plus the ability to execute business logic on the client.

 As with the Thin Web Client pattern, all communication between the client and server is done during page requests.

 The business logic, however, can be partially executed on the client with scripts, controls or applets.

When a page is sent to a client browser it may contain scripts, controls, and applets.

 They may be used simply to enhance the user interface or contribute to the business logic.

 The simplest business logic uses are field validations. 

Client scripts can be used to check for valid input, not only in a single field but across all fields in any given web page.

 For example, an e-commerce application that allows users to configure their own computer systems may use scripts to prevent incompatible options from being specified.

In order for Java Applets and ActiveX controls to be used, they must be specified in the content of the HTML page. 

These controls and applets can work independently of any scripts in the page or be driven by scripts in the page. 

Scripts in an HTML page can respond to special events sent by the browser. 

These events can indicate that the browser has just completed loading the web page, or that the user's mouse just moved over a specific region of the page.

They have access to the browsers Document Object Model (DOM) interface. This interface is a W3C standard for giving scripts, controls and applets access to the browser and HTML content in pages. 

Microsofts and Netscape's implementation of this model is Dynamic HTML (DHTML). 

DHTML is more than just an implementation of the DOM interface, its particular DHTML includes events, which at the time of this writing are not part of the DOM Level 1 specification.

At the core of the Document Object Model is a set of interfaces that specifically handle XML documents. 

XML is a flexible language that enables designers to create their own special purpose tags. 

The DOM interface enables client scripts to access XML documents

The use of XML as a standard mechanism of exchanging information between client and server is enabled by the use of special components on the client.

 ActiveX controls or Java Applets can be placed on the client to independently request and send XML documents. For example, a Java Applet embedded in an HTML page could make an HTTP request from the web server for an XML document. 

The web server finds and processes the requested information and sends back not an HTML document, but an XML formatted one. 

The Applet still running in the HTML page on the client would accept the XML document, parse it and interact with current HTML document in the browser to display its content for the user. 

The entire sequence happens in the context of a single HTML page in the client browser.

Consequences 

By far the biggest consequence of this pattern is portability across browser implementations.

 Not all HTML browsers support JavaScript or VirtualBasic Script. 

Additionally only Microsoft Windows-based clients can use ActiveX controls. 

Even when a specific brand of the client browser is exclusively used there are subtle differences in implementations of the Document Object Model.

When client scripting, controls or applets are used the testing team needs to perform the full set of test scenarios for each client configuration to be supported. 

Since critical business logic is being performed on the client it is important that it behaves consistently and correctly for all browsers involved. 

Never assume that all browsers behave the same. 

Not only is it possible for different browsers to behave differently with the same source code, but even the same browser running on different operating systems might show anomalous behavior.

Web Delivery 

The Web Delivery architectural pattern is named so because the Web is primarily used as a delivery mechanism for an otherwise traditional distributed object client/server system.

 From one viewpoint this type of application is really a distributed object client/server application that just happens to include a web server and client browser as significant architectural elements. 

Whether such a system is a web application with distributed objects or a distributed object system with web elements the ultimate system is the same.

 The fact that these two viewpoints are of the same system, and distributed object systems have always been seen as systems requiring careful modeling, it further emphasizes the theme in this page that web applications, need to be modeled and designed like any other software system.


Applicability


The Web Delivery architectural pattern is most appropriate when there is significant control over the client and network configurations.

 This pattern is not particularly suited for Internet-based applications, where there is no or little control over client configurations, or when network communications are not reliable.

The greatest strengths of this architecture are its ability to leverage existing business objects in the context of a web application.

 With direct and persistent communications possible between client and server, the limitations of the previous two web application patterns can be overcome. 

The client can be leveraged to perform significant business logic to an even greater degree.

It is unlikely that this architectural pattern is used in isolation.

 More realistically this pattern would be combined with one or both of the previous patterns. 

The typical system would utilize one or both of the first architectural patterns for those parts of the system not requiring a sophisticated user interface, or where client configurations are not strong enough to support a large client application.


Known Uses 


The CNN Interactive web site is one of the busiest news sites on the Net.

 Most of its public access is done with conventional browsers and straight HTML 3.2, however behind the web site is a sophisticated CORBA based network of browsers, servers, and distributed objects.

 A case study of this system was published Distributed Computing.

A healthcare software company has created a web application to manage patients, health records, and billing.

The billing aspects of the system are only used by a significantly small proportion of the overall user community. 

Much of the legacy billing systems were written in FoxPro.

The new web-based system leveraged the old FoxPro legacy code and through the use of some conversion, utilities built ActiveX documents for the user interface and business logic. 

The resulting system is a Thick Web Client based web application for patient and health records, integrated with a Web Delivery based web application for billing operations.


Structure 


The most significant difference between the Web Delivery and the other web application architecture patterns is the method of communication between the client and server. 

In the other patterns, the primary mechanism was HTTP, a connectionless protocol that severely limits the designer when it comes to interactive activity between the user and the server. 

The architecturally significant elements in the Web Delivery pattern include all those specified in Thin Web Client pattern plus these additional ones:

DCOM  Distributed COM is Microsofts distributed object protocol. It enables objects on one machine to interact with and invoke methods on objects on another machine.

IIOP  Internet Inter-Orb Protocol is OMGs CORBA protocol for interacting with distributed objects across the Internet (or any TCP/IP based network).

RMI (JRMP)  Remote Method Invocation is the Java way of interacting with objects on other machines. 

JRMP (Java Remote Method Protocol) is the native protocol for RMI, but not necessarily the only protocol that can be used. RMI can be implemented with CORBA's IIOP.

The figure below shows a diagram of the Logical View for the Web Delivery Architecture pattern.



ima22234



Dynamics 


The principal dynamics of the Web Delivery architectural pattern are the use of the browser to deliver a distributed object system.

 The browser is used to contain a user interface and some business objects that communicate, independently of the browser to objects in the server tier. 

Communications between client and server objects occur with IIOP, RMI and DCOM protocols.

The main advantage of using a web browser in this otherwise distributed object client-server system is that the browser has some built-in capabilities to automatically download the needed components from the server.

 A brand new computer to the network needs only a compatible web browser to begin using the application. 

Special software does not need to be manually installed on the client since the browser will manage this for the user.

 Components are delivered and installed on the client on an as-needed basis.

 Both Java Applets and ActiveX controls can be automatically sent to and cached on the client.

 When these components are activated (as a result of loading the appropriate web page) they can engage in asynchronous communication with server objects.


Consequences 


By far the biggest consequence of this pattern is portability across browser implementations. 

The use of this pattern requires a solid network.

 Connections between client and server objects last much longer than HTTP connections, and so sporadic loss of a server, which is not a problem with the other two architectures poses a serious problem to be handled in this pattern.

Fundamentals

  • Before we start our discussion on communication in distributed systems, we first recapitulate some of the fundamental issues related to communication. 
  • In the next section, we briefly discuss network communication protocols, as these form the basis for any distributed system. After that, we take a different approach by classifying the different types of communication that occurs in distributed systems.

 Layered Protocols

🔼Due to the absence of shared memory, all communication in distributed systems is based on sending and receiving (low level) messages. 

🔼When process A wants to communicate with process B, it first builds a message in its own address space.

 ðŸ”¼Then it executes a system call that causes the operating system to send the message over the network to B. Although this basic idea sounds simple enough, in order to prevent chaos, A and B have to agree on the meaning of the bits being sent. 

🔼If A sends a brilliant new novel written in French and encoded in IBM's EBCDIC character code, and B expects the inventory of a supermarket written in English and encoded in ASCII, communication will be less than optimal.

🔼Many different agreements are needed. How many volts should be used to signal a 0-bit, and how many volts for a 1-bit? How does the receiver know which is the last bit of the message? How can it detect if a message has been damaged or lost, and what should it do if it finds out? How long are numbers, strings, and other data items, and how are they represented? In short, agreements are needed at a variety of levels, varying from the low-level details of bit transmission to the high-level details of how information is to be expressed.


🔼To make it easier to deal with the numerous levels and issues involved in communication, the International Standards Organization (ISO) developed a reference model that clearly identifies the various levels involved, gives them standard names, and points out which level should do which job. 

🔼This model is called the Open Systems Interconnection Reference Model (Day and Zimmerman, 1983), usually abbreviated as ISO OSI or sometimes just the OSI model. It should be emphasized that the protocols that were developed as part of the OSI model were never widely used and are essentially dead now. 

🔼However, the underlying model itself has proved to be quite useful for understanding computer networks.

 ðŸ”¼Although we do not intend to give a full description of this model and all of its implications here, a short introduction will be helpful. For more details, see Tanen-baum (2003).

🔼The OSI model is designed to allow open systems to communicate. 

🔼An open system is one that is prepared to communicate with any other open system by using standard rules that govern the format, contents, and meaning of the messages sent and received. 

🔼These rules are formalized in what are called protocols. To allow a group of computers to communicate over a network, they must all agree on the protocols to be used. 

🔼A distinction is made between two general types of protocols. With connection-oriented protocols, before exchanging data the sender and receiver first explicitly establish a connection and possibly negotiate the protocol they will use. 

🔼When they are done, they must release (terminate) the connection. The telephone is a connection-oriented communication system. With connectionless protocols, no setup in advance is needed. 

🔼The sender just transmits the first message when it is ready. Dropping a letter in a mailbox is an example of connectionless communication. 

🔼With computers, both connection-oriented and connectionless communication is common.

 ðŸ”¼In the OSI model, communication is divided up into seven levels or layers, as shown in Fig. 4-1. 

🔼Each layer deals with one specific aspect of communication. In this way, the problem can be divided up into manageable pieces, each of which can be solved independently of the others. 

🔼Each layer provides an interface to the one above it. The interface consists of a set of operations that together define the service the layer is prepared to offer its users.

➥Figure 4-1. Layers, interfaces, and protocols in the OSI model.
(This item is displayed on page 118 in the print version)


imaa11



🔼When process A on machine 1 wants to communicate with process B on machine 2, it builds a message and passes the message to the application layer on its machine.

🔼 This layer might be a library procedure, for example, but it could also be implemented in some other way (e.g., inside the operating system, on an external network processor, etc.). 

🔼The application layer software then adds a header to the front of the message and passes the resulting message across the layer 6/7 interface to the presentation layer.

 ðŸ”¼The presentation layer, in turn, adds its own header and passes the result down to the session layer, and so on. Some layers add not only a header to the front but also a trailer to the end. 

🔼When it hits the bottom, the physical layer actually transmits the message (which by now might look as shown in Fig. 4-2) by putting it onto the physical transmission medium.


🔼Figure 4-2. A typical message as it appears on the network


imaa12



🔼When the message arrives at machine 2, it is passed upward, with each layer stripping off and examining its own header. 

🔼Finally, the message arrives at the receiver, process B, which may reply to it using the reverse path. The information in the layer n header is used for the layer n protocol.


🔼As an example of why layered protocols are important, consider communication between two companies, Zippy Airlines and its caterer, Mushy Meals, Inc. Every month, the head of the passenger service at Zippy asks her secretary to contact the sales manager's secretary at Mushy to order 100,000 boxes of rubber chicken.

 ðŸ”¼Traditionally, the orders went via the post office. However, as the postal service deteriorated, at some point the two secretaries decided to abandon it and communicate by e-mail. 

🔼They could do this without bothering their bosses since their protocol deals with the physical transmission of the orders, not their contents.

🔼Similarly, the head of the passenger service can decide to drop the rubber chicken and go for Mushy's new special, prime rib of goat, without that decision affecting the secretaries. 

🔼The thing to notice is that we have two layers here, the bosses and the secretaries. 

🔼Each layer has its own protocol (subjects of discussion and technology) that can be changed independently of the other one.

🔼 It is precisely this independence that makes layered protocols attractive. 

🔼Each one can be changed as technology improves, without the other ones being affected.

 ðŸ”¼In the OSI model, there are not two layers, but seven, as we saw in Fig. 4-1. 

🔼The collection of protocols used in a particular system is called a protocol suite or protocol stack.

 ðŸ”¼It is important to distinguish a reference model from its actual protocols. 

🔼As we mentioned, the OSI protocols were never popular. 

🔼In contrast, protocols developed for the Internet, such as TCP and IP, are mostly used. 

🔼In the following sections, we will briefly examine each of the OSI layers, in turn, starting at the bottom. 

🔼However, instead of giving examples of OSI protocols, where appropriate, we will point out some of the Internet protocols used in each layer.

Lower-Level Protocols
🔼We start by discussing the three lowest layers of the OSI protocol suite. 

🔼Together, these layers implement the basic functions that encompass a computer network.

 ðŸ”¼The physical layer is concerned with transmitting the 0s and 1s. 

🔼How many volts to use for 0 and 1, how many bits per second can be sent, and whether transmission can take place in both directions simultaneously are key issues in the physical layer.

 ðŸ”¼In addition, the size and shape of the network connector (plug), as well as the number of pins and meaning of each are of concern here.

 ðŸ”¼The physical layer protocol deals with standardizing the electrical, mechanical, and signaling interfaces so that when one machine sends a 0 but it is actually received as a 0 bit and not a 1 bit.

 ðŸ”¼Many physical layer standards have been developed (for different media), for example, the RS-232-C standard for serial communication lines.

 ðŸ”¼The physical layer just sends bits.

🔼 As long as no errors occur, all is well. However, real communication networks are subject to errors, so some mechanism is needed to detect and correct them.

 ðŸ”¼This mechanism is the main task of the data link layer. What it does is to group the bits into units, sometimes called frames, and see that each frame is correctly received.

🔼The data link layer does its work by putting a special bit pattern on the start and end of each frame to mark them, as well as computing a checksum by adding up all the bytes in the frame in a certain way. 

🔼The data link layer appends the checksum to the frame.

🔼 When the frame arrives, the receiver recomputes the checksum from the data and compares the result to the checksum following the frame.

🔼 If the two agree, the frame is considered correct and is accepted. If they disagree, the receiver asks the sender to retransmit it. 

🔼Frames are assigned sequence numbers (in the header) so everyone can tell which is which.

🔼On a LAN, there is usually no need for the sender to locate the receiver.

 ðŸ”¼It just puts the message out on the network and the receiver takes it off. 

🔼A wide-area network, however, consists of a large number of machines, each with some number of lines to other machines, rather like a large-scale map showing major cities and roads connecting them. 

🔼For a message to get from the sender to the receiver it may have to make a number of hops, at each one choosing an outgoing line to use. 

🔼The question of how to choose the best path is called routing and is essentially the primary task of the network layer.

 ðŸ”¼The problem is complicated by the fact that the shortest route is not always the best route. 

🔼What really matters is the amount of delay on a given route, which, in turn, is related to the amount of traffic and the number of messages queued up for transmission over the various lines.

🔼 The delay can thus change over the course of time. 

🔼Some routing algorithms try to adapt to changing loads, whereas others are content to make decisions based on long-term averages.

 ðŸ”¼At present, the most widely used network protocol is the connectionless IP (Internet Protocol), which is part of the Internet protocol suite. 

🔼An IP packet (the technical term for a message in the network layer) can be sent without any setup. 

🔼Each IP packet is routed to its destination independent of all others. No internal path is selected and remembered.


Transport Protocols

🔼The transport layer forms the last part of what could be called a basic network protocol stack, in the sense that it implements all those services that are not provided at the interface of the network layer, but which are reasonably needed to build network applications. 

🔼In other words, the transport layer turns the underlying network into something that an application developer can use.

 ðŸ”¼Packets can be lost on the way from the sender to the receiver.

 ðŸ”¼Although some applications can handle their own error recovery, others prefer a reliable connection. The job of the transport layer is to provide this service.

 ðŸ”¼The idea is that the application layer should be able to deliver a message to the transport layer with the expectation that it will be delivered without loss.

 ðŸ”¼Upon receiving a message from the application layer, the transport layer breaks it into pieces small enough for transmission, assigns each one a sequence number, and then sends them all. 

🔼The discussion in the transport layer header concerns which packets have been sent, which have been received, how many more the receiver has room to accept, which should be retransmitted, and similar topics.

🔼 Reliable transport connections (which by definition are connection oriented) can be built on top of connection-oriented or connectionless network services. 

🔼In the former case all the packets will arrive in the correct sequence (if they arrive at all), but in the latter case, it is possible for one packet to take a different route and arrive earlier than the packet sent before it. 

🔼It is up to the transport layer software to put everything back in order to maintain the illusion that a transport connection is like a big tube—you put messages into it and they come out undamaged and in the same order in which they went in.

 ðŸ”¼Providing this end-to-end communication behavior is an important aspect of the transport layer.

🔼The Internet transport protocol is called TCP (Transmission Control Protocol) and is described in detail in Comer (2006). 

🔼The combination TCP/IP is now used as a de facto standard for network communication. 

🔼The Internet protocol suite also supports a connectionless transport protocol called UDP (Universal Datagram Protocol), which is essentially just IP with some minor additions.

🔼 User programs that do not need a connection-oriented protocol normally use UDP.

🔼 Additional transport protocols are regularly proposed. For example, to support real-time data transfer, the Real-time Transport Protocol (RTP) has been defined.

 ðŸ”¼RTP is a framework protocol in the sense that it specifies packet formats for real-time data without providing the actual mechanisms for guaranteeing data delivery.

 ðŸ”¼In addition, it specifies a protocol for monitoring and controlling data transfer of RTP packets (Schulzrinne et al., 2003).

Higher-Level Protocols

🔼Above the transport layer, OSI distinguished three additional layers. 

🔼In practice, only the application layer is ever used. In fact, in the Internet protocol suite, everything above the transport layer is grouped together. 

🔼In the face of middle-ware systems, we shall see in this section that neither the OSI nor the Internet approach is really appropriate.

 ðŸ”¼The session layer is essentially an enhanced version of the transport layer.

🔼It provides dialog control, to keep track of which party is currently talking, and it provides synchronization facilities. 

🔼The latter is useful to allow users to insert checkpoints into long transfers, so that in the event of a crash, it is necessary to go back only to the last checkpoint, rather than all the way back to the beginning. In practice, few applications are interested in the session layer and it is rarely supported.

🔼 It is not even present in the Internet protocol suite. 

🔼However, in the context of developing middleware solutions, the concept of a session and its related protocols have turned out to be quite relevant, notably when defining higher-level communication protocols.

🔼 Unlike the lower layers, which are concerned with getting the bits from the sender to the receiver reliably and efficiently, the presentation layer is concerned with the meaning of the bits. 

🔼Most messages do not consist of random bit strings, but more structured information such as people's names, addresses, amounts of money, and so on.

 ðŸ”¼In the presentation layer, it is possible to define records containing fields like these and then have the sender notify the receiver that a message contains a particular record in a certain format.

🔼 This makes it easier for machines with different internal representations to communicate with each other.

🔼The OSI application layer was originally intended to contain a collection of standard network applications such as those for electronic mail, file transfer, and terminal emulation. 

🔼By now, it has become the container for all applications and protocols that in one way or the other do not fit into one of the underlying layers.

🔼 From the perspective of the OSI reference model, virtually all distributed systems are just applications.

 ðŸ”¼What is missing in this model is a clear distinction between applications, application-specific protocols, and general-purpose protocols.

🔼 For example, the Internet File Transfer Protocol (FTP) (Postel and Reynolds, 1985; and Horowitz and Lunt, 1997) defines a protocol for transferring files between a client and a server machine. 

🔼The protocol should not be confused with the FTP program, which is an end-user application for transferring files and which also (not entirely by coincidence) happens to implement the Internet FTP.

 ðŸ”¼Another example of a typical application-specific protocol is the HyperText Transfer Protocol (HTTP) (Fielding et al., 1999), which is designed to remotely manage and handle the transfer of Web pages.

🔼The protocol is implemented by applications such as Web browsers and Web servers.

 ðŸ”¼However, HTTP is now also used by systems that are not intrinsically tied to the Web. 

➥For example, Java's object-invocation mechanism uses HTTP to request the invocation of remote objects that are protected by a firewall (Sun Microsystems, 2004b).

 There are also many general-purpose protocols that are useful to many applications, but which cannot be qualified as transport protocols. In many cases, such protocols fall into the category of middleware protocols, which we discuss next.

 Middleware Protocols

🔼Middleware is an application that logically lives (mostly) in the application layer, but which contains many general-purpose protocols that warrant their own layers, independent of other, more specific applications.

 ðŸ”¼A distinction can be made between high-level communication protocols and protocols for establishing various middleware services.

 ðŸ”¼There are numerous protocols to support a variety of middleware services. 

➥For example, as we discuss in Chap. 9, there are various ways to establish authentication, that is, provide proof of a claimed identity. 

🔼Authentication protocols are not closely tied to any specific application, but instead, can be integrated into a middleware system as a general service. 

🔼Likewise, authorization protocols by which authenticated users and processes are granted access only to those resources for which they have authorization, tend to have a general, application-independent nature.

 ➥As another example, we shall consider a number of distributed commit protocols in Chap. 8. Commit protocols to establish that in a group of processes either all processes carry out a particular operation, or that the operation is not carried out at all. 

🔼This phenomenon is also referred to as atomicity and is widely applied in transactions. 

🔼As we shall see, besides transactions, other applications, like fault-tolerant ones, can also take advantage of distributed commit protocols.

➥As the last example, consider a distributed locking protocol by which a resource can be protected against simultaneous access by a collection of processes that are distributed across multiple machines. 

🔼We shall come across a number of such protocols in Chap. 6. Again, this is an example of a protocol that can be used to implement a general middleware service, but which, at the same time, is highly independent of any specific application.

 ðŸ”¼Middleware communication protocols support high-level communication services. 

➥For example, in the next two sections, we shall discuss protocols that allow a process to call a procedure or invoke an object on a remote machine in a highly transparent way. Likewise, there are high-level communication services for setting and synchronizing streams for transferring real-time data, such as needed for multimedia applications.

➥ As the last example, some middleware systems offer reliable multicast services that scale to thousands of receivers spread across a wide-area network.

🔼 Some of the middleware communication protocols could equally well belong in the transport layer, but there may be specific reasons to keep them at a higher level.

 ➥For example, reliable multicasting services that guarantee scalability can be implemented only if application requirements are taken into account. 

🔼Consequently, a middleware system may offer different (tunable) protocols, each, in turn, implemented using different transport protocols, but offering a single interface.

 ðŸ”¼Taking this approach to layering leads to a slightly adapted reference model for communication, as shown in Fig. 4-3. Compared to the OSI model, the session and presentation layer have been replaced by a single middleware layer that contains application-independent protocols. 

🔼These protocols do not belong in the lower layers we just discussed. 

🔼The original transport services may also be offered as a middleware service, without being modified. 

🔼This approach is somewhat analogous to offering UDP at the transport level. 

🔼Likewise, middleware communication services may include message-passing services comparable to those offered by the transport layer.

🔼 Figure 4-3. An adapted reference model for networked communication.
(This item is displayed on page 123 in the print version)


imaa13


🔼In the remainder of this chapter, we concentrate on four high-level middle-ware communication services: remote procedure calls, message queuing services, support for communication of continuous media through streams, and multicasting.

 ðŸ”¼Before doing so, there are other general criteria for distinguishing (middleware) communication which we discuss next.

Web-Based Application

A web-based application is any program that is accessed over a network connection using HTTP, rather than existing within a device’s memory.

 Web-based applications often run inside a web browser.

 However, web-based applications also may be client-based, where a small part of the program is downloaded to a user’s desktop, but processing is done over the internet on an external server.

Web-based applications are also known as web apps.

There is a lot of confusion created by the use of terms like web-based, internet-based and cloud-based when referring to applications.

 Web-based applications actually encompass all the applications that communicate with the user via HTTP. 

This includes light applications like Flash games, online calculators, calendars and so on, as well as more intensive applications such as web-based word processors and spreadsheet applications.

Characteristics of Web Applications

  • Product-related characteristics
  • Use related characteristics
  • Development related characteristics
  • Evolution-related characteristics

Product-related characteristics


It is an integral part of web application. It consists of Present, Hypertext, and Content.


imaaa14


Present: Presentation plays an important role in product marketing and survival. Looks and feel is the first impression for the success and failure of application in this competitive market. The application must be attractive, impressive and according to fashion trend going on in the market.

Hypertext: Hypertext is the base of the web application. The basic elements of hypertext are a link, node, and anchor. It implements Non-linearity, cognitive overload and Disorientation features in the application that makes the application highly interactive and improve the performance. 


Content: Content is the informational part. Content generation, integration and updating, and availability is an important factor. It contains a document, table, text, graphics, and multimedia. It must be of high quality, reliable, consistent and up-to-date. The documents must be properly arranged.

Use related characteristics


It is difficult to predict the usage frequency of a web application because it varies according to the user, devices used by the users etc. we can divide the user related characteristics of the web application as Natural content, Social content and Technical content.

Natural Content: It includes the geographical location from where the web applications are accessed and availability of the web application. Global accessibility of web application with 24*7 availability improves the performance, stability, and demand of the web application.

Social Content: It is related to the user-specific aspect. There are thousands of competitive web applications around the globe, the user need spontaneous and immediate benefits. Scalability and multiculturalism are extremely essential feature required for a web application.

Technical Content: It is related to the network of web application and the devices where web application is used. Connection bandwidth, stability, reliability etc. are some essential features that affect the performance of web application. Device specification, browser configuration, version etc. are responsible for web application performance and accessibility.

Development related characteristics


It includes the Development team, Development process, Technical infrastructure, and Integration.

Development Team: Development team must be highly knowledgeable in their field. There must be proficient designers, database developers, IT experts, hypertext experts, application developers. The team members must be knowledge freaks, willing to work, innovative and interested in the latest technology and tools.

Development Process: The development process must be flexible. There must be parallel processes of development.

Technical Infrastructure: The web application must be bugs free and development should be under the time limit. Server and Browser are the two external components that should be considered at the time of development. As the use of the browser is not exactly known, it depends on user preference, the server is usually configured and operated as desired.

Integration: The web application must have support for integration with an already existing system or with external content and services.

Evolution-related characteristics


As per the changes in requirements there occurs some changes or upgradations in the web application. This evolution may concern all the other three characteristics viz. The product, Use, and Development. Market competition or short time development may cause changes.

 Distributed System Architectures


 In this blog, I would like to talk about the available Distributed System architectures that we see today and how they are being utilized in our day to day applications. 

Distributed system architectures are bundled up with components and connectors. 

Components can be individual nodes or important components in the architecture whereas connectors are the ones that connect each of these components. 

Component: A modular unit with well-defined interfaces; replaceable; reusable

Connector: A communication link between modules which mediates coordination or cooperation among components

So the idea behind distributed architectures is to have these components presented on different platforms, where components can communicate with each other over a communication network in order to achieve specifics objectives.


imaa15


Architectural Styles


 There are four different architectural styles, plus the hybrid architecture when it comes to distributed systems.  

The basic idea is to organize logically different components, and distribute those computers over the various machines.

  • Layered Architecture
  • Object-Based Architecture
  • Data-centered Architecture
  • Event-Based Architecture
  • Hybrid Architecture

Layered Architecture


The layered architecture separates layers of components from each other, giving it a much more modular approach. 

A well-known example of this is the OSI model that incorporates a layered architecture when interacting with each of the components. 

Each interaction is sequential where a layer will contact the adjacent layer and this process continues until the request is been catered to. 

But in certain cases, the implementation can be made so that some layers will be skipped, which is called cross-layer coordination.

 Through cross-layer coordination, one can obtain better results due to the performance increase. 

 The layers on the bottom provide a service to the layers on the top. 

The request flows from top to bottom, whereas the response is sent from bottom to top. 

The advantage of using this approach is that, the calls always follow a predefined path, and that each layer can be easily replaced or modified without affecting the entire architecture.


imaaa19

 The following image is the basic idea of a layered architecture style.


imaa177


 Object-Based Architecture


 This architecture style is based on the loosely coupled arrangement of objects. 

This has no specific architecture like layers. Like in layers, this does not have a sequential set of steps that need to be carried out for a given call. 

Each of the components is referred to as objects, where each object can interact with other objects through a given connector or interface. 

These are much more direct where all the different components can interact directly with other components through a direct method call.

imaa20


As shown in the above image, communication between object happens as method invocations.
These are generally called Remote Procedure Calls (RPC). 

Some popular examples are Java RMI, Web Services and REST API Calls. This has the following properties.


This architecture style is less structured.

component = object

connector = RPC or RMI

When decoupling these processes in space, people wanted the components to be anonymous and replaceable. 

And the synchronization process needed to be asynchronous, which has led to Data Centered Architectures and Event-Based Architectures.

Data Centered Architecture


As the title suggests, this architecture is based on a data center, where the primary communication happens via a central data repository. 

This common repository can be either active or passive.

 This is more like a producer-consumer problem. 

The producers produce items to a common data store, and the consumers can request data from it. 

This common repository could even be a simple database.

 But the idea is that the communication between objects happening through this shared common storage. 

This supports different components (or objects) by providing a persistent storage space for those components (such as a MySQL database). 

All the information related to the nodes in the system is stored in this persistent storage. In event-based architectures, data is only sent and received by those components who have already subscribed.

 Some popular examples are distributed file systems, producer-consumer, and web-based data services.

imaa21

Event-Based Architecture


 The entire communication in this kind of a system happens through events. When an event is generated, it will be sent to the bus system.

 With this, everyone else will be notified telling that such an event has occurred.

 So, if anyone is interested, that node can pull the event from the bus and use it.

 Sometimes these events could be data or even URLs to resources. So the receiver can access whatever the information is given in the event and process accordingly.

 processes communicate through the propagation of events.

 These events occasionally carry data.

 An advantage in this architectural style is that components are loosely coupled.

 So it is easy to add, remove and modify components in the system.

 Some examples are the publisher-subscriber system, Enterprise Services Bus (ESB) and akka.io.

 One major advantage is that these heterogeneous components can contact the bus, through any communication protocol. 

But an ESB or a specific bus has the capability to handle any type of incoming request and process accordingly.


immaaa32


This architectural style is based on the publisher-subscriber architecture. Between each node, there is no direct communication or coordination. Instead, objects which are subscribed to the service communicate through the event bus. 


The event-based architecture supports several communication styles. 


  • Publisher-subscriber
  • Broadcast
  • Point-to-Point

The major advantages of this architecture are that the Components are decoupled in space - loosely coupled.


System Level Architecture


The two major system level architectures that we use today are Client-server and Peer-to-peer (P2P).  We use these two kinds of services in our day to day lives, but the difference between these two are often misinterpreted.

Client-Server Architecture


The client-server architecture has two major components.

The client and the server. The Server is where all the processing, computing and data handling is happening, whereas the Client is where the user can access the services and resources given by the Server (Remote Server).

 The clients can make requests from the Server, and the Server will respond accordingly.

Generally, there is only one server that handles the remote side. But to be on the safe side, we do use multiple servers will load balancing techniques.

immaaa22

As one common design feature, the client-Server architecture has a centralized security database.

This database contains security details like credentials and access details.

Users can't log in to a server, without the security credentials.

So, it makes this architecture a bit more stable and secure than Peer to Peer.

The stability comes where the security database can allow resource usage in a much more meaningful way.

  But on the other hand, the system might get low, as the server only can handle a limited amount of workload at a given time.

Advantages:

  • Easier to Build and Maintain
  • Better Security
  • Stable

Disadvantages:


  • Single point of failure

  • Less scalable


Peer to Peer (P2P)



The general idea behind peer to peer is where there is no central control in a distributed system. The basic idea is that, each node can either be a client or a server at a given time. If the node is requesting something, it can be known as a client, and if some node is providing something, it can be known as a server. In general, each node is referred to as a Peer.


immaaa23


In this network, any new node has to first join the network.

 After joining in, they can either request a service or provide a service.

The initiation phase of a node (Joining of a node), can vary according to the implementation of a network.

There are two ways in how a new node can get to know, what other nodes are providing.

Centralized Lookup Server - The new node has to register with the centralized look up server an mention the services it will be providing, on the network. So, whenever you want to have a service, you simply have to contact the centralized look up the server and it will direct you to the relevant service provider.

Decentralized System - A node desiring for specific services must, broadcast and ask every other node in the network, so that whoever is providing the service will respond. 

A Comparison Between Client Server and Peer to Peer Architectures

immaaa27

immaaa28

                                      

Middleware in Distributed Applications



If we look at Distributed systems today, they lack the uniformity and consistency.

Various heterogeneous devices have taken over the world where distributed system cater to all these devices in a common way.

One way distributed systems can achieve uniformity is through a common layer to support the underlying hardware and operating systems.

This common layer is known as a middleware, where it provides services beyond what is already provided by Operating systems,  to enable various features and components of a distributed system to enhance its functionality better.

 This layer provides a certain data structures and operations that allow processes and users on far-flung machines to inter-operate and work together in a consistent way.

The image given below, depicts the usage of a middleware to inter-connect various kinds of nodes together.

 According to Andrew Tannenbaum, middleware is like the operating system of distributed systems.


immaaa289


Centralized vs Decentralized Architectures


The two main structures that we see within distributed system overlays are Centralized and Decentralized architectures.

The centralized architecture can be explained by a simple client-server architecture where the server acts as a central unit.

This can also be considered as centralized look up table with the following characteristics.


➽Low overhead

➽Single point of failure

➽Easy to Track

➽AdditionalOverhead.


immaaa30


When it comes to distributed systems, we are more interested in studying more on the overlay and unstructured network topologies that we can see today.

In general, the peer to peer systems that we see today can be separated into three unique sections.

Structured P2P: nodes are organized following a specific distributed data structure

Unstructured P2P: nodes have randomly selected neighbors

Hybrid P2P: some nodes are appointed special functions in a well-organized fashion


Structured P2P Architecture



The meaning of the word structured is that the system already has a predefined structure that other nodes will follow.

Every structured network inherently suffers from poor scalability, due to the need for structure maintenance.

 In general, the nodes in a structured overlay network are formed in a logical ring, with nodes being connected to the this ring.

In this ring, certain nodes are responsible for certain services.

A common approach that can be used to tackle the coordination between nodes, is to use distributed hash tables (DHTs).

A traditional hash function converts a unique key into a hash value, that will represent an object in the network.

The hash function value is used to insert an object in the hash table and to retrieve it.

immaaa31

In a DHT, each key is assigned to a unique hash, where the random hash value needs to be of a very large address space, in order to ensure uniqueness.

A mapping function is being used to assign objects to nodes based on the hash function value.

A look up based on the hash function value, returns the network address of the node that stores the requested object.


Hash Function: Takes a key and produces a unique hash value

Mapping Function: Map the hash value to a specific node in the system

Lookup table: Return the network address of the node represented by the unique hash value.


Unstructured P2P Systems


There is no specific structure in these systems, hence the name "unstructured networks".

Due to this reason, the scalability of the unstructured p2p systems is very high.

These systems rely on randomized algorithms for constructing an overlay network.

 As in structured p2p systems, there is no specific path for a certain node.

 It's generally random, where every unstructured system tried to maintain a random path.

Due to this reason, the search of a certain file or node is never guaranteed in unstructured systems.

The basic principle is that each node is required to randomly select another node, and contact it. 


  • Let each peer maintain a partial view of the network, consisting of n other nodes

  • Each node P periodically selects a node Q from its partial view

  • P and Q exchange information and exchange members from their respective partial views

Hybrid P2P Systems



Hybrid systems are often based on both client server architectures and p2p networks.

A famous example is Bittorrent, which we use everyday.

The torrent search engines provide a client server architecture, where the trackers provide a structured p2p overlay.

The rest of the nodes, which are also known as leechers and seeders, become the unstructured overlay of the network, allowing it to scale itself as needed and further.

 More on how Bittorrent works in the distributed context, will be written in a future blog.

immaaa35


 Summary of Structured and Unstructured P2P Systems


111

Monolithic Architecture


Monolith means composed all in one piece. 

The Monolithic application describes a single-tiered software application in which different components combined into a single program from a single platform.

Components can be:

  • Authorization➦ responsible for authorizing a user

  • Presentation➦ responsible for handling HTTP requests and responding with either HTML or JSON/XML (for web services APIs).

  • Business logic➦ the application’s business logic.

  • Database layer➦ data access objects responsible for accessing the database.

  • Application integration➦ integration with other services (e.g. via messaging or REST API). Or integration with any other Data sources.

  • Notification module➦ responsible for sending email notifications whenever needed.


Example of Monolithic Approach


Consider an example of an E-commerce application, that authorizes customer, takes an order, check products inventory, authorize payment and ships ordered products.

This application consists of several components including an e-Store User interface for customers (Store web view) along with some backend services to check products inventory, authorize and charge payments and shipping orders.


im97


Despite having different components/modules/services, the application is built and deployed as one Application for all platforms (i.e. desktop, mobile, and tablet) using RDBMS as a data source. Benefits and Drawbacks of Monolithic Architecture.



Benefits:


Simple to develop➤At the beginning of a project, it is much easier to go with Monolithic Architecture.

Simple to test. For example, you can implement end-to-end testing by simply launching the application and testing the UI with Selenium.

Simple to deploy. You have to copy the packaged application to a server.

Simple to scale horizontally by running multiple copies behind a load balancer.



Drawbacks:


Maintenance ➼ If Application is too large and complex to understand entirely, it is challenging to make changes fast and correctly.

The size of the application can slow down start-up time.

You must redeploy the entire application on each update.

Monolithic applications can also be challenging to scale when different modules have conflicting resource requirements.

Reliability ➼ Bug in any module (e.g. memory leak) can potentially bring down the entire process. Moreover, since all instances of the application are identical, that bug impact the availability of the entire application

Regardless of how easy the initial stages may seem, Monolithic applications have difficulty in adopting new and advanced technologies. 

Since changes in languages or frameworks affect an entire application, it requires efforts to thoroughly work with the app details, hence it is costly considering both time and efforts.

Microservices Architecture


Microservices are an approach to application development in which a large application is built as a suite of modular services (i.e. loosely coupled modules/components). 

Each module supports a specific business goal and uses a simple, well-defined interface to communicate with other sets of services.

Instead of sharing a single database as in Monolithic application, each microservice has its own database.

 Having a database per service is essential if you want to benefit from microservices because it ensures loose coupling. 

Each of the services has its own database. Moreover, a service can use a type of database that is best suited to its needs.

Consider the same example of the e-commerce application, which consists of several components/modules. 

Define each component/module as a separate loosely coupled service depending on the requirement, which may collaborate with each other based on the scenario. 

We can have the following services for a complete application:

  • Authorization Service⇰Responsible for authorizing customer.
  • Order Service⇰takes an order and process it.
  • Catalog Service⇰Manage products and check products inventory.
  • Cart Service⇰Manage user cart, this service can utilize Catalog service as a data source.
  • Payment Service⇰Manage and Authorize payments.
  • Shipping Service⇰Ships ordered products.


im98

Benefits:


Microservices Enables the continuous delivery and deployment of large, complex applications.

  • Better testability➨services are smaller and faster to test.
  • Better deployability➨services can be deployed independently.


It enables you to organize the development effort around multiple teams.

 Each team is responsible for one or more single service.

 Each team can develop, deploy and scale their services independently of all of the other teams.

Each microservice is relatively small

Comfortable for a developer to understand

The IDE is faster making developers more productive

The application starts faster, which makes developers more productive, and speeds up deployments

Improved fault isolation. For example, if there is a memory leak in one service then only that service is affected. 

The other services continue to handle requests. In comparison, one misbehaving component of a monolithic architecture can bring down the entire system.

Microservices Eliminates any long-term commitment to a technology stack. 

When developing a new service you can pick a new technology stack. Similarly, when making major changes to an existing service you can rewrite it using a new technology stack.



Drawbacks:



Developers must deal with the additional complexity of creating a distributed system.

Developer tools/IDEs are oriented on building monolithic applications and don’t provide explicit support for developing distributed applications.

Testing is more difficult as compared to Monolith applications.

Developers must implement the inter-service communication mechanism.

Implementinga use cases that span multiple services without using distributed transactions is difficult.

Implementing use cases that span multiple services requires careful coordination between the teams.

Deployment complexity. In production, there is also the operational complexity of deploying and managing a system comprised of many different service types.

Increased memory consumption. The microservice architecture replaces N monolithic application instances with NxM services instances. If each service runs in its Container, which is usually necessary to isolate the instances, then there is the overhead of M times as many Containers.


im100




Microservices vs. Monolith Architecture


The evolution of technologies has changed the way we build the architecture of applications.

 Docker, Cloud services, and Container Orchestration services brought us ability to develop distributed, more scalable, and reliable solutions. 

In this article, we will compare microservices and monolith architecture, discuss what teams and projects should use what type of architecture, and explore their advantages and disadvantages.

At a glance, the difference between those types can be illustrated like this


im102



It is not strictly true that monolith apps are always simple, but microservices are often 10 times larger and almost always requires more resources.

Let’s discuss the pros and cons of each, point by point.



Deployment

Monolith apps allow you to set your deployment once and then simply adjust it based on ongoing changes.

 At the same time, however, there is also only a single point of failure during deployment and, if everything goes wrong, you could break your entire project.

Microservices require much more work; you will need to deploy each microservice independently, worry about orchestration tools, and try to unify the format of your ci/cd pipelines to reduce the a amount of time required for doing it for each new microservice. 

There is a bright side, however; if something goes wrong, you will only break one small microservice, which is less problematic than the entire project. 

It’s also much easier to rollback one small microservices than and entire monolith app.



Maintenance

If you plan to use a microservices architecture, get a DevOps for your team and prepare yourself.

 Not every developer will be familiar with Docker or orchestration tools, such as Kubernetes, Docker Swarm, Mesosphere, or any similar tool that could help you to manage infrastructure with a lot of moving parts. 

Someone has to monitor and maintain the functioning state of your CI configuration for each microservice and the whole infrastructure.



Reliability

Microservices architecture is the obvious winner here. 

Breaking one microservice affects only one part and causes issues for the clients that use it, but no one else.

 If, for example, you’re building a banking app and the microservice responsible for money withdrawal is down, this is definitely less serious than the whole app being forced to stop.


Scalability


For scalability, microservices are again better suited. 

Monolith apps are hard to scale because, even if you run more workers, every worker will be on the single, whole project, an inefficient way of using resources. 

Worse, you may write your code in the way that would render it impossible to scale it horizontally, leaving only vertical scaling possible for your monolith app. 

With microservices, this is much easier. Resources can be used more carefully and allow you to scale only that parts that require more resources.


Cost


Cost is tricky to calculate because monolith architecture is cheaper in some scenarios, but not in others. 

For example, with the better scalability of microservices, you could set up an auto-scale and only pay for that when the volume of users really requires more resources. 

At the same time, to keep that infrastructure up and running you need a devops that needs to be paid. With a small monolith app, you could run on a $5-$20 host and turn on the snapshot. 

With a larger monolith app, you may host a very expensive instance because you can’t share it over multiple small, cheap hosts.


Development


In one of our projects, we have 16 microservices and I could tell you from experience that this can be tricky to deal with it. 

The best way to deal with microservices is to build your docker-compose file from the beginning and develop through Docker. 

This helps you reduce the time spent onboarding new people; simply run the system from scratch and launch all microservices as needed. 

Opening 10+ terminal windows and executing commands to start each individual service is a pain.


On the other hand. when you develop one microservice, you may have a case in which you don’t need to run other parts of the application at all. 

This results in fewer problems with git conflicts due to the better process of breaking down tasks and the ability to isolate developers across microservices.

Doing code review and QA is simpler with microservices; you may even be able to write microservices in different languages.


Releasing


Microservices that are smaller and with a proper architecture of microservices communication allow you to release new features faster by reducing QA time, build time, and tests execution time.

 Monolith apps have a lot of internal dependencies that could not be broken up. 

There is also a higher risk that something you are committed to could depend on unfinished changes from your team members, which could potentially postpone releases.

What’s architecture better to you?


Use monolith architecture if you:

  • Have a small team.

  • Build the MVP version of a new product.

  • Did not get millions in investments to hire DevOps or spend extra time on complex architecture.

  • Have experience of development on solid frameworks, such as Ruby on Rails, Laravel, etc.

  • Don’t see performance bottlenecks for some key functionality.

  • Think that microservices are cool and it’s a trend.
Keep in mind that if you find out that there is need of microservices in your project, monolith architecture always carries the risk of break down as a result of these small microservices.



Use microservices architecture if you:

  • Don’t have a tight deadline; microservices require you to research and architecture planning to ensure it works.
  • Have a team with knowledge of different languages.
  • Worry a lot about the scalability and reliability of your product.
  • Potentially have a few development departments(maybe even in different countries/time zones).
  • Have an existing monolith app and see problems with parts of your application that could be split across multiple microservices.

MVC


MVC stands for Model–view–controller.

 It is a software architectural pattern for implementing user interfaces on computers.

 It divides a given software application into three interconnected parts, so as to separate internal representations of information from the ways that information is presented to or accepted from the user.

Components of MVC


1) Model: It specifies the logical structure of data in a software application and the high-level class associated with it. It is the domain-specific representation of the data which describes the working of an application. When a model changes its state, domain notifies its associated views so they can refresh.

2) View: View component is used for all the UI logic of the application and these are the components that display the application’s user interface (UI). It renders the model into a form suitable for interaction. Multiple views can exist for a single model for different purposes.

3) Controller: Controllers act as an interface between Model and View components. It processes all the business logic and incoming requests, manipulates data using the Model component, and interact with the Views to render the final output. It receives input and initiates a response by making calls on model objects.



imaa120


Advantages of MVC



1) Faster development process: MVC supports rapid and parallel development. With MVC, one programmer can work on the view while others can work on the controller to create business logic of the web application. The application developed using MVC can be three times faster than an application developed using other development patterns.

2) Ability to provide multiple views: In the MVC Model, you can create multiple views for a model. Code duplication is very limited in MVC because it separates data and business logic from the display.

3) Support for asynchronous technique: MVC also supports asynchronous technique, which helps developers to develop an application that loads very fast.

4) The modification does not affect the entire model: Modification does not affect the entire model because the model part does not depend on the views part. Therefore, any changes in the Model will not affect the entire architecture.

5) MVC model returns the data without formatting: MVC pattern returns data without applying any formatting so the same components can be used and called for use with any interface.

6) SEO friendly Development platform: Using this platform, it is very easy to develop SEO-friendly URLs to generate more visits from a specific application.

Disadvantages of MVC


1) Increased complexity

2) The inefficiency of data access in view

3) The difficulty of using MVC with a modern user interface.

4) Need multiple programmers

5) Knowledge of multiple technologies is required.

6) Developer has knowledge of client-side code and HTML code.


Tools and technologies used with MVC


There are many tools and technologies which can be used to the developed web application with the help of MVC architecture.

 Depending upon the interest of developers, they can use any of the tools and technologies to develop a web application.

 Here are some tools and technologies which can be used to develop a web application using MVC architecture:

Tools


Visual Studio: Visual Studio is not just only a tool but a complete development environment which provide us facility to create different kinds of application. 

When we want to develop an application using ASP.NET MVC framework then the visual studio is very helpful for us.

1) MYSQL Server ↝ relational database management services to maintain the database.

2) SQL Server ↝ a database engine to maintain database just like MYSQL server 

3) MYSQL Workbench ↝a database design tool 

4) Net Beans ↝ ⇗IDE (integrated development Environment) provide complete environment to develop different applications 

5) Glassfish Server: Java EE application server  


Technologies


 A. HTML, CSS, JQUERY, AJAX for designing

B. Servlet and Java server pages (JSP) used with Net beans

C. EJB (Enterprise Java beans) technologies

D. JSTL (Java server pages standard tag libraries)

E. JPA (Java persistence API)

F. JDBC (Java database connectivity)

G. ASP.NET MVC used with Visual studio

Example of MVC architecture application


★In our research study we have tried to make an Ecommerce web application using MVC architecture which will help the developers to understand the features of model view and controller pattern. E-commerce refers to the online selling and purchasing of goods over the internet. For example, amazon.com is today’s most useful e-commerce website which provides different products of different categories. Customer can purchase those products online using internet. There are different types of e-commerce applications such consumer to consumer, Business to business, business to consumer.

★In our application we have developed a business to consumer application which normally accommodates a B2C scenario consists of two components: first component store front which enables the customers to view different products, the data about the products is maintained in the database and is displayed to the customers on the pages dynamically. Second component is admin console which is protected area. It cannot be accessed by the customers instead it is available to the administration who manages the customer transactions such as customer orders, shipping and payment methods, CRUD (create read update delete) access to the database store.

★The technology used in our application is Java. Java is a programming language which contains the fundamental concepts that can be grasped quickly. It sticks to an object-oriented technique which contained encapsulated objects that communicates with each other by passing information. Java include compile and run time checking to identify the errors. It also contains network security features. It is portable, application can easily be transferred from one platform to another platform with the need of a very little or no modification. Java interpreter is independent of run time environment, so we can run applications quickly. It also provides an automatic garbage collector to free unused memory.

★Java is not only a programming language it is a complete platform which suggests software-based platform consist of two components. JVM (java virtual machine), engine used to execute the instruction translated by the java complier. It is considered as an instance of JRE (java runtime environment) and inserted in different products such as operating system, browsers and web servers etc. Second component of java platform is java application program interface (API) which provides prewritten codes which are prearranged into packages. These packages include classes for creating user interfaces such as font, button, menus etc. There are several editions of java platform such as Java standard edition, Java micro edition and java enterprise edition. Here we are working with java enterprise edition.

★Java enterprise edition provides technologies used for developing and managing vigorous, consistent, scalable and secure server-side applications. These enterprise edition technologies are divided into two categories. These categories include web application technologies and enterprise application technologies. In our application as we must develop a web application so mostly we will be getting help from web application technologies. In our web application we are using Servlet, JSP, JSTL, EJB, and JPA enterprise technologies. Java EE technologies are mostly used technologies in the market as we have shown in a diagram taken from independent survey of European market perform in 2007 (Figure 1).

★★Figure 1:Survey findings about well-known IDEs.


imaa122


★The tools which we have used for the development of our application are net beans IDE, MySQL server and MySQL workbench. NetBeans is a development environment provides the facility of creating professional, enterprise desktop, mobile and web applications. MySQL server is a database engine used to maintain our database. MySQL workbench is used to visually design database such as ERD (entity relationship diagram).

Designing the application


✦Designing the application demonstrates that how our application can be applied to real world business requirements. Before designing the application, we try to gather the customer requirements. The customer requirements should be clear. As per requirements of our application, our application should meet the following customer requirements.

a. Online representation of data which should be stored in our database. The information about our products which will be displayed to the customer will be (name, image and description).

b. Add products temporary selected by our customer to a shopping cart.

c. Customer can update the quantity of the selected products.

d. Customer can remove the selected product from shopping cart.

e. Customer can view summary of shopping cart i.e. which product he selected and in how much quantity.

f. Customer can place an order and can make payment through a secure checkout process.

g. Our application should provide server-side administration so that administrators can view customer orders, add new products for the customers.

✦After gathering the requirements, we should design application according to customer requirements. We will try to make a use case which will describe that how our application will work and encapsulate its behavior. In our application we are making an e-commerce web site, so our use case will describe the following actions to be performed by different actors.

1) Customer can browse different products of the selected category.

2) Customer will add his desired products of different categories into shopping cart so that later he can purchase it.

3) Customer can view his shopping cart to see which items he has selected.

4) Customer can verify the shopping cart information so that he can proceed to checkout process.

5) Customer will provide his personal information as well he will see his order details on checkout page.

6) After viewing the checkout process page customer will confirm his order.

7) Administrator will view the orders of different customers after successfully login to our application.

8) Administrator can add new products into different categories.

✦According to above given use-case we must identify and design web pages which will be used in our application. We can create the mockups using different techniques. The technique which we use to design our application is paper prototyping in which we try to cooperate with customers by sketching ideas on the paper. In our application we have design five web pages i.e. welcome page (home page entry point to our application where our main categories of products will be shown), Category page (which will show us the list of different products also it will show us shopping cart option and proceed to checkout option), cart page (which will show us the list of all the product items which we have selected for purchasing), checkout page (which will be used to collect the user personal information as well as it will provide the order summary) and confirmation page (which will show the information that his order has been successfully placed) (Figure 2).

✦✦Figure 2:Purchasing an item using a web-application.


imaa1233


Determining the architecture


✴Before we start the development of application we should decide that which type of architecture we should use to develop our application. We should examine the functional components of our application and determine the way through which they will communicate with each other. There are many design patterns are available which can be used to develop an application. Here we are going to use MVC architecture pattern.

✴✴Figure 3:Functionality of each layer in MVC architecture.



imaa1234



✴MVC pattern divides our application into three major components i.e. Model, View and Controller. Model is used to communicate with our database. View is used to get data from model and present it to the user. And finally, the controller is used to define the application behavior. It interacts with the inputs of the users. Normally in web-based application user’s inputs are HTTP GET and HTTP POST. Detail about the MVC architecture pattern is given earlier in this paper in section I, section II, section III and Section IV (Figure 3).

✴Here we will be working with JSP technologies, our business logic into JSP pages will be coded using script lets. The script lets are snippets in <% %> tags. JSP pages will be compiled into Servlet. JSP was firstly introduced in 1999 and it included a description of two model architectures. Model one involves implementing business logic directly with JSP pages and second model applies the MVC pattern architecture which we are using in our application (Figure 4).

✴✴Figure 4:Interaction and overview of the MVC layers.


imaa1235

Designing the data model


🌤In this step we should create a conceptual model of our storage system by defining the entities if our system and relationship among them. Our data model will contain both logical and physical design parameters required to generate a script using data definition language (DDL), which will be helpful in creating a database. As we have stated earlier we will use MySQL workbench to create data model, reverse-engineer SQL into visual presentations, forwardengineer data models into database schema and synchronize models with a running MySQL database server.

🌤In our application we have identified four entities customer, category, product and order to construct an ERD (entity relationship diagram). We created a database schema from the ERD; we used IDE’s Eclipse Link support to generate JPA classes from the database. We have used the technique of bottom up approach which begins with an existing database schema. It provides the easiest way to use forward engineering tool to take out the metadata from schema and generate the JPA entity classes.


Development of application


🎕In development of application first we begin with the development of our application front end of application by creating JSP pages and placing them in proper locations, creating the header and footers which will be displayed in every view and setting up Servlet which will handle the entire incoming requests from the users. We also created a deployment descriptor (web.xml) which contained all the configuration information of the application.

🎕After creating front-end of our application, we enabled our application that it can communicate with the database, for which we add sample data into the database and set up a data source and a connection pool on Glassfish server to proceed by JSP pages which will test the data source. We also use the JSTL library and SQL tag library to retrieve and show the images of different categories and products on the index and category pages.

🎕After that we created java persistent API class for each table in the database, complete with named query annotations, fields (columns) and relationships (foreign keys). We also created the EJB session façade for each entity class to define their access methods. In EE developments following two technologies are used for development of Model component:

a) Enterprise Java Beans: it is a server-side component architecture which is used for fast and easy development of distributed, transactional, convenient application. It creates pool of component instance which is shared by users. It also provides thread safety, as well as transaction management. EJB provide the service of java authentication and authorization (JAAS) which provide security to our application.

b) Java Persistent: Java persistent automatically stores the data into the database contained by the java objects. It is an object relational technology which helps the application to manage the data between java objects and database in such a way that it is apparent to the developer. Transparency of data to the developer provides facilities of data caching and performance optimization.

🎕Enterprise session beans are invoked by the users to perform a business operation. Session bean is available for some duration of time. Session bean is crashed when the EJB container is crashed and after crashing of session bean, user must re-establish a new session object to continue calculation. There are three types of session beans provided by the EJB i.e. stateful which is maintained across multiple method calls, stateless which is useful for those operations that can take place in single method call, and singleton which is instantiated only once per application and exists until the application remains active.

🎕In our application we are using stateless session bean. We have used HTTP protocol which is stateless protocol; over which communication take place on the internet. We must create a session in which user related information is maintained for some duration before the information is properly stored into the database. We used HTTP Session for maintaining user’s sessions (cookies). We have also secured our application by properly setting up the login process for administration console through which only authorized administrators will access console services and unauthorized users will be blocked. We have configured a secure data transport for customer checkout process as well as administration console.

🎕For this purpose, we have used Glassfish server administration console to make users groups corresponds to our application. We also tested our application using JMeter kit plug-in. It enables us to check the performance of our application whether it is working properly or not.

MVC - Strengths and Weaknesses

I have worked with both web forms and MVC.

I like ASP.NET MVC more than Web Forms.

In fact, it is hard for me to go back to Web Forms now.  

However, if I did not learn Web Forms first I would not have as much respect for MVC as I do now.  

Nonetheless, here is my input:

ASP.NET Web Form strengths:

  • Rapid development
  • Easy to learn and implement.



ASP.NET Web Form weaknesses:

  • Bizarre page life cycles, sometimes leaves you guessing where to put your code.
  • Very often I had to fight with my code just to produce something simple, my workarounds included lots of javascript.
  • False separation of concerns, business logic / data logic can easily be placed into your code behinds.
  • Viewstate can grow enormously making your web pages even larger in size
  • Little control over the HTML


ASP.NET MVC strengths

  • Complete separation of concerns over view, data, and business logic.
  • Convention over configuration, ASP.NET MVC practically forces you to follow a naming convention
  • Much improved control over your HTML
  • No postbacks / viewstate
  • Support for unit testing


ASP.NET MVC weaknesses

  • Takes some time to learn.  First couple of sessions with MVC will feel rough especially if you are coming from a Web Forms background.


Choosing which one to start with depends on the size of your application.  If it is something small and will not require a lot of maintenance then web forms is perfectly fine.  If you have a larger application with multiple programmers involved then MVC is a better choice.

 Technologies for Supporting Distributed Computing

To address the challenge described above, therefore, three levels of support for distributed computing were developed:ad hoc network programming, structured communication, and middleware. Ad hoc network programming includes interprocess communication (IPC) mechanisms, such as shared memory, pipes, and sockets, that allow distributed components to connect and exchange information. These IPC mechanisms help address a key challenge of distributed computing: enabling components from different address spaces to cooperate with one another.


Certain drawbacks arise, however, when developing distributed systems only using ad hoc network programming support. For instance, using sockets directly within application code tightly couples this code to the socket API. Porting this code to another IPC mechanism or redeploying components to different nodes in a network thus becomes a costly manual programming effort. Even porting this code to another version of the same operating system can require code changes if each platform has slightly different APIs for the IPC mechanisms [POSA2] [SH02]. Programming directly to an IPC mechanism can also cause a paradigm mismatch, e.g., local communication uses object-oriented classes and method invocations, whereas remote communication uses the function-oriented socket API and message passing.


The next level of support for distributed computing is structured communication, which overcomes limitations with ad hoc network programming by not coupling application code to low-level IPC mechanisms, but instead offering higherlevel communication mechanisms to distributed systems. Structured communication encapsulates machine-level details, such as bits and bytes and binary reads and writes. Application developers are therefore presented with a programming model that embodies types and a communication style closer to their application domain.


Historically significant examples of structured communication are remote procedure call (RPC) platforms, such as Sun RPC and the Distributed Computing Environment (DCE). RPC platforms allow distributed applications to cooperate with one another much like they would in a local environment: they invoke functions on each other, pass parameters along with each invocation, and receive results from the functions they called. The RPC platform shields them from details of specific IPC mechanisms and low-level operating system APIs. Another example of structured communication is ACE [SH02] [SH03], which provides reusable C++ wrapper facades and frameworks that perform common structured communication tasks across a range of OS platforms.


Despite its improvements over ad hoc network programming, structured communication does not fully resolve the challenges described above. In particular, components in a distributed system that communicate via structured communication are still aware of their peers’ remoteness—and sometimes even their location in the network. While location awareness may suffice for certain types of distributed systems, such as statically configured embedded systems whose component deployment rarely changes, structured communication does not fulfill the following the properties needed for more complex distributed systems:

• Location-independence of components. Ideally, clients in a distributed system should communicate with collocated
or remote services using the same programming model. Providing this degree of location-independence requires the
separation of code that deals with remoting or location-specific details from client and service application code.
Even then, of course, distributed systems have failure modes that local systems do not have [WWWK96].


 Flexible component (re)deployment. The original deployment of an application’s services to network nodes could
become suboptimal as hardware is upgraded, new nodes are incorporated, and/or new requirements are added. A redeployment of distributed system services may therefore be needed, ideally without breaking code and or shutting down the entire system.


Mastering these challenges requires more than structured communication support for distributed systems. Instead it requires dedicated middleware [ScSc02], which is distribution infrastructure software that resides between an application and the operating system, network, or database underneath it. Middleware provides the properties described above so that application developers can focus on their primary responsibility: implementing their domain-specific functionality. Realizing the need for middleware has motivated companies, such as Microsoft, IBM, and Sun, and consortia, such as the Object Management Group (OMG) and the World Wide Web Consortium (W3C), to develop technologies for distributed computing. Below, we describe a number of popular middleware technologies, including distributed object computing, component middleware, publish/subscribe middleware, and service-oriented architectures and Web Services [Vin04a]. 


 Understanding Distributed Systems Software Technologies via Patterns

Although the various middleware technologies described in Section 2 differ widely in their programming interfaces and language mappings they share many of the same patterns [VKZ04]. Design-focused patterns provide a vocabulary for expressing architectural visions, as well as examples of representative designs and detailed implementations that are clear and concise. Presenting pieces of software in terms of their constituent patterns also allows developers to
communicate more effectively, with greater conciseness and less ambiguity.


Distributed computing has been a popular focus for pattern authors for many years. For example, [POSA2] and [VKZ04] present collections of patterns for developing distributed object computing middleware. Likewise,[HOHPE03] and [FOW02] present collections of patterns for enterprise message-oriented middleware and serviceoriented architectures. Most recently, [POSA4] has captured an extensive pattern language for building distributed software systems that connects over 250 patterns addressing topics ranging from defining and selecting an appropriate
baseline architecture and communication infrastructure, to specifying component interfaces, their implementations, and their interactions. Together, the patterns covered in these books address key technical aspects of distributed computing, such as adaptation and extension, concurrency, database access, event handling, synchronization, and resource
management.


As software is integrated into mission-critical systems there is an increasing need for robust techniques to meet user dependability requirements. Patterns on fault tolerance and fault management have therefore been an active focus over the past decade. Several recent books [UTAS05] [HAN07] contain patterns and pattern languages that address fault tolerance and fault management for systems with stringent operational requirements. Likewise, developing high-quality distributed real-time and embedded (DRE) systems that provide predictable behavior in networked environments is
also increasingly crucial to support mission-critical systems. Patterns that guide the development of resource management algorithms and architectures for DRE software appear in [DIP07] and [POSA3]. 


Remote Procedure Call 

Definition 

🔼Remote Procedure Call (RPC) is a programming language feature devised for the distributed computing and based on semantics of local procedure calls. It is the most common forms of remote service and was designed as a way to abstract the procedure call mechanism to use between systems connected through a network. It is similar to IPC mechanism where the operating system allows the processes to manage shared data and deal with an environment where different processes are executing on separate systems and necessarily require message-based communication.

🔼🔼Let’s understand how RPC is implemented through the given steps:


  • The client process calls the client stub with parameters, and its execution is suspended until the call is completed.
  • The parameters are then translated into machine-independent form by marshalling through client stub. Then the message is prepared which contain the representation of the parameters.
  • To find the identity of the site the client stub intercommunicate with name server at which remote procedure exists.
  • Using blocking protocol the client stub sends the message to the site where remote procedure call exists. This step halt the client stub until it gets a reply.
222



  • The server site receives the message sent from the client side and converts it into machine specific format.
  • Now server stub executes a call on the server procedure along with the parameters, and the server stub is discontinued till the procedure gets completed.
  • The server procedure returns the generated results to the server stub, and the results get converted into machine-independent format at server stub and create a message containing the results.
  • The result message is sent to the client stub which is converted back into machine specific format suitable for the client stub.
  • At last client, stub returns the results to the client process.


Remote Method Invocation 

Definition 

Remote Method Invocation (RMI) is similar to RPC but is language specific and a feature of java. A thread is permitted to call the method on a remote object. To maintain the transparency on the client and server side, it implements remote object using stubs and skeletons. The stub resides with the client and for the remote object it behaves as a proxy.

When a client calls a remote method, the stub for the remote method is called. The client stub is accountable for creating and sending the parcel containing the name of a method and the marshalled parameters, and the skeleton is responsible for receiving the parcel.


333



The skeleton unmarshals parameters and invokes the desired method on the server. The skeleton marshals the given value (or exceptions) with the parcel and sends it to client stub. The stub reassembles the return parcel and sends it to the client.


 In Java, the parameters are passed to methods and returned in the form of reference. This could be troublesome for RMI service since not all objects are possibly remote methods. So, it must determine which could be passed as reference and which could not.

Java uses process named as serialisation where the objects are passed as value. The remote object is localised by pass by value. It can also pass an object by reference through passing a remote reference to the object along with the URL of the stub class. Pass by reference restricts a stub for the remote object.


Key Differences Between RPC and RMI

  • RPC supports procedural programming paradigms thus is C based, while RMI supports object-oriented programming paradigms and is java based.
  • The parameters passed to remote procedures in RPC are the ordinary data structures. On the contrary, RMI transits objects as a parameter to the remote method.
  • RPC can be considered as the older version of RMI, and it is used in the programming languages that support procedural programming, and it can only use pass by value method. As against, RMI facility is devised based on modern programming approach, which could use pass by value or reference. Another advantage of RMI is that the parameters passed by reference can be changed.
  • RPC protocol generates more overheads than RMI.
  • The parameters passed in RPC must be “in-out” which means that the value passed to the procedure and the output value must have the same datatypes. In contrast, there is no compulsion of passing “in-out” parameters in RMI.
  • In RPC, references could not be probable because the two processes have the distinct address space, but it is possible in case of RMI.


Difference Between RPC and RMI

RPC and RMI are the mechanisms which enable a client to invoke the procedure or method from the server through establishing communication between client and server. The common difference between RPC and RMI is that RPC only supports procedural programming whereas RMI supports object-oriented programming.

Another major difference between the two is that the parameters passed to remote procedures call consist of ordinary data structures. On the other hand, the parameters passed to remote method consist of objects.

Comparison Chart


44



Common Object Request Broker Architecture (CORBA)



This section provides a short introduction to CORBA, and should give you some idea of how you typically use CORBA in the Oracle8i server environment. Providing a complete introduction to CORBA is beyond the scope of this Guide. See the references in "For More Information" for suggested further reading. This first section gives a very high-level overview of CORBA itself.

CORBA stands for Common Object Request Broker Architecture. What is common about CORBA is that it integrates ideas from several of the original proposers. CORBA did not just follow the lead of a single large corporation, and it is very deliberately vendor neutral. The CORBA architecture specifies a software component, a broker, that mediates and directs requests to objects that are distributed across a network (or several networks), which might have been written in a different language from that of the requestor, and which might be (and in fact, usually are) running on a completely different hardware architecture from that of the requestor.

You can begin to get an idea of the tremendous advantages of CORBA from the preceding paragraph. CORBA enables your application to tie together components from various sources. Also, and unlike a typical client/server application, a CORBA application is not inherently synchronous. It is not necessarily typical that a CORBA requestor (a client) invokes a method on a server component and waits for a result. Using asynchronous method invocations, event interfaces and callbacks from server object to the client ORB, you can construct elaborate applications that link together many interacting objects and that access one or many data sources and other resources under transactional control. CORBA enables you to go beyond the bounds of the traditional client/server application in many imaginative ways.

CORBA Features

CORBA achieves its flexibility in several ways:

  • It specifies an interface description language (IDL) that allows you to specify the interfaces to objects. IDL object interfaces describe, among other things:
  • The data that the object makes public.
  • The operations that the object can respond to, including the complete signature of the operation. CORBA operations map to Java methods, and the IDL operation parameter types map to Java datatypes.
  • Exceptions that the object can throw. IDL exceptions also map to Java exceptions, and the mapping is very direct.


CORBA provides bindings for many languages, including both non-object languages such as COBOL and C, and object-oriented languages such as Smalltalk and Java.
  • All CORBA implementations provide an object request broker (ORB), that handles the routing of object requests in a way that is largely transparent to the application developer. For example, requests (method invocations) on remote objects that appear in the client code look just like local method invocations. The remote call functionality, including marshalling of parameter and return data, is performed for the programmer by the ORB.
  • CORBA specifies a network protocol, the Internet Inter-ORB Protocol (IIOP), that provides for transmission of ORB requests and data over a widely-available transport protocol: TCP/IP, the Internet standard.
  • A set of fully-specified services eases the burden of application development by making it unnecessary for the developer to constantly reinvent the wheel. Among these services are:
  • Naming. One or more services that let you resolve names that are bound to CORBA server objects.
  • Transactions. Services that let you manage transaction control of data resources in a flexible and portable way.
  • Events.

CORBA specifies over 12 services. Most of these are not yet implemented by CORBA ORB vendors.

The remainder of this section introduces some of the essential building blocks of an Oracle8i JServer CORBA application. These include:

  • the ORB--how to talk to remote objects
  • IDL--how to write a portable interface
  • the naming service (and JNDI)--how to locate a persistent object
  • object adapters--how to register a transient object

ADVANTAGES 


  • CORBA supports many existing languages. CORBA also supports mixing these languages within a single distributed application.
  • CORBA supports both distribution and Object Orientation.
  • CORBA is an industry standard. This creates competition among vendors and ensures that quality implementations exist. The use of the CORBA standard also provides the developer with a certain degree of portability between implementations. Note: application source is not 100% portable between different CORBA products.
  • CORBA provides a high degree of interoperability. This insures that distributed objects built on top of different CORBA products can communicate. Large companies do not need to mandate a single CORBA product for all development.
  • Over 600 companies back CORBA, including hardware companies, software companies, and cable companies, phone companies, banks, etc.


Benefits of CORBA


 Maturity

  • The original version of the CORBA standard was defined in 1991. This first version of the specification was deliberately limited in scope. The OMG’s philosophy was to define a small standard, let implementors gain experience and then slowly expand the standard to incorporate more and more capabilities. This “slow but sure” approach has been remarkably successful. In particular, there have been few backwards-incompatible changes to the CORBA specification. Instead, new versions of the specification have tended to add new functionality rather than modify existing functionality. Today, CORBA is extremely feature-rich, supporting numerous programming languages, operating systems, and a diverse range of capabilities—such as transactions, security, Naming and Trading services, messaging and publish-subscribe services—that are essential for many enterprise-level applications. Many newer middleware technologies claim to be superior to CORBA but actually have to do a lot of “catching up” just to match some of the capabilities that CORBA has had for a long time.


 Open standard

  • CORBA is an open standard rather than a proprietary technology. This is important for a variety of reasons.
  • First, users can choose an implementation from a variety of CORBA vendors (or choose one of the freeware implementations). You might think that switching from one CORBA product to another would involve a lot of work. However, the amount of work involved is likely to be much less than you might think, particularly if you follow the practical advice in Chapter 25 about how to increase the portability of CORBA-based applications. In contrast, if you use a proprietary middleware system then switching to another proprietary middleware vendor is much more challenging.
  • Second, the competition between different CORBA vendors helps to keep software prices down.

  • Finally, many proprietary middleware technologies are designed with the assumption that developers will build all their applications using that particular middleware technology, and so they provide only limited support for integration with other technologies. In contrast, CORBA was designed with the goal of making it easy to integrate with other technologies. Indeed, the CORBA specification explicitly tackles integrations with TMN, SOAP, Microsoft’s (D)COM and DCE (a middleware standard that was popular before CORBA). Furthermore, many parts of J2EE borrow heavily from concepts in CORBA, which makes it relatively easy to integrate J2EE and CORBA. Some vendors sell gateways between CORBA and J2EE that make such integration even easier. Several CORBA vendors sell COM-to-CORBA and/or .NET-to-CORBA gateways. This provides a very pragmatic solution to organizations that wish to write GUI applications in, say, Visual Basic on Windows that act as clients to server applications on a different type of computer, such as UNIX or a mainframe. The Visual Basic GUI can be written as a COM/.NET client that thinks it is talking to a COM/.NET server, but in fact communicates with a gateway that forwards on requests to a CORBA server.


 Wide platform support


  • CORBA implementations are available for a wide variety of computers, including IBM OS/390 and Fujitsu GlobalServer mainframes, numerous variants of UNIX (including Linux), Windows, AS/400, Open VMS, Apple’s OS X and several embedded operating systems. There are very few other middleware technologies that are available on such a wide range of computers.



  Wide language support


  • CORBA defines standardized language mappings for a wide variety of programming languages, such as C, C++, Java, Smalltalk, Ada, COBOL, PL/I, LISP, Python and IDLScript. Some small organizations might use a single programming language for all their projects, but as an organization increases in size, it becomes increasingly likely that the organization will make use of several programming languages. Likewise, the older an organization is, the higher the likelihood becomes that some of its “legacy” (older) applications are implemented in one programming language and newer applications are implemented in a different programming language. For these organizational reasons, it is important for a middleware system to support many programming languages; unfortunately, not all middleware systems do so. One extreme case of this is J2EE, which supports only Java. Another extreme case is the SOAP middleware standard. SOAP applications can be built with a variety of programming languages but, at the time of writing, the SOAP standard defines only one language mapping (for Java). There may be several vendors who support, say, C++ development of SOAP applications, but each of those vendors provides their own proprietary C++ APIs. This means that there is no source-code portability of non-Java SOAP applications across different vendor products.


  Efficiency


  • The on-the-wire protocol infrastructure of CORBA (discussed in Chapter 11) ensures that messages between clients and servers are transmitted in a compact representation. Also, most CORBA implementations marshal data (that is, convert data from programming-language types into a binary buffer that can be transmitted) efficiently. Many other middleware technologies also use a similarly compact format for transmitting data and have efficient marshaling infrastructure. However, there are some notable exceptions, as I now discuss.
  • SOAP uses XML to represent data that is to be transmitted. The verbosity of XML results in SOAP using much more network bandwidth than CORBA.1 SOAP-based applications also incur considerable CPU overhead involved in formatting programming-language types into XML format and later parsing the XML to extract the embedded programming-languages types.
  • Some other middleware technologies, such as IBM MQ Series, transmit only binary data, which is efficient. However, this requires that developers write the marshaling code that copies programming-language types into the binary buffers prior to transmission, and the unmarshaling code to extract the programming-language types from a binary buffer. In contrast, a CORBA IDL compiler generates the marshaling and unmarshaling code, so that developers do not need to write (and maintain) such low-level code.


 Scalability


  • The flexible, server-side infrastructure of CORBA (Chapter 5) makes it feasible to develop servers that can scale from handling a small number of objects up to handling a virtually unlimited number of objects. Obviously, scalability varies from one CORBA implementation to another but, time and time again, real-world projects have demonstrated that a CORBA server can scale to handle not just a huge amount of server-side data, but also high communication loads from thousands of client applications. Most CORBA vendors will likely know of customers who have tried a different middleware technology, found that it could not scale sufficiently well and then switched to CORBA.


 CORBA Success Stories

  • With such an impressive list of benefits as those discussed in this chapter, it is little wonder that CORBA is being used successfully in many industries, including aerospace, consulting, education, e-commerce, finance, government, health-care, human resources, insurance, ISVs, manufacturing, military, petrochemical, publishing, real estate, research, retail, telecommunications, and utilities.
  • CORBA is used in everything from billing systems and multi-media news delivery to airport runway illumination, aircraft radio control and the Hubble space telescope. Most of the world’s telephone systems, as well as the truly mission-critical systems operated by the worlds biggest banks, are built on CORBA.
  • A discussion about real-world projects that have benefitted from the use of CORBA is outside the scope of this book. However, many CORBA success stories are available on various web sites. For example, you can find over 300 CORBA success stories on www.corba.org. The web sites of some CORBA vendors also contain more detailed success stories.


XML 


XML stands for Extensible Markup Language. It is a text-based markup language derived from Standard Generalized Markup Language (SGML).

XML tags identify the data and are used to store and organize the data, rather than specifying how to display it like HTML tags, which are used to display the data. XML is not going to replace HTML in the near future, but it introduces new possibilities by adopting many successful features of HTML.

There are three important characteristics of XML that make it useful in a variety of systems and solutions −

XML is extensible − XML allows you to create your own self-descriptive tags, or language, that suits your application.

XML carries the data, does not present it − XML allows you to store the data irrespective of how it will be presented.

XML is a public standard − XML was developed by an organization called the World Wide Web Consortium (W3C) and is available as an open standard.


XML Usage


A short list of XML usage says it all −

  • XML can work behind the scene to simplify the creation of HTML documents for large web sites.
  • XML can be used to exchange the information between organizations and systems.
  • XML can be used for offloading and reloading of databases.
  • XML can be used to store and arrange the data, which can customize your data handling needs.
  • XML can easily be merged with style sheets to create almost any desired output.

Virtually, any type of data can be expressed as an XML document.


What is Markup?

XML is a markup language that defines set of rules for encoding documents in a format that is both human-readable and machine-readable. So what exactly is a markup language? Markup is information added to a document that enhances its meaning in certain ways, in that it identifies the parts and how they relate to each other. More specifically, a markup language is a set of symbols that can be placed in the text of a document to demarcate and label the parts of that document.

Following example shows how XML markup looks, when embedded in a piece of text −

<message>
   <text>Hello, world!</text>
</message>


This snippet includes the markup symbols, or the tags such as <message>...</message> and <text>... </text>. The tags <message> and </message> mark the start and the end of the XML code fragment. The tags <text> and </text> surround the text Hello, world!.


Is XML a Programming Language?

A programming language consists of grammar rules and its own vocabulary which is used to create computer programs. These programs instruct the computer to perform specific tasks. XML does not qualify to be a programming language as it does not perform any computation or algorithms. It is usually stored in a simple text file and is processed by special software that is capable of interpreting XML.


XML Elements

XML elements can be defined as building blocks of an XML. Elements can behave as containers to hold text, elements, attributes, media objects or all of these.

Each XML document contains one or more elements, the scope of which are either delimited by start and end tags, or for empty elements, by an empty-element tag.

Syntax

Following is the syntax to write an XML element −

<element-name attribute1 attribute2>
....content
</element-name>


where,

element-name is the name of the element. The name its case in the start and end tags must match.

attribute1, attribute2 are attributes of the element separated by white spaces. An attribute defines a property of the element. It associates a name with a value, which is a string of characters. An attribute is written as −

name = "value"
name is followed by an = sign and a string value inside double(" ") or single(' ') quotes.


Empty Element

An empty element (element with no content) has following syntax −

<name attribute1 attribute2.../>
Following is an example of an XML document using various XML element −


<?xml version = "1.0"?>
<contact-info>
   <address category = "residence">
      <name>Tanmay Patil</name>
      <company>TutorialsPoint</company>
      <phone>(011) 123-4567</phone>
   </address>
</contact-info>


XML Elements Rules

Following rules are required to be followed for XML elements −

  • An element name can contain any alphanumeric characters. The only punctuation mark allowed in names are the hyphen (-), under-score (_) and period (.).
  • Names are case sensitive. For example, Address, address, and ADDRESS are different names.
  • Start and end tags of an element must be identical.
  • An element, which is a container, can contain text or elements as seen in the above example.

XML
➥Pros

1. Open and extensible

The XML structure is adaptable and can be modified to match industry specific vocabulary. Users can add elements when needed.

2. Internationalization

Multilingual documents and Unicode standards are supported by XML. This is important for electronic business applications.

3. Future oriented technology 

The W3C has endorsed XML, which is supported by major software providers. It is also being used in an increasing number of industries.

4. Self-describing data

Business applications have tasks other than just presenting the content. XML is therefore used because there is complete data usability as well as proper presentation of data. XML is thus preferred over traditional database systems.

5. Integration of traditional databases and formats

XML documents support all types of data; classical (text, numbers), multimedia (sounds), active formats (java applets, active x components).

6. Data presentation modifications

XML style sheets can be used to modify documents or websites without modifying the actual data.

7. One Server view

Data from different databases and multiple servers can be a part of an XML document. That is, the whole WWW is converted into one database.

➥Cons

1. Requires more development resources and expertise to implement and maintain

2. You become responsible for the programming, logic, debugging and monitoring of your site and you will not be able to leverage the development

3. XML's biggest disadvantage is that its parsers tend to be very large, although the large memory footprint of XML parsers may be reduced to a reasonable size by eliminating unneeded features.

4. The larger size of XML data records may be an issue for some applications. This can be dealt with by compressing the data before transmitting it or writing it to disk.


JSON Pros and Cons


JSON is a simple object serialization approach based on the JavaScript object initializers syntax. The code for initializer (object literal) is put into a string and then interpreted using JavaScript eval() function or JSON parser (which is very lightweight):


 serializedObj='{firstName:"john", lastName:"doe"}';
...
// This is just an example, JSON parser should be used instead
// to avoid security vulnerabilities of "eval"
var obj = eval("(" + serializedObj + ")");
document.getElementById("firstName").innerHTML=person.firstName;


JSON is used extensively in various AJAX frameworks and toolkits to provide easy object serialization for remote calls. It is is supported by both GWT and DOJO. There is a growing realization that perhaps JSON should be considered as an option when implementing SOA, for example Dion Hinchcliffe recently published a blog entry suggesting that JSON (and other Web 2.0 technologies) must be seriously considered by SOA architects.

So what are the benefits of using JSON relative to XML (for this comparison I want to focus just on XML and stay away from SOAP)? Here is my brief take on that, there are also numerous other articles and posts on the subjects.

IMAK

III

So the bottom line is that JSON and XML are, of course, two very different technologies; XML is much broader in scope so I'm not even sure if comparing them side by side is fair.

As an object serialization technology for AJAX (or should it now be called AJAJ since we've replaced XML with JSON?) JSON looks very appealing. Anybody who ever tried parsing SOAP directly in a browser (while having to support multiple browsers) can attest that this is not a straightforward task. JSON simplifies this task dramatically. So I think that ESB vendors should definitely start thinking about adding JSON to the list of formats they support.

One of the keys to SOA success is that it should be easy to consume a service, i.e., the entry barrier for service consumers must be low to support "grass root" SOA adoption. While a top-down SOA effort may succeed, it will certainly take longer than bottom-up ("grass-root") approach when developers are able to consume services as they see fit. AJAX/JSON fits this bill perfectly - it is easily understood by developers and it does not require any Web services -specific tools or infrastructure.

Data Encoding Techniques


Encoding is the process of converting the data or a given sequence of characters, symbols, alphabets etc., into a specified format, for the secured transmission of data. Decoding is the reverse process of encoding which is to extract the information from the converted format.

Data Encoding


Encoding is the process of using various patterns of voltage or current levels to represent 1s and 0s of the digital signals on the transmission link.

The common types of line encoding are Unipolar, Polar, Bipolar, and Manchester.

Encoding Techniques


The data encoding technique is divided into the following types, depending upon the type of data conversion.

Analog data to Analog signals − The modulation techniques such as Amplitude Modulation, Frequency Modulation and Phase Modulation of analog signals, fall under this category.

Analog data to Digital signals − This process can be termed as digitization, which is done by Pulse Code Modulation (PCM). Hence, it is nothing but digital modulation. As we have already discussed, sampling and quantization are the important factors in this. Delta Modulation gives a better output than PCM.

Digital data to Analog signals − The modulation techniques such as Amplitude Shift Keying (ASK), Frequency Shift Keying (FSK), Phase Shift Keying (PSK), etc., fall under this category. These will be discussed in subsequent chapters.

Digital data to Digital signals − These are in this section. There are several ways to map digital data to digital signals. Some of them are −


Non Return to Zero (NRZ)


NRZ Codes has 1 for High voltage level and 0 for Low voltage level. The main behavior of NRZ codes is that the voltage level remains constant during bit interval. The end or start of a bit will not be indicated and it will maintain the same voltage state, if the value of the previous bit and the value of the present bit are same.

The following figure explains the concept of NRZ coding.


lllhj


If the above example is considered, as there is a long sequence of constant voltage level and the clock synchronization may be lost due to the absence of bit interval, it becomes difficult for the receiver to differentiate between 0 and 1.

There are two variations in NRZ namely −

NRZ - L (NRZ – LEVEL)

There is a change in the polarity of the signal, only when the incoming signal changes from 1 to 0 or from 0 to 1. It is the same as NRZ, however, the first bit of the input signal should have a change of polarity.


NRZ - I (NRZ – INVERTED)

If a 1 occurs at the incoming signal, then there occurs a transition at the beginning of the bit interval. For a 0 at the incoming signal, there is no transition at the beginning of the bit interval.

NRZ codes has a disadvantage that the synchronization of the transmitter clock with the receiver clock gets completely disturbed, when there is a string of 1s and 0s. Hence, a separate clock line needs to be provided.

Bi-phase Encoding

The signal level is checked twice for every bit time, both initially and in the middle. Hence, the clock rate is double the data transfer rate and thus the modulation rate is also doubled. The clock is taken from the signal itself. The bandwidth required for this coding is greater.

There are two types of Bi-phase Encoding.

  • Bi-phase Manchester
  • Differential Manchester

Bi-phase Manchester


In this type of coding, the transition is done at the middle of the bit-interval. The transition for the resultant pulse is from High to Low in the middle of the interval, for the input bit 1. While the transition is from Low to High for the input bit 0.


Differential Manchester


In this type of coding, there always occurs a transition in the middle of the bit interval. If there occurs a transition at the beginning of the bit interval, then the input bit is 0. If no transition occurs at the beginning of the bit interval, then the input bit is 1.

The following figure illustrates the waveforms of NRZ-L, NRZ-I, Bi-phase Manchester and Differential Manchester coding for different digital inputs.



Block Coding


Among the types of block coding, the famous ones are 4B/5B encoding and 8B/6T encoding. The number of bits are processed in different manners, in both of these processes.


4B/5B Encoding


In Manchester encoding, to send the data, the clocks with double speed is required rather than NRZ coding. Here, as the name implies, 4 bits of code is mapped with 5 bits, with a minimum number of 1 bits in the group.

The clock synchronization problem in NRZ-I encoding is avoided by assigning an equivalent word of 5 bits in the place of each block of 4 consecutive bits. These 5-bit words are predetermined in a dictionary.

The basic idea of selecting a 5-bit code is that, it should have one leading 0 and it should have no more than two trailing 0s. Hence, these words are chosen such that two transactions take place per block of bits.


8B/6T Encoding


We have used two voltage levels to send a single bit over a single signal. But if we use more than 3 voltage levels, we can send more bits per signal.

For example, if 6 voltage levels are used to represent 8 bits on a single signal, then such encoding is termed as 8B/6T encoding. Hence in this method, we have as many as 729 (3^6) combinations for signal and 256 (2^8) combinations for bits.

These are the techniques mostly used for converting digital data into digital signals by compressing or coding them for reliable transmission of data.

Data Structure - Sorting Techniques


Sorting refers to arranging data in a particular format. Sorting algorithm specifies the way to arrange data in a particular order. Most common orders are in numerical or lexicographical order.

The importance of sorting lies in the fact that data searching can be optimized to a very high level, if data is stored in a sorted manner. Sorting is also used to represent data in more readable formats. Following are some of the examples of sorting in real-life scenarios −

Telephone Directory − The telephone directory stores the telephone numbers of people sorted by their names, so that the names can be searched easily.

Dictionary − The dictionary stores words in an alphabetical order so that searching of any word becomes easy.

In-place Sorting and Not-in-place Sorting

Sorting algorithms may require some extra space for comparison and temporary storage of few data elements. These algorithms do not require any extra space and sorting is said to happen in-place, or for example, within the array itself. This is called in-place sorting. Bubble sort is an example of in-place sorting.

However, in some sorting algorithms, the program requires space which is more than or equal to the elements being sorted. Sorting which uses equal or more space is called not-in-place sorting. Merge-sort is an example of not-in-place sorting.

Stable and Not Stable Sorting

If a sorting algorithm, after sorting the contents, does not change the sequence of similar content in which they appear, it is called stable sorting.

dfdfdfes


If a sorting algorithm, after sorting the contents, changes the sequence of similar content in which they appear, it is called unstable sorting.


asaa


Stability of an algorithm matters when we wish to maintain the sequence of original elements, like in a tuple for example.

Adaptive and Non-Adaptive Sorting Algorithm


A sorting algorithm is said to be adaptive, if it takes advantage of already 'sorted' elements in the list that is to be sorted. That is, while sorting if the source list has some element already sorted, adaptive algorithms will take this into account and will try not to re-order them.

A non-adaptive algorithm is one which does not take into account the elements which are already sorted. They try to force every single element to be re-ordered to confirm their sortedness.

Important Terms

Some terms are generally coined while discussing sorting techniques, here is a brief introduction to them −

Increasing Order

A sequence of values is said to be in increasing order, if the successive element is greater than the previous one. For example, 1, 3, 4, 6, 8, 9 are in increasing order, as every next element is greater than the previous element.

Decreasing Order

A sequence of values is said to be in decreasing order, if the successive element is less than the current one. For example, 9, 8, 6, 4, 3, 1 are in decreasing order, as every next element is less than the previous element.

Non-Increasing Order

A sequence of values is said to be in non-increasing order, if the successive element is less than or equal to its previous element in the sequence. This order occurs when the sequence contains duplicate values. For example, 9, 8, 6, 3, 3, 1 are in non-increasing order, as every next element is less than or equal to (in case of 3) but not greater than any previous element.

Non-Decreasing Order

A sequence of values is said to be in non-decreasing order, if the successive element is greater than or equal to its previous element in the sequence. This order occurs when the sequence contains duplicate values. For example, 1, 3, 3, 6, 8, 9 are in non-decreasing order, as every next element is greater than or equal to (in case of 3) but not less than the previous one.


ppp


Share:

0 comments