1 / 41

JBoss Application Platform Assistance Version

JBoss Application Platform Assistance Version. 임형준 ( hyungjun25@cnu.ac.kr ) 충남대학교 컴퓨터공학과 데이터베이스시스템 연구실 2014년 10월 23일 목요일. 목차. JBoss Application Platform Review JBoss Enterprise Middleware System JGroup JBoss Cache Performance Decline Factors Clustering State Replication

Download Presentation

JBoss Application Platform Assistance Version

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.


Presentation Transcript

  1. JBoss Application PlatformAssistance Version 임형준(hyungjun25@cnu.ac.kr) 충남대학교 컴퓨터공학과 데이터베이스시스템 연구실 2014년 10월 23일 목요일

  2. 목차 • JBoss Application Platform Review • JBoss Enterprise Middleware System • JGroup • JBoss Cache • Performance Decline Factors • Clustering • State Replication • Load-balancing • Failover

  3. JBoss Enterprise Middleware System

  4. JEMS Architecture Java Applications (EARs, WARs, JARs, JSPs, Servlets) JBoss Portal --- J2EE 1.4 Services implemented as JMX Mbeans --- Services beyond J2EE JBoss Eclipse IDE Java Applications Management API JBoss Remoting* JBoss AOP* EJB (JBoss CMP) JAXR Persistence (Hibernate*) WS4EE (JBossWS) JTA (JBossJTA) JCA (JBossJCA) RMI-IIOP (jacORB) JAX-RPC SAAJ Deployment API Clustering JSP/Servlet (Tomcat*) JMS (JBoss MQ) JDBC JNDI (JBossNS) JAAS (JBossSX) JACC Caching (JBossCache*) JAXP Workflow (JBoss jBPM**) Custom Mbeans JBoss Application Server 4.x (JMX Microkernel : JBossMX) Java Virtual Machine (Sun JVM, BEA JRockit, IBM VM, etc.) Operating System (Windows, Unix = Linux, Solaris, AIX, etc.) Hardware (CPU + Storage + Memory) * Product can run inside JBoss AS or stand-alone ** Integration as MBean under development

  5. JGroup & JBoss Cache

  6. JGroups • Toolkit for reliable multicasting • Fragmentation • Message retransmission • Ordering • Group membership, membership change notification • LAN or WAN based • Like JMS • Receive a message • Retrieve membership • Disconnect from the group • Close the channel • Be notified when members join, leave (including crashes) Group topology

  7. JGroups (Layered) Architecture Protocol Stack View Pipe & Filter View Application Application Application Application send() receive() send() receive() Building Building Blocks Blocks Channel Channel Channel Channel GMS GMS UNICAST UNICAST NAKACK NAKACK FD FD UDP UDP Queue & Tread Network

  8. Flexible Protocol Stack & Code Sample • 2 threads per protocol • Can be optimized away, per protocol • down_thread="false", up_thread="false" • Cause the up() or down() to run on caller's thread • A protocol implements up() and/or down() methods • When done, pass message on: passUp(), passDown() methods • Tradeoff between performance/concurrency and context switching • Code Sample • public void JGroupsSample () { • JChannel channel = new JChannel("file://home/bela/default.xml"); • channel.connect("demo-group"); // join the group • System.out.println("members are: " + channel.getView().getMembers()); • Message msg = new Message(null, null, "Hello world"); • channel.send(msg); • Message m=(Message)channel.receive(0); • System.out.println("received msg from " + m.getSrc() + ": " + m.getObject()); • ch.disconnect(); // Leave from “demo-group“ • ch.close(); • }

  9. Advantages of Protocol Stacks • Each property is implemented by 1 protocol • Fragmentation, retransmission, ordering • Protocols are assembled into a stack • Stack has exactly the properties needed by the appl / required by the network • Can‘t get this with java.net.Socket, always comes with full TCP/IP • Small scope: a protocol does just one job, but does it well • Protocol stacks are fashionable: • Servlet 2.3 filters • Interceptors (Corba, JBoss) • AOP: separation of concerns, e.g. fragmentation should not be an application concern

  10. Available Protocols • Transport: UDP, TCP, TCP_NIO, TUNNEL, JMS, LOOPBACK • Discovery: PING, TCPPING, TCPGOSSIP, UDPPING • Group membership • Ordering: FIFO, CAUSAL, TOTAL, TOTAL_TOKEN • Security: ENCRYPT, SSL ConnectionTable (n/a) • Fragmentation: FRAG • Flow control: FLOW_CONTROL, FC • Misc: PIGGYBACK, COMPRESS • Reliable delivery & FIFO: NAKACK, SMACK, UNICAST • Failure detection: FD, FD_SOCK, FD_PID, FD_SIMPLE, FD_PROB, VERIFY_SUSPECT • State transfer: STATE_TRANSFER

  11. Group Membership • Group Membership • Maintain a list of members • Notify members when a new member joins, or an existing member leaves (or crashes) • Each member has the same ordered list • List can be retrieved by Channel.getView() • First (= oldest) member is coordinator • If coordinator crashes, 2nd oldest takes over • Actions • JOIN • LEAVE • Member sends LEAVE to coordinator • Coordinator multicasts new view to all members • CRASH • GMS multicasts new view (not containing crashed member) If (first member) { Coordinator adds new member to list, and multicasts new view (member list) to all members } else { sends JOIN to coordinator }

  12. JBoss Cache • A replicated, transactional, persistency and fine-grained cache system • Transactional or non-transactional • Non-Transactional • Replication after each modification • Transactional • Replication at TX commit • DB isolation levels supported • Support for pluggable TxManagers

  13. JBoss Cache Module • Two modules • TreeCache • TreeCacheAOP • Uses JGroups as underlying transport stack

  14. a c d e f g h TreeCache Architecture • Tree structure • Each node has a name and zero or more children • Can be navigated recursively from node to node or using a fully qualified name (/a/d/g) : like xpath • Multiple roots per cache allowed • Each node is a map with keys and values • Locking • Isolation level per node • Drawback • Coarse grained Replication • replicate a big object even only a sub-field is dirty • Interface • Node put(FQN name, Object key, Object value) • Insert a (key, value) pair • Object get(FQN name, Object key) • Finds by key with node name • remove(FQN name, Object key)

  15. TreeCacheAOP • Subclass of TreeCache • POJO needs not be Serializable (but needs instrumentation) • Fine-grained field-level Pojo Cache • Object graph • Sub-object reference, Cross and multiple reference • Polymorphism • Inheritance • Use JBossAop’s Dynamic AOP feature • Eviction policy • Object management transparency • Once the object is put into cache, regular POJO field operation will trigger appropriate replication.(ex : a method call, field access, instance construction) It’s Kind Of AOP Magic • If under transaction, the POJO operation is transacted as well. • Automatic Collection class support • List, Map, and Set • A proxy is generated for the Collection. User operates on the proxy

  16. / name name Mary Joe Person p (key=/husband) name: „Joe“ Person p (key=/wife) addr name: „Mary“ 0 wife 2 addr husband hobbies 1 hobbies addr hobbies city: „ San Jose“ city San Jose zip 95123 zip: 95123 TreeCacheAop Mapping

  17. TreeCacheAOP is a JBoss AOP Product Person.java /** * @@org.jboss.aop.cache.AopMarker */ Public class Address { String tel; String street; int zip; … } AopMarker.java package org.jboss.cache.aop; // Annotation marker interface Public interface AopMakrer {} update Jboss-aop.xml <aop> <prepare expr="field(* $instanceof{org.jboss.cache.aop.AopMarker}->*)" /> </aop>

  18. TreeCacheAOP Interface & Configuration replySync-service.xml <server> <mbean code="org.jboss.cache.aop.TreeCacheAop" name="jboss.cache:service=TreeCacheAop"> ... <attribute name=“TransactionManagerLookupClass"> org.jboss.cache.transaction.JBossTransactionManagerLookup</attribute> <attribute name="IsolationLevel">REPEATABLE_READ</attribute> <attribute name="CacheMode">REPL_SYNC</attribute> ... Code TreeCacheAop cache = new TreeCacheAop(); PropertyConfigurator configurator = new PropertyConfigurator(); // Configuration via xml Configurator.config(cache, “META-INF/replSync-serivce.xml”); cache.start(); Person joe = new Person(“Joe Black”, 51); // Put object into cache management cache.putObject(“/person/joe”, joe); // Fine grained replication here. Only the age field is replicated! cache.getObject(“/person/joe”).setAge(61); // Remove it from the cache management cache.removeObject(“/person/joe”); assert(null == cache.findObject(“/person/joe”));

  19. Clustering

  20. Performance Decline Factors • 부하분산 (State Replication) • 동시 접속자 증가에 따른 성능저하 방지 • 요청을 서버들에 전달하여 고가용성 및 성능향상 • 상태복제 (Load Balancing) • 서비스 접근 시 응답속도의 항상성 유지 • 클러스터 내의 모든 노드들이 상태 접근가능 • 하나의 노드가 장애 시 다른 노드에서 클라이언트와 통신하여 서비스 제공 • 자동 장애복구 (Silent Failover) • 서비스 장애 시 정상적인 서비스 보장 • 시스템 장애 시 클라이언트는 다른 노드로 redirection

  21. Clustering • Highavailability enterprise services via JBoss Clusters • To run an application on several parallel servers (cluster nodes) while providing a single view to application clients • Clustering is crucial for • Scalable enterprise applications: improve performance by simply adding more nodes to the clusters • Highly available enterprise applications: support the redundancy

  22. JBoss Clustering Includes • Cluster • Set of nodes with a common goal - Homogeneous • Partition - Group of nodes • Not statically defined • Defined by a name • Node can join and leave as needed • Automatic cluster membership discovery • HA-Singleton • Only node is running at the same time in a cluster

  23. Clustering 구성 • On the same network, even for the same service, they may have different clusters (partition) Partition A Jboss Node 1 Jboss Node 2 Jboss Node 3 Partition B Partition C Jboss Node 4 Jboss Node 5 Jboss Node 1 Clusters and server nodes

  24. Clustering 방법 • 상태 복제 (State Replication)– 아래 항목에 대해 Synchronous & Asynchronous Replication 모드 지원 • HTTP Session • Stateful Session Bean • Entity Bean • Plain Old Java Bean (POJO) • 부하 분산 (Load Balancing) • HTTP Load-balancing via Apache Plug-in • EJB Load-balancing via Dynamic Proxy • Message-Driven Bean Load-balancing via Queue • 자동 장애 복구 (Silent Failover) • HTTP failover via Apache Plug-in • EJB failover via Dynamic Proxy

  25. Clustering Expression JBoss instance SFSB EJB 3 Fat Client Remoting Entity Bean JBossWeb POJO JBoss instance SFSB HTTP Thin Client Apache EJB 3 Entity Bean JBossWeb POJO

  26. Clustering 동작 • Farming Deployment • JBoss deployment scanner가 변경사항을 감지해서 클러스터의 각 노드에 자동으로 deploy • Dynamic Cluster Definition • 특정 노드 장애 발생시, 클러스터의 각 노드 및 클라이언트의 클러스터 정의에서 동적으로 해당 노드를 제거

  27. Farming Deployment • Hot-deploy • Any of the cluster members and the application will be automatically duplicated across all nodes in the same cluster by simply copying a file in a /farm folder

  28. Configuration File <?xml version="1.0" encoding="UTF-8"?> <server> <mbean code="org.jboss.ha.framework.server.FarmMemberService" name="jboss:service=FarmMember,partition=DefaultPartition"> ... <depends optional-attribute-name="ClusterPartition" proxy-type="attribute"> jboss:service=${jboss.partition.name:DefaultPartition} </depends> <attribute name="ScanPeriod">5000</attribute> <attribute name="URLs">farm/</attribute> ... </mbean> </server> farm-service.xml

  29. four five Dynamic Cluster Definition If any node fails, the cluster will identify the failure and remove that node from the cluster definition of every node and all client proxies. All nodes in a JBoss cluster are peers. There is no central director of the cluster, which eliminates any single point of failure. To add a node to the cluster simply duplicate a drive of an existing node, give the node a unique name/IP, and connect it to the network. Now all of the nodes in the cluster and all client proxies are aware of the new cluster member. Node five is now included in all state replication operations as well. one one two five three four Cluster Definition one two three four Cluster Definition one two three four five Cluster Definition two three four five

  30. 상태 복제 (State Replication)

  31. State Replication (1) • Fine-Grained State Replication • Object 변경 시 Object 전체가 아닌, field level의 변경 사항만을 복제 • Synchronous VS. Asynchronous • 상태 복제를 동기화할 경우, 노드 장애 시 항상 상태 정보를 최신으로 유지할 수 있으나 성능은 떨어짐 • 어느 정도의 상태 정보 손실이 발생해도 문제가 없다면 상태 정보 복제를 비동기화해서 성능을 개선 (동기화 주기 설정 가능)

  32. TreeCacheAOP SFSB Replications • After each invocation of a SFSB, if the bean changed, a message is broadcast to the cluster • The message contains the serialized state of the session bean • The broadcast operation is synchronous (blocking) with acknowledgements from all the nodes of the cluster 3. Notify to other node TreeCacheAOP 2. register 1. new 6. Notify to other node TreeCacheAOP 5. update 4. Update state SFSB Automatic TreeCacheAOPNotification

  33. Shopping Cart Line# QTY Product Description Unit Price 1 4 Coffee Beans (1lb) $6.59 2 4 Coffee Filters #4 $1.99 :::::: :::::: :::::::::::::::::::::::::::: :::::::: 25 Coffee Mugs $2.25 State Replication Across Cluster Now all nodes in the cluster are in sync with the updated state of the shopping cart. one two five three four Replicated Objects HttpSessions Stateful Session Beans HA-JNDI tree 1 0

  34. State Replication (2) • Buddy Replication & Data Gravitation for HTTP Session • 상태정보를 하나 이상의 buddy node (backup server)에만 복제 • HTTP 요청이 오면 해당 노드는 cluster에서 상태 정보를 복제 • Failover일 경우, HTTP 요청이 반드시 buddy node로 전달되지는 않음 • Sticky load-balancing (session affinity) 사용

  35. 부하분산 (Load-balancing)

  36. Load-balancer • HTTP-based services do not require the client to download anything • External load balancer is required to process all requests and dispatch them to server nodes in the cluster Jboss Node 1 Web Browser 1.1 1 Sessions Replications Load-balancer 1.2 1.3 Jboss Node 2

  37. Load-balancing • HTTP Load-balancing • Apache Plug-in (mod-jk) Load-balancing 정책 • Weight Round Robin • Lowest Session • Lowest Network Traffic • Lowest Current Load • EJB Load-balancing via Dynamic Proxy • EJB Stub (Proxy)에서 제어 • Load-balancing 정책 • Round Robin • First Available • First Available with identical all proxies • Message-Driven Bean Load-balancing via Queue

  38. 자동장애 복구 (Failover)

  39. Failover • HTTP failover • L4, Apache Plug-in (mod_jk)에서 제어 • 노드 장애 발생 시 다른 노드로 요청을 전달 • EJB failover • EJB Stub (Dynamic Proxy)에서제어 • 노드 장애 발생 시 다른 노드로 요청 • 모든 노드가 장애가 발생할 경우 Client에게 Exception 전달 • 장애가 발생한 노드는 Cluster에서 제외 • 변경된 Cluster 구성 정보는 EJB 응답 메시지에 추가되어 Stub으로 전달

  40. Intelligent Stub Client-Server Communication • The clients downloads an “intelligent” stub from the server and uses it to access the bean • The stub encapsulates the load balancing policy and the failover mechanism • JBoss provides load balance policies: • RoundRobin • FirstAvailable (Sticky Sessions) • FirstAvailableIdenticalAllProxies • The stubs maintains a list of server addresses which is updated on each request Client fault Node 1 RMI Dispatcher Invoke : Server Address List Node 2 : Server Address Reference

  41. Silent Failover via Dynamic Proxies Current Cluster Nodes one two three four Dynamic proxies are provided out-of-box in JBoss. The client application does not know or care that the server has failed-over. one two five Client Application Dynamic Proxy three four = replicated stateful object (e.g. Stateful Session Bean)

More Related