scalable highly available distributed system with jboss/wildfly

44
SCALABLE HIGHLY AVAILABLE DISTRIBUTED SYSTEM WITH JBOSS Author Evgeniy Khist

Upload: yevhen-khyst

Post on 23-Jan-2015

828 views

Category:

Software


0 download

DESCRIPTION

JBoss Enterprise Application Platform and Wildfly are flexible and mature platforms with excited features like small memory footprint and lightning fast startup times. Learn how JBoss can help to build distributed system and achieve scalability and high availability independently of application frameworks and datastores. http://slides-evgeniykhist.rhcloud.com/scalable-highly-available-distributed-system-with-jboss/ http://developer-should-know.tumblr.com/

TRANSCRIPT

Page 1: Scalable Highly Available Distributed System with JBoss/WildFly

SCALABLE HIGHLYAVAILABLE DISTRIBUTED

SYSTEM WITH JBOSSAuthor Evgeniy Khist

Page 2: Scalable Highly Available Distributed System with JBoss/WildFly

SCALABLE HIGHLY AVAILABLE DISTRIBUTEDSYSTEM WITH JBOSS

JBoss Enterprise Application Platform and Wildfly are flexible andmature platforms with excited features like small memory

footprint and lightning fast startup times

Learn how JBoss can help to build distributed system andachieve scalability and high availability independently of

application frameworks and datastores

Page 3: Scalable Highly Available Distributed System with JBoss/WildFly

WHY DO WE NEED DISTRIBUTED SYSTEM?We can't guarantee that single server instance will be able tohandle growing amount of requests just updating hardware

Page 4: Scalable Highly Available Distributed System with JBoss/WildFly

WHAT IS DISTRIBUTED SYSTEM?A set of independent computers that can be viewed by its clients

as a single system

Page 5: Scalable Highly Available Distributed System with JBoss/WildFly

WHAT DO WE EXPECT FROM DISTRIBUTEDSYSTEMS?

Ability to handle growing amount of loadLittle effort required to increase capacityNo unplanned downtime

Page 6: Scalable Highly Available Distributed System with JBoss/WildFly

WHAT DIFFICULTIES DO DISTRIBUTEDSYSTEMS INTRODUCE?Multiple points of failureData consistency across the nodesComplexity of managing

Page 7: Scalable Highly Available Distributed System with JBoss/WildFly

DISTRIBUTED ARCHITECTUREDistributed system is heterogeneousDistributed system has multiple autonomous componentsComponent is a modular unit that can be used exclusively

Page 8: Scalable Highly Available Distributed System with JBoss/WildFly

DISTRIBUTED SYSTEM

Page 9: Scalable Highly Available Distributed System with JBoss/WildFly

APPLICATION INTEGRATION STYLESThere are four main approaches for integrating components of

distributed system

File transfer - application produces files of shared data forothers to consume, and consumes files that others haveproducedShared database - applications store the shared data in acommon databaseRPC (Remote Procedure Call) - application exposes some of itsprocedures so that they can be invoked remotely by otherapplications to run behavior and exchange dataMessaging - application is connected to a common messagingsystem, and exchange data and run behavior using messages

Page 10: Scalable Highly Available Distributed System with JBoss/WildFly

MESSAGINGMessaging is a method of communication between software

components or applications

Messaging enables distributed communication that is looselycoupled

Requires an extra component in the architecture, the messagebroker

Page 11: Scalable Highly Available Distributed System with JBoss/WildFly

MESSAGE BROKER

Page 12: Scalable Highly Available Distributed System with JBoss/WildFly

JMSJava Message Service is a Java API that allows applications to

create, send, receive, and read messages.

AsynchronousReliable - message is delivered once and onlyonce

Page 13: Scalable Highly Available Distributed System with JBoss/WildFly

MESSAGE QUEUEProducer puts message into the queue

Any available at this moment consumer capable of handling thismessage takes it from the queue

Page 14: Scalable Highly Available Distributed System with JBoss/WildFly

MESSAGE QUEUE

Page 15: Scalable Highly Available Distributed System with JBoss/WildFly

MESSAGE QUEUE

Page 16: Scalable Highly Available Distributed System with JBoss/WildFly

SCALABILITYScalability is the ability of a system to expand to handle a growing

amount of work

For example, ability of a system to scale to handle larger numberof users

Page 17: Scalable Highly Available Distributed System with JBoss/WildFly

TWO WAYS OF SCALING APPLICATIONSVertical Scalability - adding more resources within the sameapplication to increase capacity (adding CPUs to an existingserver, adding hard drive on an existing RAID storage)Horizontal Scalability - adding multiple application instancesand making them work as a single unit

Page 18: Scalable Highly Available Distributed System with JBoss/WildFly

HORIZONTAL SCALABILITYIs typically achieved using clustering and load balancing

Cluster is homogenous and consists of multiple instances ofdistributed system component

Typically each cluster node runs on its own server instance

Page 19: Scalable Highly Available Distributed System with JBoss/WildFly

HORIZONTAL SCALABILITY

Page 20: Scalable Highly Available Distributed System with JBoss/WildFly

HORIZONTAL SCALABILITY

Page 21: Scalable Highly Available Distributed System with JBoss/WildFly

HORIZONTAL SCALABILITY

Page 22: Scalable Highly Available Distributed System with JBoss/WildFly

MESSAGE BROKER CLUSTERING

Page 23: Scalable Highly Available Distributed System with JBoss/WildFly

FAULT-TOLERANCEFault-tolerance is ability of a system to continue operating

properly when some part of the system fails

Availability is the amount of time that a system is actuallyavailable relative to the amount of time it is expected to be

available

Fault-tolerant systems are typically based on the concept ofredundancy

Redundancy is the duplication of critical components of a systemfor increasing reliability of the system

Page 24: Scalable Highly Available Distributed System with JBoss/WildFly

STATELESSNESSStateless means no client context being stored on the server

between requests, but passed with each request

But stateless service can talk to other services maintaining stateof business objects

Page 25: Scalable Highly Available Distributed System with JBoss/WildFly

STATELESSNESSEasier to scaleReduces memory usageNo need for session data replication

Page 26: Scalable Highly Available Distributed System with JBoss/WildFly

ASYNCHRONOUS REQUEST PROCESSINGAsynchronous communication using JMS on back-end

Request can be in one of states: SUBMITED, IN_PROGRESS,

DONE, FAILED

Request can change from one state to another during processingby different modules

Page 27: Scalable Highly Available Distributed System with JBoss/WildFly

CONSISTENCYMessage consumption from one queue and sending to another

queue should be done in single transaction

If node fails after message consumption, but before sendingmessage to other destination, it will be returned to queue and can

be consumed again by any other node

Page 28: Scalable Highly Available Distributed System with JBoss/WildFly

CONSISTENCY

Page 29: Scalable Highly Available Distributed System with JBoss/WildFly

CONSISTENCYAlternatively, write-ahead transaction log (journal) can be used

In case of node failure transaction log can be replayed or otheractions can be taken

Page 30: Scalable Highly Available Distributed System with JBoss/WildFly

CONSISTENCY

Page 31: Scalable Highly Available Distributed System with JBoss/WildFly

ASYNCHRONOUS REQUEST PROCESSINGAJAX polling on front-end

After sending request to API request id will be sent in responseThis request id will be used for polling request statusLong-polling from async-servlets (Servlet 3.0) can be used forefficient pollingWhen status shows that request is completed, additionaldetails can be requested

Page 32: Scalable Highly Available Distributed System with JBoss/WildFly

SYNCHRONOUS JMS

Page 33: Scalable Highly Available Distributed System with JBoss/WildFly

JMS REQUEST-REPLY PATTERNJMS can be also used for synchronous communication

Using temporary queues for repliesTemporary queue address is sent in JMSReplyTo message property, so only sender knows about replyqueue

Using shared reply queue with message selectorFiltering by JMSCorrelationID, for example

Using exclusive reply queueNot cluster-safe until each node (even of the same module) has separate queue for replies

Page 34: Scalable Highly Available Distributed System with JBoss/WildFly

CONSISTENCYCalls to 3rd party services is often done by HTTP or other

protocol not supporting ACID transactions

Page 35: Scalable Highly Available Distributed System with JBoss/WildFly

HTTP CALLS TO THIRD-PARTY SERVICE

Page 36: Scalable Highly Available Distributed System with JBoss/WildFly

HTTP CALLS TO THIRD-PARTY SERVICE

Page 37: Scalable Highly Available Distributed System with JBoss/WildFly

CONSISTENCYTo solve this issue write-ahead transaction log (journal) can be used

Transaction log can be stored locally for each node

In case of node failure transaction log can be replayed

After failure node will request 3rd party service for transactionstatus and basing on response will repeat transaction

Page 38: Scalable Highly Available Distributed System with JBoss/WildFly

WRITE-AHEAD TRANSACTION LOG

Page 39: Scalable Highly Available Distributed System with JBoss/WildFly

WHY JBOSS?ClusteringDeployment APIDistributed caching (Infinispan)Distributed deploymentFailoverHibernate integrationRobust messaging subsystem (HornetQ)Load balancingManagement APILogging (SLF4J implementation)JBoss Modules

Page 40: Scalable Highly Available Distributed System with JBoss/WildFly

CONFIGURATION CONCEPTSstandalone.xml or domain.xml and host.xmlJBoss Web ConsoleJBoss Command Line Interface (CLI)

Page 41: Scalable Highly Available Distributed System with JBoss/WildFly

JBOSS MODULESJBoss Modules is a standalone implementation of a modular

(non-hierarchical) class loading and execution environment forJava. In other words, rather than a single class loader which loads

all JARs into a flat class path, each library becomes a modulewhich only links against the exact modules it depends on, and

nothing more. It implements a thread-safe, fast, and highlyconcurrent delegating class loader model, coupled to an

extensible module resolution system, which combine to form aunique, simple and powerful system for application execution

and distribution.

Page 42: Scalable Highly Available Distributed System with JBoss/WildFly

JBOSS MODULESUnlike OSGi, JBoss Modules does not implement a container;

rather, it is a thin bootstrap wrapper for executing an applicationin a modular environment.