Concepts clustering applicatifs Serveur d Applications : J2EE Server -Sun Glassfish Francesco Termine, professeur HES, francesco.termine@he-arc.ch Francesco Termine HEG-ARC Filière d Informatique de gestion 1
Concepts de clustering applicatifs PLAN Présentation Sun GlassFish Clustering J2EE J2EE Glassfish Server Clustering Modèle d exécution utilisé par Sun Glassfish Mise en œuvre Francesco Termine HEG-ARC Filière d Informatique de gestion 2
Présentation Sun GlassFish Introduction GlassFish est le nom du serveur d'applications Open Source Java EE 5 et qui sert de fondation au produit Sun Java System Application Server de Sun Microsystems. Sa partie Toplink persistence [2] provient d'oracle. C'est la réponse aux développeurs Java désireux d'accéder aux sources et de contribuer au développement des serveurs d'applications de nouvelle génération de Sun. GlassFish est sous double licence CDDL et GPLv2 et il est certifié Java EE 5 (EJB3 + JPA + JSF + JAX-WS 2.x +...). Francesco Termine HEG-ARC Filière d Informatique de gestion 3
Présentation Sun GlassFish Historique Le projet est né en juin 2005 de l'ouverture de Sun Application Server 8. La version GlassFish v1.0 date de mai 2006 et la 2.0 (ajout des fonctions de haute-dispo/clustering et support de Web Services avancés) date du 17 septembre 2007. Cette version apporte également une performance accrue (benchmark SPECjAppServer) par rapport aux leaders traditionnels que sont BEA WebLogic (en) et WebSphere. La version 3.0 suivra après avec un découpage modulaire et des temps de démarrage de quelques secondes seulement. La version finale est prévue pour 2009 en même temps que Java EE 6. Francesco Termine HEG-ARC Filière d Informatique de gestion 4
Présentation Sun GlassFish Java EE Au niveau des standards, GlassFish est une implémentation complète de la norme Java EE 5 qui recouvre : EJB 3 (approche POJO, configuration par annotations, injection de dépendance) ; JPA (Java Persistence API) : standard implémenté par TopLink (par défaut dans GlassFish), Hibernate ou OpenJPA ; JAX-WS 2.x : nouvelle pile pour les services web ; JAXB 2.0 : mise en correspondance (mapping) XML/Java utilisée par JAX-WS 2.0 ; JSF (Java Server Faces) - framework MVC StAX - parseur de streaming XML ; JSP 2.1 & Servlet 2.5 : pour faire de l'injection de dépendance dans le conteneur web. Francesco Termine HEG-ARC Filière d Informatique de gestion 5
Présentation Sun GlassFish Implémentation Oracle contribue à la partie JPA sous la forme de TopLink Essentials publié en open source dans le projet GlassFish. Il s'agit de la dernière version du produit. La spécification JPA permet de remplacer à volonté les implémentations ; JBoss utilisera JSF et JAXB issus de GlassFish dans sa prochaine version et propose le support de Metro/JAX-WS issu de GlassFish ; BEA Weblogic 10 utilise JAX-WS ; Oracle utilise également des technologies issues de GlassFish ; Jetty a adopté Grizzly et le compilateur JSP de GlassFish ; La société TmaxSoft revend une distribution GlassFish sous le nom de JEUS 6.0 ; Des contributeurs individuels proviennent du monde entier et en particulier de France ; Ericsson a annoncé en mai 2007 la contribution de sa technologie Session Initiation Protocol au projet GlassFish (projet SailFin). Francesco Termine HEG-ARC Filière d Informatique de gestion 6
Clustering J2EE But du clustering Scalability In some large-scale systems, it is hard to predict the number and behavior of end users. Scalability refers to a system s ability to support fast increasing numbers of users. The intuitive way to scale up the number of concurrent sessions handled by a server is to add resources (memory, CPU or hard disk) to it. Clustering is an alternative way to resolve the scalability issue. It allows a group of servers to share the heavy tasks, and operate as a single server logically. High Availability The single-server s solution (add memory and CPU) to scalability is not a robust one because of its single point of failure. Those mission-critical applications such as banking and billing cannot tolerate service outage even for one single minute. It is required that those services are accessible with reasonable/predictable response times at any time. Clustering is a solution to achieve this kind of high availability by providing redundant servers in the cluster in case one server fails to provide service. Load balancing Load balancing is one of the key technologies behind clustering, which is a way to obtain high availability and better performance by dispatching incoming requests to different servers. A load balancer can be anything from a simple Servlet or Plug-in (a Linux box using ipchains to do the work, for example), to expensive hardware with an SSL accelerator embedded in it. In addition to dispatching requests, a load balancer should perform some other important tasks such as session stickiness to have a user session live entirely on one server and health check (or heartbeat ) to prevent dispatching requests to a failing server. Sometimes the load balancer will participant in the Failover process, which will be mentioned later. Fault Tolerance Highly available data is not necessarily strictly correct data. In a J2EE cluster, when a server instance fails, the service is still available, because new requests can be handled by other redundant server instances in the cluster. But the requests which are in processing in the failed server when the server is failing may not get the correct data, whereas a fault tolerant service always guarantees strictly correct behavior despite a certain number of faults. Failover Failover is another key technology behind clustering to achieve fault tolerance. By choosing another node in the cluster, the process will continue when the original node fails. Failing over to another node can be coded explicitly or performed automatically by the underlying platform which transparently reroutes communication to another server. Idempotent methods Pronounced i-dim-po-tent, these are methods that can be called repeatedly with the same arguments and achieve the same results. These methods shouldn t impact the state of the system and can be called repeatedly without worry of altering the system. For example, getusername() method is an idempotent one, while deletefile() method isn t. Idempotency is an important concept when discussing HTTP Session failover and EJB failover. Francesco Termine HEG-ARC Filière d Informatique de gestion 7
Clustering J2EE Load Balancing & Failover src: http://www.theserverside.com/tt/articles/article.tss?l=j2eeclustering Francesco Termine HEG-ARC Filière d Informatique de gestion 8
Clustering J2EE Application J2EE Web tier clustering implementation Clustering in the Web tier is the most important and fundamental function in J2EE clustering. Web clustering technique includes: Web load balancing and HTTPSession failover. src: http://java.sun.com/j2ee/1.3/docs/tutorial/doc/images/fig55.gif Francesco Termine HEG-ARC Filière d Informatique de gestion 9
Clustering J2EE HTTPSession Failover Memory replication approach Backup Session State to a Database http://www.theserverside.com/tt/articles/article.tss?l=j2eeclustering Francesco Termine HEG-ARC Filière d Informatique de gestion 10
J2EE GlassFish Server Clustering GlassFish clustering architecture from a runtime-centric viewpoint. Src: http://developers.sun.com/appserver/reference/techart/glassfishcluste Francesco Termine HEG-ARC Filière d Informatique de gestion 11
J2EE GlassFish Server Clustering Architecture typique du clustering sur GlassFish Src: http://developers.sun.com/appserver/reference/techart/glassfishcluste Francesco Termine HEG-ARC Filière d Informatique de gestion 12
J2EE GlassFish Server Clustering Architecture typique avec Load Balancer Src: http://developers.sun.com/appserver/reference/techart/glassfishcluste Francesco Termine HEG-ARC Filière d Informatique de gestion 13
J2EE & RAC JDBC J2EE & RAC Oracle RAC jdbc:oracle:thin:@(description=(load_balance=on) (ADDRESS=(PROTOCOL=TCP)(HOST=host1) (PORT=1521)) (ADDRESS=(PROTOCOL=TCP)(HOST=host2) (PORT=1521)) (CONNECT_DATA=(SERVICE_NAME=service) (FAILOVER_MODE = (TYPE = SELECT) (METHOD = BASIC) (RETRIES = 180) (DELAY = 5) ))) Francesco Termine HEG-ARC Filière d Informatique de gestion 14
Infrastructure complète Eviter les SPOF (Single Point of Failure) Dupliquer les LB! Francesco Termine HEG-ARC Filière d Informatique de gestion 15