GlassFish in Production Environments


Published on

Get to know GlassFish Community, the differences between Oracle GlassFish Server, and also all the capabilities for Management, Administrative tasks, Monitoring, Tuning and Configuration for Production Environments of all your Java EE applications

Published in: Technology
1 Comment
No Downloads
Total Views
On Slideshare
From Embeds
Number of Embeds
Embeds 0
No embeds

No notes for slide
  • Let’s begin by talking about what’s new in Java EE 7, and as a result, are also available in GlassFish 4.0
  • Java EE has gone through many releases, starting back in 1998. The early releases focused on building out the platform to meet the needs of the industry as the web gained rapid adoption. As a result of this rapid growth and the focus on features, J2EE (as it was called up to J2EE 1.4) became a difficult platform for developers to develop to. In fact, this spawned some open source projects like JPA and Spring that addressed developer ease-of-use.Of course, ease-of-use is relative, and beginning with Java EE 5 in 2005, Java EE moved ease of use and developer productivity to the forefront, and remain release themes for Java EE 7 today! Unlike some frameworks, Java EE 5 adopted “convention of configuration” and “annotated object” as the primary approach to developing server-side applications. Java EE 6 added the Web Profile, which is a subset of the full platform targeted at Web applications. Because many of the enterprise connectivity features are not in the Web Profile, it is simpler to pick up and learn, is more lean, and has even helped to grow the Java EE ecosystem with new vendors supporting only the Web Profile.Java EE 7, which we’ll talk about in detail, continues to focus on developer productivity, and emphasizes HTML5 development.
  • Java EE 7 has three main themes. First and foremost, it lays the foundation for HTML5 development. WebSockets offer low-latency, bi-directional data exchange that enable highly dynamic data exchange between browser and rich clients, and the server. Servlets gained asynchronous support in Java EE 6, enabling more scalable applications because more requests could be handled concurrently. Servlet 3.1 NIO (Non-blocking I/O) adds additional scalability through an event-driven API that enables the server to read data from a client as it becomes available and avoid blocking. This is useful, for example, when clients have low-bandwidth connections, and we don’t want the server to have to wait for all the data to be read. Like Servlet 3.0 in Java EE 6, JAX-RS 2.0 in Java EE 7 adds asynchronous support, enabling more scalable RESTful applications. Java EE 7 also adds a JSON Processing API for portable data exchange. This enables JSON objects to be read and written when communicating with Java and non-Java clients. This API offers both streaming and Document Object Model APIs, similar to JAX-WS and JAX-B for XML.Java EE makes developing HTML5-enabled and enterprise applications more productive than ever. Java EE 7 introduces new annotated Plain-Old-Java-Objects, or POJOs, simplifying application development even further. For example, a beans.xml file is no longer required to use dependency injection, and transactions are supported in virtually any POJO by simply using the @Transactional annotation. Developers write less boilerplate code with a much simpler JMS API. What used to take 18 lines of code to send a message now only requires a single line of code. The platform also adds default resources, where developers can depend on a resource being pre-configured for deployed applications. Last, the platform is highly integrated. For example, the Bean Validation API enables developers to define constraints on values, like “a string can not be null and must be less than 20 characters”. The Bean Validation API can now apply to JAX-RS resource parameters, and on POJO method parameter and return value.The third area of focus for Java EE 7 is meeting enterprise demands. Two new features are Batch and Concurrency Utilities APIs. The Batch feature is a rich API that enables developers to define batch that can be non-interactive, bulk-oriented and are long-running tasks that are computationally intensive, can execute sequentially or parallel, and may be initiated ad hoc or through scheduling. Batch processing also effectively utilizes computing resources by shifting processing times to when resources are typically idle. The Java EE platform is a managed environment that frowns on developers spawning their own non-managed threads to improve application scalability. The Concurrency Utilities for Java EE APIs enable developers to define and prioritize tasks that can be run in a dedicated thread pool, improving application scalability.
  • While Oracle is the steward of Java EE and leads the specification, Java EE is truly a community effort. Many organizations, individuals, and even Java User Groups are involved in the definition of Java EE. Some organizations and industry experts define the features, many others provide feedback throughout the process, and even create applications to test the proposed APIs and reference implementation that offer feedback. Of course, we encourage the involvement of everyone we talk to to become involved in the definition of the platform.
  • While GlassFish Server is the reference implementation, it is developing in open source.
  • The benefit of being developed in open source is the feedback and contributions of a vibrant developer community. GlassFish Server, for a period of time, is the only Java EE 7 implementation available until other implementations are able to pass the compatibility test suite. Developers that want to learn the latest APIs flock to GlassFish to learn the latest and greatest features of the Java EE platform. Developers also like GlassFish because it is modular, lightweight, and starts in seconds. Because of this, most developers use the full Java EE 7 platform builds, although some do use the Web Profile builds as well. Organizations often take their applications developed on GlassFish into production.
  • GlassFish server is extremely popular, with over ten million annual downloads. Students learn Java EE on GlassFish, and rofessionaldeveloperswant write applications using the latest standards and features. There is also a community of developers that are involved in FishCAT, the program that helps improve the quality of GlassFish. Developers test new features and read the documentation, looking for bugs in either case. Bugs found using FishCAT are prioritized over other bug fixes, which encourages more participation. The mailing lists are very active with participation from the product team, individuals, and organizations. The community also contributes features. For example, Serli, a company in France, has contributed application versioning feature, which we’ll discuss shortly.
  • While GlassFish Server is a great development platform, it is also used in many production environments. One reason are the “production” features that GlassFish Server offers. For example, GlassFish includes the ability to provision instances to remote hosts using SSH or DCOM. Clusters can be created securely without logging into a remote server to install software – just let GlassFish do it for you. GlassFish can manage the lifecycle of clusters and instances, by creating, start, stopping, and removing them. Instances and clusters can also share a common configuration or each can have their own. The configurations are all managed centrally. Resources like database and JMS connections are also managed from a central location, Last, applications can be deployed, enable, disable, and removed in a centralized manner.
  • GlassFish Server has three administration channels that offer feature rich administration features. From the web console, administrators can manage the lifecycle of instances, clusters, and applications. They can define resources, and upgrade GlassFish itself. Whatever can be done through the administration console can also be done through the command line, so admins can create shell scripts for complete automation. Anything that can be done through the web console and CLI can also be done using the RESTful API, so developers can programmatically control GlassFish as well.
  • At the center of the GlassFish Server architecture is the Domain Administration Server, or DAS for short. It is used to manage multiple configurations, applications, clusters, and instances. [LEFT] Developers and administrators interact with the DAS using the administration console, their favorite IDE, the “asadmin” command line tool, or RESTful API. Interaction occurs over HTTP or by using GlassFish APIs (such as the embedded API).[RIGHT] The DAS interacts with remote clusters using ssh and/or http. SSH can be used to manage the lifecycle of clusters and standalone instances (create, start, stop, destroy).Existing GlassFish Server 2.x users will notice that we have replaced the node agent architecture by leveraging the use of SSH. Note that SSH is actually optional, so instance lifecycle management can be done by logging in to a remote server and manually creating/start/stopping/destroying instances.
  • GlassFish Server manages 100 instances per domain, and these can be broken into 100 standalone instances, 50 2-node clusters, and up to 10 10-node clusters. Instances can be added or removed to a cluster at runtime. JMS brokers, based on OpenMQ, can be clustered as well, with persistent messages being stored on the filesystem or in a database. Oracle GlassFish Server, the commercial offering from Oracle, includes a load-balancer plugin. However, Oracle also tests mod_jk and mod_proxy, or basically the AJP protocol, as an open source option.
  • Application Versioning is a feature that is was contributed by Serli, a consulting company out of France. Application versioning allows for multiple versions of an application to be deployed simultaneously, although only one can be active at a time. This provides the ability to quickly and easily roll forward and backwards as required to meet business needs.
  • GlassFish Server is a modular application server build on an OSGi runtime.<CLICK> When you first start Glassfish, only a few modules are loaded. This is why GlassFish server starts in seconds.<CLICK> When an application is deployed, only the modules required to service running applications are loaded, minimizing resource utilization.<CLICK> When running applications, some additional modules will be loaded to support clustering, or when the web console is used, for example
  • GlassFish Server 4.0 is built on an OSGi runtime, and ships Apache Felix by default, although we do test with other OSGi implementations as well. GlassFish has roughly 275 modules. Developers can manage OSGI modules using Apache Felix OSGi tools or through the Felix Web console that integrates with the GlassFish console. Oracle does not formally support managing GlassFish modules in this manner, but OSGi developers can use it to manage their modules.GlassFish also supports “hybrid” applications, where OSGi resources can be injected into Java EE applications, and EJBs can be looked up from an OSGi bundle as if they were OSGi services.Because GlassFish runs on a generic OSGi runtime, any OSGi bundle can be deployed to the GlassFish runtime.OSGi also suports OSGi Enterprise, which is a way of making Java EE services like JDBC, JPA, and Web Applications.
  • GlassFish Server is also extensible. Developers can create new OSGi-based services and run them in GlassFish. Developers can then create administrative commands that integrate with the GlassFish infrastructure and be exposed through the console, CLI, or RESTful interface.GlassFish also includes an embedded API, so GlassFish can be embedded into an existing JVM to integrate with an existing application, or can be used in Unit testing environments.ISVs can also re-brand the user interface to offer a custom look and feel such as color themes, logo, etc.
  • GlassFish offers fast application deployment and redeployment. Applications can be deployed and redeployed to a live instance by dropping a war file into an auto-deploy directory, or by using a scattered archive in an exploded manner, like when using popular IDEs and their directory structures.GlassFish can be started using the asadmin CLI tool, or by simply running java –jar. The application server is quite flexible. Developers can also use the GlassFish maven plugin to start GlassFish, deploy applications, etc, which is very useful for testing in a continuous integration environment.
  • Developers love to use ActiveRedeploy, which is a feature that maintains the state of HTTP and EJB sessions across redeployments. Using NetBeans or Eclipse, developers can edit a file. Save it, and simply refresh the browser page. The IDE with the GlassFish plugin will compile the code and automatically redeploy the application. Imaging writing a shopping cart-like application where the contents of the cart do not change across redeployments. Developers can focus on writing business logic and not have to re-fill the cart just to test a new piece of code.
  • NetBeans 7.3.1 offers the strongest Java EE 7 features and GlassFish integration. NetBeans actually bundles GlassFish 4.0. In addition to active redeploy, it offers complete Java EE 7 support, with wizards that generate the outline of a POJO and the developer can customize it as needed. There are also some advanced wizards that actually generate RESTful endpoints from a JPA entity, one a wizard that generates a JSF CRUD interface to database tables.
  • While GlassFish is the reference implementation and is built in open source, Oracle also offers Oracle GlassFish Server as a commercially supported product.
  • GlassFish Pluginsupports 3.x, except 3.1.2
  • GlassFish in Production Environments

    1. 1. Copyright © 2012, Oracle and/or its affiliates. All rights reserved.1 GlassFish in Production Environments Bruno Borges Principal Product Manager Java Evangelist
    2. 2. Copyright © 2012, Oracle and/or its affiliates. All rights reserved.2 The following is intended to outline our general product direction. It is intended for information purposes only, and may not be incorporated into any contract. It is not a commitment to deliver any material, code, or functionality, and should not be relied upon in making purchasing decisions. The development, release, and timing of any features or functionality described for Oracle’s products remains at the sole discretion of Oracle.
    3. 3. Copyright © 2012, Oracle and/or its affiliates. All rights reserved.3 Open Source Project Commercial Product GlassFish Server Reference Implementation Glass Fish
    4. 4. Copyright © 2012, Oracle and/or its affiliates. All rights reserved.4 GlassFish Server Reference Implementation
    5. 5. Copyright © 2012, Oracle and/or its affiliates. All rights reserved.5 Java EE – And GlassFish - Journey Java EE 7 2005-2012 Ease of Development Lightweight Developer Productivity & HTML5 1998-2004 Enterprise Java Platform Robustness Web Services 2013 - Future
    6. 6. Copyright © 2012, Oracle and/or its affiliates. All rights reserved.6 Java EE 7 ThemesJava EE 7 Themes DEVELOPER PRODUCTIVITY MEETING ENTERPRISE DEMANDS Java EE 7  Batch  Concurrency  Simplified JMS  More annotated POJOs  Less boilerplate code  Cohesive integrated platform  WebSockets  JSON  Servlet 3.1 NIO  REST
    7. 7. Copyright © 2012, Oracle and/or its affiliates. All rights reserved.7 Java EE 7 Community Momentum ACTIVEPROJECTS 26 Active and transparent mailing lists JSRsADOPTED 22 JUGs 19 Adopt a JSR PROMOTEDBUILDS 89 GlassFish YOU 187 COMPANIES 32 EXPERTS SPECLEADS 16 ACTIVEJSRs 14
    8. 8. Copyright © 2012, Oracle and/or its affiliates. All rights reserved.8 GlassFish Server Open Source Project
    9. 9. Copyright © 2012, Oracle and/or its affiliates. All rights reserved.9 GlassFish Server  Built in open source  World’s first Java EE 7 Application Server  Lightweight / modular / easy to use  Production ready Open Source Project
    10. 10. Copyright © 2012, Oracle and/or its affiliates. All rights reserved.10 The GlassFish Community  10+ million annual downloads  FishCAT - Early testing and fixes  Active user forums  Community contributions
    11. 11. Copyright © 2012, Oracle and/or its affiliates. All rights reserved.11 Centralized management  Integrated GlassFish Server Provisioning  Manage instance/cluster lifecycle  Manage configurations  Manage Java EE resources  Manage application lifecycle
    12. 12. Copyright © 2012, Oracle and/or its affiliates. All rights reserved.12 Flexible Administration Web Browser REST API Command Line
    13. 13. Copyright © 2012, Oracle and/or its affiliates. All rights reserved.13 GlassFish Server Administration Architecture Cluster 1 Domain Administration Server (DAS) instance4 ssh / dcom / http http Repository instance2 instance3 instance1 REST JSON XML
    14. 14. Copyright © 2012, Oracle and/or its affiliates. All rights reserved.14 GlassFish Server Clustering  Manage 100 instances per domain – Standalone – Clusters (max 10 per cluster)  Dynamically resize cluster  JMS Broker Clustering  Load Balancing – Commercial plugin – AJP (mod_jk, mod_proxy)
    15. 15. Copyright © 2012, Oracle and/or its affiliates. All rights reserved.15 Application Versioning  Deploy multiple versions application versions  Activate any version  For example: – Roll forward and backwards between versions – Pre-deploy application for later activation – Enable new version at specific time of day
    16. 16. Copyright © 2012, Oracle and/or its affiliates. All rights reserved.16 GlassFish Modularity  Starts in seconds  Only loads required modules  Including “infrastructure” features In a nutshell OSGi EJB Servlet 274 JPA … JMS Broker app1.war CDI CDI REST WebSocket Bean Validation Clustering Console HTTP app2.ear
    17. 17. Copyright © 2012, Oracle and/or its affiliates. All rights reserved.17 OSGi Support  OSGi Runtime (Apache Felix) – Also runs on others – Ships with ~275 modules – Integrates OSGi management tools  Hybrid Java EE / OSGi Applications – Expose EJBs as OSGi Services – Inject OSGi services into Java EE applications  Run any OSGi bundle  Supports OSGi Enterprise
    18. 18. Copyright © 2012, Oracle and/or its affiliates. All rights reserved.18 Extending GlassFish Server  Define a new container – System-level logic – Implement administration commands  Expose administration capabilities – Administration Console – Command Line – RESTful Interface  Embeddable API  Re-brand user interface
    19. 19. Copyright © 2012, Oracle and/or its affiliates. All rights reserved.19 Built-in Developer Features  Ultra-fast deployment – Hot deployment – Directory deployment – Auto-deploy directory  Run as a single JAR java –jar glassfish.jar app1.war  Maven Plugin mvn gf:run, gf:start, gf:deploy
    20. 20. Copyright © 2012, Oracle and/or its affiliates. All rights reserved.20 Active Redeploy  Maintains state across redeploys  Rapid Iterative development – Edit – Save – Refresh 1) Edit 2) Save 3) Refresh
    21. 21. Copyright © 2012, Oracle and/or its affiliates. All rights reserved.21 NetBeans 7.3.1 + GlassFish 4.0  NetBeans bundles GlassFish  Incremental compilation; auto-deploy  Complete Java EE 7 support – All Java EE 7 project types – Maven Support – Wizards – Advanced Wizards  Entity to REST generation  Database to JSF 2.2
    22. 22. Copyright © 2012, Oracle and/or its affiliates. All rights reserved.22 Oracle GlassFish Server Commercial Product
    23. 23. Copyright © 2012, Oracle and/or its affiliates. All rights reserved.23 Oracle GlassFish Server  Commercial Distribution of GlassFish Server Open Source Edition  GlassFish Server Control  Java SE support  24 x 7 x 365 premium support  Regular patch releases  Indemnification Java EE 6 Compliant
    24. 24. Copyright © 2012, Oracle and/or its affiliates. All rights reserved.24 Oracle Enterprise Manager 12c  Features – Discovery  Applications not discovered – OOTB Monitoring (live, historical) – Event Monitoring – Configuration management – Process controle (live, schduled)  EM FMW Plugin  GlassFish Open Source and Commercial versions GlassFish Plugin
    25. 25. Copyright © 2012, Oracle and/or its affiliates. All rights reserved.25 GlassFish Server Control Performance TunerDAS Backup & Recovery Monitoring Scripting Client ActiveCache for GlassFish Oracle Access Manager Integration Load Balancer Plugin & Installer
    26. 26. Copyright © 2012, Oracle and/or its affiliates. All rights reserved.26 TUNING FOR PRODUCTION ENVIRONMENTS
    27. 27. Copyright © 2012, Oracle and/or its affiliates. All rights reserved.27 Quick Start and Overview  Download from – ZIP and native installers (Mac, Linux, Windows) – Download Size  Smallest at 37Mb for English Web Profile  Biggest at 114Mb for Multilingual Full Profile  Install (requires JDK 7) – Execute native installer or uncompress ZIP file  Run – $ cd glassfish4 – $ ./bin/asadmin start-domain Download, Install, Run
    28. 28. Copyright © 2012, Oracle and/or its affiliates. All rights reserved.28
    29. 29. Copyright © 2012, Oracle and/or its affiliates. All rights reserved.29 Default configurations  GlassFish comes by default best configured for development environments – Default security configurations OTOH come pre-configured – A default GF domain does not enables remote access for admin  Best for hot deployment  Great for integrating and using from within IDEs Development purpose
    30. 30. Copyright © 2012, Oracle and/or its affiliates. All rights reserved.30 Basic stuff: JVM options  A production domain will need more memory, and other fine tuned options – Edit <java-config> inside domain.xml manually, or – Edit through Admin CLI or Web UI  JVM Options -Xms and -Xmx to same value (at least 2GB) -XX:MaxPermSize and -XX:MinPermSize to same value (at least 256mb) More memory for production environments
    31. 31. Copyright © 2012, Oracle and/or its affiliates. All rights reserved.31 Garbage Collector and Heaps  There are several options, but G1 is available for a while and you should consider it. Analyse, compare, and decide  Enable -verboce:gc  Enable -XX:+PrintGCDetails  Inform -Xloggc:/tmp/my_glassfish_vm_gc.log  Make sure devs can’t freeze your VM by enabling – XX:+DisableExplicitGC  Enable heap dump for when you get OOME Analyse and consider G1 from HotSpot 7
    32. 32. Copyright © 2012, Oracle and/or its affiliates. All rights reserved.32 Disabling Developer Features  Disable auto-deploy and dynamic application reload  Disable JSP check for modified date  Enable cache of characters in Strings – Edit domain1/config/default-web.xml – genStrAsCharArray=true – ** this might bring encoding issues Because this is a production environment
    33. 33. Copyright © 2012, Oracle and/or its affiliates. All rights reserved.33 Request and Acceptor Threads  Define Acceptor Threads to a number similar to the number of Cores in your CPU  Increase the number of threads for the HTTP Listener, to as much as your CPU can handle simultaneously  Set min and max threads pool size to same value Handling more than <several> users at the same time
    34. 34. Copyright © 2012, Oracle and/or its affiliates. All rights reserved.34 LOGGING  Always disable: Unnecessary logging
    35. 35. Copyright © 2012, Oracle and/or its affiliates. All rights reserved.35 Monitor, tune, monitor, tune  Always monitor  Keep tuning  Tools – jmap / jps, jstat, jconsole
    36. 36. Copyright © 2012, Oracle and/or its affiliates. All rights reserved.36 CUSTOMER STORIES
    37. 37. Copyright © 2012, Oracle and/or its affiliates. All rights reserved.37 Customers using GlassFish in Production  Jelastic was the first cloud to provide GlassFish 4.0 with Java EE 7  Pense Imóveis, real estate buyer/seller network  Guia da Semana, enterteinment/schedule website   CloudBees first to ofer Java EE 7 (Using GlassFish) Besides Jelastic
    38. 38. Copyright © 2012, Oracle and/or its affiliates. All rights reserved.38 ROADMAP
    39. 39. Copyright © 2012, Oracle and/or its affiliates. All rights reserved.39 GlassFish Server 4.x 2013 2014 GlassFish Server 4.0 • Java EE 7 • Open Source Edition • Clustering (early access) GlassFish Server 4.0.1 • Bug Fixes GlassFish Server 4.1 • Clustering • Improve modularization • GlassFish Server Control • Oracle GlassFish Server • Bug fixes Major Minor
    40. 40. Copyright © 2012, Oracle and/or its affiliates. All rights reserved.40 Future of Java EE JCACHE State Management Configuration HTML5 ++Cloud / PaaS JSON Binding Java EE 8 and Beyond NoSQL
    41. 41. Copyright © 2012, Oracle and/or its affiliates. All rights reserved.41
    1. A particular slide catching your eye?

      Clipping is a handy way to collect important slides you want to go back to later.