28 June 2012

RBS IT Failure - A Familiar Tale?


In the last few days the news has been full of stories about another high-profile IT failure, this time it is the consumer banking giant RBS, whose IT upgrade (provided by CA) did not go according to plan. A planned upgrade seems to have caused significant performance problems, making the system unable to cope with day-to-day load, leaving thousands of customers without access to their money, and unable to pay their bills. While the staff at the banks branches have apparently done the best they can, in a situation not of their making, it still leaves customers frustrated and understandably angry. This is the kind of IT failure that loses customers and can ultimately topple a business, but what went wrong?

Well I have no inside knowledge of these systems, but I would be willing to put good money on the fact that the events leading up to the failure followed a pattern familiar to C2B2 and our consultants. We have performed technical fault identification and resolution for a number of customers with similar high-profile IT failures, and while we can usually pinpoint a technical cause of the problem and identify a fix, the issue remains that the real underlying cause is one of process and management, rather than IT. The timescale to a modern IT project failure goes something like this:

An agile, feature driven methodology is chosen as the software development process, while this is not a problem in itself, insufficient weight is given to the delivery of non-functional requirements.
Six months before the project delivers, everything is looking good but the delivery of features is slightly behind schedule. No problems have been identified so far in the very limited performance testing done so far, so the decision is taken to re-allocate some of the testing time and budget to finishing the desired features.
Four weeks before the project delivers, ‘performance testing’ starts, running load against a cut-down version of the live environment. Tools like load-runner or JMeter are used to test the system, with a guess of what behaviours the users might exhibit, based on an old version of the site with less features and a fraction of the expected live volumes. Testing will focus on the “sunny day scenarios” when all hardware is working and an average number of users is doing “normal” stuff.
One week before the project delivers, ‘soak testing’ is performed by the developers, a small number of machines repeatedly hit the front page of the site for an hour, if the site doesn’t fall over then testing is considered to have passed.
The project delivers, users hit the site in large numbers using it in a way completely differently to how it was expected, the site stays up for a while, but after a few hours it slows down and fails.

The root cause of most IT failures we come across is a lack of proper performance testing with realistic user loads, and a lack of interpretation of the results when limited performance testing is performed. Throwing load at a system for one hour, with a binary outcome of “it fell over” or “it stayed up” tells you nothing about your system, you have no idea if it will fall over after 61 minutes or if it will stay up forever. Real testing needs to start early, use representative loads, and be performed for extended periods of time. Monitoring should be in place so that bottlenecks can be identified, and failure conditions can be extrapolated. When you come out of performance testing you should know what the weak points of your system are, what modes of failure it may demonstrate, and how it will behave with bursty traffic.

When you bet significant parts of your budget and reputations on a software release, skimping on the testing and focussing on “sunny day scenarios” may sometimes save you a bit of money, but when it fails it has the potential to cost far more in reputational damage than the IT system cost in the first place.

RBS are now facing a government enquiry into what went wrong, with the possibility of legislation forcing banks to disclose details of their IT systems and the causes of failures. I don’t imagine that the CTO is having a particularly nice time of it right now, so if you have a responsibility for IT systems, please don’t make the same mistakes.

Matt Brasier
@mbrasier

JBossWorld Boston 2012 Wednesday



AeroGear: The Gear You Need to Go Mobile with Red Hat
Jay Balunas, Aero Gear's project lead gave a talk focused on another hot topic this week - how to convert existing and deliver new applications to mobile devices.  Tablets and smart phones are now outselling PC's so the importance of this area cannot be under-estimated, everything has to be delivered through multiple channels.  Mobile devices present a seemingly endless list of challenges - there are a wide range of operating systems, multiple versions of operating systems, native code, interpreted code, the performance impact of network bandwidth, security, testing....  The Aero Gear project is starting to address these issues and standardise an approach enabling rapid development and testing of mobile applications.  Demo apps can be found on the Aero Gear home page including details on creating JSF, HTML5 & Rest, Hybrid (for example using Apache Cordova) and Native mobile apps, good stuff.


JBoss Operations Network Provisioning
This was a hands on sample of JBoss Operations Network training, specifically two labs on bundle provisioning.  JBossON can provision any type of resource to groups of resources contained within its inventory.  Resources could be application deployments, configuration files or even entire server installations - it doesn't really matter.  On reflection having done implementations and Proof of Concepts for customers using this technology with RHQ I should have probably attended a different session.  Nevermind, it was a useful recap anyway!


JBoss Enterprise Application Platform 6 - Ease into the Cloud
This session presented by Jason Greene and Rich Sharples gave an overview of JBoss EAP 6 with some technical information on the new domain and standalone operation modes, improved performance and the new management tooling.  There were some good points raised by the audience at the end including

Is JBossAS7 7.1.1 going to be the final community release or will patches and enhancement be pushed back into the community version?  The response wasn't definitive - EAP 6 will likely go through several more release cycles with the initial releases being trialed on a possible AS 7.2 and 7.3 before forming part of the supported version.  I guess time will tell if the community product is stable enough (and sufficiently patched) to compete with EAP as a viable enterprise server.

How come the domain management console is incomplete, many metrics and configuration options are unavailable at the moment?  And also the console appears to lack some "truly" domain management functionality such as session bleed down.

The response was that these features are on the plan but they missed the cut for the first release, for the time being you can access all functionality through the new command line and RESTful interfaces but the console is still some way off completion.  In my opinion the console is still far too far behind some of JBoss' competitors, its a good start and definitely going in the right direction but there's a long way to go.  Most of the domain management use-cases can be covered off by management using alternative approaches to just the console, but for the time being at least its not going to be as easy as clicking a button in the console.

Mark Addy



Infinispan Event push over Tomcat Websocket via HornetQ (part 2)

(see Part 1 here)
In-play Match Betting
For this example we have a selection of sporting events, well just some football and cricket matches that we will publish odds for.  In the background a thread randomly updates odds for one of the outcomes (home win, away win or draw) and one of the matches.  Using the @CacheEntryModified event we send these back to the connected browser sessions via the websocket connection.

Servlet Code 
So lets get started with some code and the web container.  Its just got one servlet defined as follows:

@WebServlet(urlPatterns = "/inplay", loadOnStartup = 1)
public class InfinispanServlet extends WebSocketServlet {

As you can see we are using servlet 3.0 annotations, the other important thing to note is we are extending org.apache.catalina.websocket.WebSocketServlet which gives us the ability to process websocket connections.

This servlet gets loaded when the container starts and the init() lifecycle method performs the following tasks
  • Create an Infinispan CacheManager instance
  • Grab a reference to the distributed cache we are going to use
  • Creates a listener (jmsMessageProducer) for events propagated from the cache
  • Creates a consumer (jmsMessageConsumer) of events from the JMS topic 
  • Load the default set of events / matches we have odds for into the cache
  • Register our listener on the cache
    public void init() throws UnavailableException {
        try {
            super.init();
            manager = new DefaultCacheManager("infinispan-config.xml");
            cache = manager.getCache("dist-cache");
            jmsMessageProducer = JMSMessageProducer.getInstance();
            jmsMessageConsumer = JMSMessageConsumer.getInstance();

            /* loads all matches */
            for (Match match : Match.selection.getData()) {
                cache.put(match.getKey(), match);
            }

            cache.addListener(jmsMessageProducer);

        } catch (Exception e) {
            throw new UnavailableException(e.getMessage());
        }
    }

The corresponding servlet lifecycle destroy method cleans up these resources when the container stops.

The infinispan configuration is very basic, we have enabled JMX monitoring and are using distributed mode, two data owners with asynchronous replication.  The configuration file is bundled inside the war and looks like this:

<infinispan xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="urn:infinispan:config:5.1 http://www.infinispan.org/schemas/infinispan-config-5.1.xsd"
    xmlns="urn:infinispan:config:5.1">

    <global>
        <globalJmxStatistics enabled="true" jmxDomain="org.infinispan"
            cacheManagerName="MyCacheManager" />
        <transport>
            <properties>
                <property name="configurationFile" value="jgroups-udp.xml" />
            </properties>
        </transport>
        
    </global>

    <default>
        <jmxStatistics enabled="true" />
    </default>

    <namedCache name="dist-cache">
        <clustering mode="distributed">
            <hash numOwners="2" />
            <async />
        </clustering>
    </namedCache>

</infinispan>

When you extend org.apache.catalina.websocket.WebSocketServlet one of the methods you must implement is createWebSocketInbound, i.e. what do we do when a new websocket connection is created?  In our example for every connection we receive we want to commence a push of events from the cache to that connection.  To handle this we add the new connection to a pool (set) inside our local JMS message consumer.  This consumer is listening against the JMS topic that the cache listener pushes events onto:

    @Override
    protected StreamInbound createWebSocketInbound(String subProtocol) {
        WebsocketMessageInbound connection = new WebsocketMessageInbound();
        jmsMessageConsumer.addConnection(connection);
        return connection;
    }

We have to provide our own implementation of the Websocket connection and this is also contained in the servlet as a private class:

    final class WebsocketMessageInbound extends MessageInbound {

        @Override
        protected void onBinaryMessage(ByteBuffer message) throws IOException {
            // getWsOutbound().writeBinaryMessage(message);
        }

        @Override
        protected void onTextMessage(CharBuffer message) throws IOException {
            // getWsOutbound().writeTextMessage(message);
        }

        public void onClose(int status) {
            jmsMessageConsumer.removeConnection(this);
        }

        public void onOpen(WsOutbound outbound) {
            try {
                Set<Entry<String,Match>> entrySet = cache.entrySet();
                List<Match> matchList = new ArrayList<Match>();
                for (Entry<String, Match> entry : entrySet) {
                    matchList.add(entry.getValue());
                }
                MatchSelection selection = new MatchSelection(matchList);
                outbound.writeTextMessage(CharBuffer.wrap(JsonHelper.toJSonString(selection)));
            } catch (Exception e) {
                e.printStackTrace();
            }
        }

        void broadcast(String message) {
            try {
                CharBuffer buffer = CharBuffer.wrap(message);
                getWsOutbound().writeTextMessage(buffer);
            } catch (IOException ioe) {
                System.out.println("ouch " + ioe.getMessage());
            }
        }

    }

In this example we are ignoring events received from the client (these are handled by the onBinaryMessage and onTextMessage methods), we are just pushing read-only data back down the websocket.
  • When a client opens a connection (onOpen) we extract all the in-play match information from the cache and send them the latest view of the data.  
  • When a client closes their connection (onClose) we remove that connection from the pool.
You'll also notice that the initial data set sent to the client during onOpen is in JSON format - when we take a look at the java script later in this post you'll see why we are using this format for all messages.

Messaging Code and Configuration
We've already seen the servlet initializing a jmsMessageProducer instance (to listen for cache events and publish them onto our topic) and a jmsMessageConsumer instance (to receive messages from the topic and push them back over all their registered client connections).  First we should really set up our HornetQ server:

HornetQ Server
I downloaded the latest release (2.2.14.Final) from here, extracted and ran the default "standalone" configuration.  The only change to the config required is to define our JMS topic in the $HQ_HOME/config/standalone/non-clustered/hornetq-jms.xml file as follows:

   <queue name="ExpiryQueue">
      <entry name="/queue/ExpiryQueue"/>
   </queue>

   <topic name="InfinispanEventTopic">
      <entry name="/topic/InfinispanEventTopic"/>
   </topic>

</configuration>

JmsMessageProducer
The JmsMessageProducer is responsible for receiving cache events from Infinispan so therefore it has to be annotated with the @Listener interface:

@Listener
public class JMSMessageProducer {

Initialization of the JmsMessageProducer creates a connection to the topic using the native HornetQ JMS Api to connect to the host and port where the HornetQ server is located:

    private void initialize() throws Exception {

        Map<String, Object> connectionParams = new HashMap<String, Object>();
        connectionParams.put(org.hornetq.core.remoting.impl.netty.TransportConstants.PORT_PROP_NAME, 5445);
        connectionParams.put(org.hornetq.core.remoting.impl.netty.TransportConstants.HOST_PROP_NAME, "localhost");
        TransportConfiguration transportConfiguration = new TransportConfiguration("org.hornetq.core.remoting.impl.netty.NettyConnectorFactory",
                connectionParams);
        HornetQConnectionFactory cf = HornetQJMSClient.createConnectionFactoryWithoutHA(JMSFactoryType.CF, transportConfiguration);
        connection = cf.createConnection();
        session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
        Topic topic = session.createTopic("InfinispanEventTopic");
        producer = session.createProducer(topic);
        connection.start();

    }

To receive cache modification events and publish messages to our HornetQ topic the JmsMessageProducer defines a method annotated with @CacheEntryModified containing the logic to generate and publish the message:

    @CacheEntryModified
    public void logModifiedEvent(CacheEntryModifiedEvent<String, Match> event) throws IOException {
        if (!event.isPre()) {
            MatchUpdate matchUpdate = new MatchUpdate(event.getValue());
            sendMessage(matchUpdate);
        }
    }

And finally the sendMessage method handles delivery:

    public void sendMessage(MatchUpdate matchUpdate) throws JsonGenerationException, JsonMappingException, IOException {
        try {
            Message textMessage = session.createTextMessage(JsonHelper.toJSonString(matchUpdate));
            textMessage.setStringProperty(org.hornetq.core.message.impl.MessageImpl.HDR_DUPLICATE_DETECTION_ID.toString(),
                    matchUpdate.getJmsDuplicateDetectionId());
            producer.send(textMessage);
        } catch (JMSException e) {
            e.printStackTrace();
        }
    }

Hang on though, this means for every cache update two events (if we have numOwners=2) get fired, one at each node owning the data.  In our current system two duplicate events will generate a JMS message delivered to the HornetQ topic running on the standalone broker and so therefore all the message listeners will receive the event twice!

Obviously this isn't great but HornetQ has an out of the box duplicate detection system we can make use of.  One of its attractive features is its amazing performance in performance tests - over 8 million messages per second is very impressive.  Native HornetQ bridges are also highly performant and this in part can be attributed to the mechanism HornetQ uses to provide ONCE and ONLY ONCE delivery semantics.  The previous incarnation of HornetQ, JBoss Messaging relied on XA transations to provide guaranteed delivery over a JMS bridge but this came at a price, namely disk I/O.  XA transactions require that the state of the transaction is persisted to disk at the prepare and commit phases to ensure that should a system outage occur at any point during this process sufficient information is retained to recover the transaction state and ensure that messages are delivered ONCE and ONLY ONCE.  Disk I/O is a huge overhead in a high throughput system so the HornetQ team devised an in-memory mechanism that caches a configurable number of received messages at the receiver end so that in failure scenarios message delivery can be replayed safely with any duplicates discarded by the receiver.

By default the JMS Message Id property is used as the unique identifier  but this can be overridden as shown in the sample code above, allowing users to implement their own identifiers - in our case this will be the key to the in-play match cache entry and its associated version number.

JmsMessageConsumer
The consumers job is to receive messages from the topic and forward them back to the clients, the initialization logic is similar, again we use the native HornetQ JMS Api:

    private void initialize() throws JMSException {
        Map<String, Object> connectionParams = new HashMap<String, Object>();
        connectionParams.put(org.hornetq.core.remoting.impl.netty.TransportConstants.PORT_PROP_NAME, 5445);
        connectionParams.put(org.hornetq.core.remoting.impl.netty.TransportConstants.HOST_PROP_NAME, "localhost");
        TransportConfiguration transportConfiguration = new TransportConfiguration("org.hornetq.core.remoting.impl.netty.NettyConnectorFactory",
                connectionParams);
        HornetQConnectionFactory cf = HornetQJMSClient.createConnectionFactoryWithoutHA(JMSFactoryType.CF, transportConfiguration);
        connection = cf.createConnection();
        session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
        Topic topic = session.createTopic("InfinispanEventTopic");
        MessageConsumer consumer = session.createConsumer(topic);
        consumer.setMessageListener(listener);
        connection.start();
    }

We also maintain the set of connected clients:

    private Set<WebsocketMessageInbound> connections = new CopyOnWriteArraySet<InfinispanServlet.WebsocketMessageInbound>();

    public void addConnection(WebsocketMessageInbound connection) {
        connections.add(connection);
    }

    public void removeConnection(WebsocketMessageInbound connection) {
        connections.remove(connection);
    }

And when we receive a message we broadcast it to the clients:

    private final MessageListener listener = new MessageListener() {

        @Override
        public void onMessage(Message message) {
            if (message instanceof TextMessage) {
                TextMessage textMessage = ((TextMessage) message);
                try {
                    for (WebsocketMessageInbound connection : connections) {
                        connection.broadcast(textMessage.getText());
                    }
                } catch (JMSException e) {
                    e.printStackTrace();
                }
            }

        }

    };

So that's it for the messaging infrastructure, next we'll take a quick look at the client side java script

Client Java Script
Ok, so we've looked at the key components on the server side and also how the servlet container handles websocket traffic, now we'll look at the client side and run through the java script used to create a websocket connection and receive the cache event updates from the server.

This is the javascript used in the example to create the client websocket connection - the actual websocket is wrapped in a "FancyWebSocket" (see below) to handle a JSON message format exchange between client and server:

            var WS = {};
            WS.socket = null;
    
            WS.connect = (function(host) {
                if ('WebSocket' in window) {
                    WS.socket = new FancyWebSocket(host);
                } else {
                    return;
                }
            });
    
            WS.initialize = function() {
                WS.connect('ws://' + window.location.host + '/infinispan/inplay');
            };
    
            WS.initialize();
As you have seen data sent from the server to the browser is in JSON format, this is no accident.  Earlier in this post we saw the default handling of client messages in the servlet (onBinaryMessage and onTextMessage) and although we haven't implemented any client messaging back to the server it's worth considering how you would handle this anyway.  If you clients send text instructions to the server then you'll probably need to parse the content to comprehend what the client wants to do, is the client trying to request a data item?  update some data? query for some data?  So we definitely need to parse this communication and JSON is an ideal format both the client and server can understand.

Fortunately for me, not being a javascript expert, handling of java script messages over websockets on the client side has been beautifully encapsulated in this post back in 2010 - you'll find the code in ws_events_dispatcher.js if you take a look at our running example.  So we'll borrow this for our example - its very powerful allowing the binding of "events" to functions.

var FancyWebSocket = function(url){

  var conn = new WebSocket(url);
  var callbacks = {};

  this.bind = function(event_name, callback){
    callbacks[event_name] = callbacks[event_name] || [];
    callbacks[event_name].push(callback);
    return this;// chainable
  };

  this.send = function(event_name, event_data){
    var payload = JSON.stringify({event:event_name, data: event_data});
    conn.send( payload ); // <= send JSON data to socket server
    return this;
  };

  // dispatch to the right handlers
  conn.onmessage = function(evt){
    var json = JSON.parse(evt.data)
    dispatch(json.event, json.data)
  };

  conn.onclose = function(){dispatch('close',null)}
  conn.onopen = function(){dispatch('open',null)}

  var dispatch = function(event_name, message){
    var chain = callbacks[event_name];
    if(typeof chain == 'undefined') return; // no callbacks for this event
    for(var i = 0; i < chain.length; i++){
      chain[i]( message )
    }
  }
};

Now we can bind our examples events and execute the functionality we want when JSON messages matching that event arrive at the client:

            WS.socket.bind('update', function(matchData){
                if (availableMatchListBuilt) {
                    updateMatchRow(matchData);
                }    
            })
            WS.socket.bind('start', function(matchData){
                if (!availableMatchListBuilt) {
                    buildAvailableMatches(matchData);
                    availableMatchListBuilt = true;
                }    
            })
  • The update event corresponds to a change in the match odds
  • The start event corresponds to the initial load of all the in-play matches
Hopefully this gives you an introduction to the fundamental nuts and bolts I used to get this example working, there's lots more scripting in the client and heavy usage of the jquery libraries to get the formatting and updates to work - the best way to view this will be to take a look at the source code yourself.

Mark Addy

27 June 2012

JUDCon Boston 2012 Day Two

Back for another day, they even have bagels for breakfast :)

JBoss Forge: Productivity, Reliability, and Testability in an Enterprise Environment

This was a really good talk and demo from project lead Lincoln Baxter III.  JBoss Forge is a command line / shell based rapid application development tool.  It can be run standalone or integrated into your favourite IDE.  You can use to automate tasks, generate tests and rapidly build a working, if a little basic enterprise application.  Sort of like a maven archetype but taking you a step further and providing the ability to generate and deploy some real (and working) code which can then be customised for your own use-case.  Its not tied to a framework, in fact the range of functionality is limited only by the number of available plugins - and of course there is a framework to develop your own plugins.  The demo showed how a JSF application with JPA persistence could be created, configured, customer, built and deployed to a JBossAS7 instance in a matter of minutes.  Quite impressive.

There are other tools out there so you might want to take a look at Spring Roo and Play! if this is an area you are looking into.

A common theme with the presentations so far has been inclusion and pushing of OpenShift so it wasn't a surprise that Forge has a plugin capable of deploying to the JBoss opensource cloud.

Enterprise Services Made Easy with SwitchYard

Another SwitchYard presentation and demo - you can't fail to be impressed with the tooling that comes with this new ESB offering from JBoss.  In this talk we saw how the logic to perform validation and transformations can be externalized to service logic with the container injecting this functionality at run-time.
Testing of SwitchYard services has also been simplified in comparison to JBossESB, the new tooling can autogenerate JUnit test classes that run with a SwitchYardRunner responsible for bootstrapping the ESB container.


And the evening saw the commencement of Redhat Summit / JBossWorld and the opening keynotes - which was quite something.  Perhaps a little bit over the top, at least for me anyway.  Booming music, rock concert lighting, at least there was no dry ice and I didn't see anyone holding a lighter in the air.  Still I felt I had to take a photo but it really doesn't capture the ambience...


Mark Addy

26 June 2012

Infinispan Event push over Tomcat Websocket via HornetQ (part 1)


Background
Continuous query (CQ) is a powerful tool to register for and receive updates on changes to cached data.  For example, you have a cache of equity trades and you would like to provide users with the ability to register for and only receive changes effecting google.com.  The established big players in Data Grid technology such as Oracle Coherence and Gemfire offer variations on this functionality and this is a common usage pattern that will hopefully become part of the JSR 347 standardisation of data grids.

I wanted to take a look at what Infinispan has to offer in this area and combine it with the latest Tomcat distribution which contains support for websockets as defined in RFC 6455.  This combination of technologies will permit a real-time push cache events over a websocket back to the client browser.  It wasn't plain sailing so I'll go through some of the issues I encountered, how they were solved and some (rudimentary) code to demonstrate how you might implement this architecture.  The image on the right will take you to a working example where you'll find the source code available for download.

Tomcat
The last two Tomcat releases (7.0.27 and 7.0.28) both include Websocket functionality - you'll want to skip 7.0.27 though as websocket timeouts are coupled to the HTTP connector connectionTimeout property defined in server.xml.  In 7.0.28 this link is removed and the websocket has an infinite timeout, this is the version used in this example. 

Infinispan
Does Infinispan have CQ support?  Well there is a project in "incubation" status available for download here and some documentation here, great news - this is going to be straight forward then!  So I grabbed a copy, built it, wrote some code but then I hit a problem.  Internally Infinispan maintains a "ComponentRegistry" - a singleton store of the core components required to run the cache.  When one cache component requires a reference to a component from the registry an @Inject annotation is used to execute the logic to supply this reference.  From what I could see the component registry is now implemented slightly differently in the latest 5.1.x releases of Infinispan in comparison to the 4.x code base.  Component dependencies are now expressed in a serialized .dat file rather than in the previous releases where reflection was exclusively used - this has broken the CQ project.  All is not lost though! Lets take a look at Infinispan's Event Listener Framework.  Instances of org.infinispan.Cache implements the Listenable interface.  This allows classes marked with the @Listener annotation to receive events from the cache, the full set of events is comprehensively covered in the docs so I won't go into it in much detail here.  For this example we'll just be using the @CacheEntryModified event to receive updates when cache entries change.

So what are the drawbacks?

Well there isn't any support for events over the Hotrod client-server architecture, yet - you can track the status of this task here and it looks like this functionality will be available in the 5.2.0 release.  So for this example I'm going to stick with embedded mode.

The other issue is that events only fire on nodes that own the data which is fine if your cache is replicated but as we've already discussed in this post replicated caches don't scale well.


So how do we capture events from a distributed cache and still ensure that all clients receive all the updates?  We can use a JMS topic to capture events with clients consuming from this destination.

HornetQ
HornetQ is the default JBoss messaging stack, its super quick and also completely free!  Check out this post for some more background.  To implement this architecture we'll turn the listener we create in the architecture above to be a JMS producer as well.  We'll send events to a topic and create a consumer embedded in the application to receive from the topic.  Here's what it looks like now:


So all the application instances now receive updates from the cache, all we need to do is push these back to the client using Tomcat's websocket implementation.


Ok, so that's it for part 1, in part 2 we'll look more closely at some of the code.

See Part 2 here

Mark Addy

Infinispan from POC to Production - Video and Slides


Presentation by Mark Addy, C2B2 Senior Consultant

If your applications caching capability is preventing you from scaling up or handling bursts in traffic then you may have considered some of the data grid technologies available. This session walks you through two real world solutions designed and implemented using open source Infinispan for a global on-line travel agency. Both outcomes resulted in reduced latency, dynamic scaling and a massively increased caching capacity.

The first part will describe an existing replicated cache running at full capacity and how this was replaced with a distributed solution that allowed the application to scale dramatically with a performance improvement to boot. Secondly we will look at proof of concept for an application with a problematic design and how another distributed caching solution incorporating grid-execution saved the day providing massive scale out and low latencies.

This talk is aimed at developers, architects and middleware specialists interested in caching solutions.

Speaker Bio:
Mark Addy currently works as a Senior Consultant at C2B2 a UK Java consultancy which specializes in building fast, scalable and reliable systems. He has extensive experience delivering development, troubleshooting, problem analysis and performance tuning services to clients spanning a wide range of industries.

The talk was presented at London JBUG and JUDCon Boston in June 2012



JUDCon Boston 2012 Day One


Welcome to JUDCon Boston 2012, and as you can see the weather is a distinct improvement on this years English Summer!

So here are some of the best bits from the first day.

The Future of the Enterprise Service Bus at JBoss


If your using or thinking about using JBossESB then you shouldn't have missed this talk.  The end of the road is insight for JBossESB, the current JBoss offering that forms the base for the supported SOA-P platform.  It will be replaced in SOA-P 6 with SwitchYard and this talk focused on the implementation differences between the two projects and migration paths to move from ESB to SwitchYard.  I felt a little sorry for co-presenter Tom Cunningham, project lead on JBossESB as Keith Babo, his counterpart on SwitchYard reeled off improvements in tooling, configuration and wound up with a slick demo creating a simple service using an Eclipse plugin.  It's still early days for SwitchYard features such as clustering and distribution have yet to be implemented but the writing in on the wall for JBossESB.  It's definitely time to take a good look at this project if you are an ESB user.


Eventual Consistency in Infinispan


Manik Surtani presented plans to implement a new consistency model for Infinispan, "eventual consistency".  Starting with an overview of CAP theory he covered the difficulties of managing consistency, availability and partition tolerance in a distributed system.  You can have two out of the three properties but you can't have everything!

Consistency - all nodes have the same view of the data 
Availability - all requests receive a response (an error is a legitimate response)
Partition Tolerance - the system still functions in the event of a network partition of split brain

Currently Infinispan operates in a single traditional "Strongly Consistent" model facilitated by its built in support for transactions, thereby providing ACID guarantees for cache operations.  In the new model some consistency would be sacrificed for better handing of network partitions.   Vector clocks will track causality of updates and a new API will permit applications to make consistency "fixes" should operations return indeterminate results.  For example a V cache.get(K) operation could return multiple versions of a cache entry if a network partition has occurred.  The API would allow the application to make an intelligent choice over which entry is correct and "fix" the consistency discrepancy.  Users will have the ability elect which consistency mode to run their distributed system in but this is some way off as its still in the design stage.


JBoss AS7/EAP6 - Reflection of 6 Months on-site

If you wanted to get some deeper information on reality around migrating applications to the latest JBoss application server (AS7 or EAP6 depending on your budget) then this talk highlighted the fundamental changes in the new modular class-loading architecture.  The jboss-deployment-structure.xml configuration file gives you fine grained control over class-loading and the ability to define explicit dependencies. 



Mark Addy

23 June 2012

JBoss EAP 6 as light as Raspberry PI?

JEE != Heavy!

There has been a lot of debate about JEE application servers being "heavy-weight" . However I've always been of the opinion that JEE app servers may have been a little fat in the "noughties" but with the new breed of application servers combined with JEE6 that is no longer true. So I recently received my Raspberry PI, a cheap ($25) Linux compatible ARM bare board which runs Debian. The PI comes with 256Mb RAM on board and an ARM1176JZFS and supports Java so it should be about as lightweight as you can get as a server platform. Also JBoss EAP 6 was released this week with claims that it is a lightweight JEE6 compliant application server so I decided to test how lightweight it is by getting it to run on the PI.

Install Java

First things first. I decided to use Oracle's embedded Java as it supports Armv6 chips. The exact version used was ejre-7u4-fcs-b20-linux-arm-vfp-client_headless-12_apr_2012.
pi@raspberrypi:~$ gunzip ejre-7u4-fcs-b20-linux-arm-vfp-client_headless-12_apr_2012.tar.gz
pi@raspberrypi:~$ tar xvf ejre-7u4-fcs-b20-linux-arm-vfp-client_headless-12_apr_2012.tar
pi@raspberrypi:~$ cd ejre1.7.0_04/bin pi@raspberrypi:~/ejre1.7.0_04/bin$ ./java -version java version "1.7.0_04-ea" Java(TM) SE Runtime Environment for Embedded (build 1.7.0_04-ea-b20, headless) Java HotSpot(TM) Embedded Client VM (build 23.0-b21, mixed mode)
That's it for installing Java.

Get JBoss EAP 6 Running


 Now for JBoss EAP 6. I downloaded the EAP 6 zip file release from http://access.redhat.com and copied it over to the PI using SCP.

pi@raspberrypi:~$ unzip jboss-eap-6.0.0.zip 

So now we have JBoss "installed". First things first JBoss EAP 6 sets its java memory settings a little high so we override it by setting our own JAVA_OPTS variable and tell JBoss where to find Java. Then we need to add a user so we can access the console later (by default JBoss has no users created).

pi@raspberrypi:~/jboss-eap-6.0/bin$ export JAVA_OPTS="-Xmx125M -XX:MaxPermSize=50M -Djava.net.preferIPv4Stack=true -Dorg.jboss.resolver.warning=true -Dsun.rmi.dgc.client.gcInterval=3600000 -Dsun.rmi.dgc.server.gcInterval=3600000 -Djboss.modules.system.pkgs=org.jboss.byteman -Djava.awt.headless=true -Djboss.server.default.config=standalone.xml" pi@raspberrypi:~/jboss-eap-6.0/bin$ export JAVA_HOME=/home/pi/ejre1.7.0_04/
pi@raspberrypi:~/jboss-eap-6.0/bin$ ./add-user.sh
What type of user do you wish to add?
a) Management User (mgmt-users.properties)
b) Application User (application-users.properties)
(a): Enter the details of the new user to add.
Realm (ManagementRealm) :
Username : admin
Password :
Re-enter Password :
The username 'admin' is easy to guess Are you sure you want to add user 'admin' yes/no?
yes
About to add user 'admin' for realm 'ManagementRealm' Is this correct yes/no? yes Added user 'admin' to file '/home/pi/jboss-eap-6.0/standalone/configuration/mgmt-users.properties' Added user 'admin' to file '/home/pi/jboss-eap-6.0/domain/configuration/mgmt-users.properties'
Is this new user going to be used for one AS process to connect to another AS process e.g. slave domain controller? yes/no?
no
pi@raspberrypi:~/jboss-eap-6.0/bin$ ./standalone.sh -b 192.168.0.81 -bmanagement=192.168.0.81


With these settings JBoss starts up in about 60 seconds and listens on 192.168.0.81 (the IP address of the PI on the network). Browsing to the home page http://192.168.0.81:8080 we see that JBoss is ALIVE on the PI.

 Browsing through the Admin Console we can see that we have JBoss running with memory to spare!

Why is this important

This may seem a bit silly but it shows that modern JEE 6 application servers are in no way heavyweight and you can easily run a full JEE6 stack in less than 100Mb of RAM on a $30 ARM board. So forget the heavyweight claims.
The second things this shows is that thanks to Oracle's release of the embedded JDK for ARM which is a full JDK as opposed to a mobile profile it is possible to run very complex Java applications on low powered ARM chips ( the PI apparently draws less than 3W power when running flat out). I can see a huge future in new server platforms containing large numbers of ARM chips running application servers like JBoss. In fact I know that Dell and HP are planning these hyperscale servers.

Steve Millidge

22 June 2012

JBoss EAP 6 - First Light


What’s All The Fuss About?
So, JBoss EAP 6 is here at last, it’s a long time since EAP 5 was released (2009) and the middleware market has changed a lot in that time, how does Red Hat’s latest offering stand up to the competition? JBoss has always struggled in the enterprise, it has historically focussed on being “the developers application server”, being first-to-market with the latest standards and features, but with an unwieldy set of configuration files, and no central management, making it hard to look after in large scale operational deployments. JBoss has always been a collection of disparate projects, pulled together at the last minute into an application server, and it showed. Red Hat made attempts to solve this with the RHQ/JBoss Operations Network tool, but uptake was poor (because developers aren’t interested in operations tooling) and JBoss retained its reputation as a product for developers, with many organisations developing on JBoss and deploying on Websphere/WebLogic. After an abortive attempt to keep plugging on with the old JBoss architecture (JBoss AS community 6), work started on a completely new JBoss application server, taking the best ideas from popular enterprise-grade platforms, and designing a new, integrated application server from the ground up. This new application server was released almost a year ago with the name JBoss AS 7, and it is from this that JBoss EAP 6 has grown.

A New Beginning
JBoss AS 7 took large (but not particlarly bold, given the path was well trodden by the likes of Glassfish, WebLogic and Websphere) steps, a single central configuration file for one (or more) servers, a modular start-up, and a completely new way of managing multiple servers. With the core architecture in place, JBoss AS 7 GA was released to the public, but as I blogged back in August last year, it was too little and too soon. Many features were not yet implemented, and many of those that were had bugs. The features that weren’t working, while they might be considered ‘minor’ to an application developer, were the core features that the application server should be providing, things like security, file access, application deployment, etc. This AS 7 release was only-half finished, pushed out of the door to meet marketing deadlines and make some “noise about JBoss”, but it backfired, with many C2B2 customers, together with members of the London JBUG, commenting that it was unusable and rushed.

EAP 6 - Was it Worth The Wait?
At the time of the AS 7 release, the general feeling among the community was that the product was only half complete, and that people should “come back in a year when it is finished”. Now it is nearly a year later and EAP 6 has been released, did they manage to finish the job? Well the good news is that it looks like they did. The features that were partially implemented or incomplete seem to be there and working, finally giving Red Hat the centrally controlled platform that it needs to be able to compete in the large-scale enterprise market. For me, the main features that make JBoss 7 stand above its predecessors are the domain mode and the central configuration. Between these two, it is now possible to centrally manage the configuration for a large deployment of JBoss servers, eliminating much of the mis-configuration that can occur when having to configure each server and component separately.

Still Room For Improvement
While the platform does seem more solid than it was a year ago, with the necessary features in place, I did find a few small bugs (which is to be expected in a product this big). I still get the feeling that ‘standalone’ mode is targeted more than ‘domain’ mode in the testing, that features are developed in standalone mode and then ‘got to work’ in domain mode, rather than the other way around. I strongly believe that ‘domain’ mode deployments are going to be the choice of most of Red Hat’s enterprise (and therefore paying) customers, and that features and testing should be focussed on domain mode primarily. This runs counter to JBoss’ background as the application server that people code on in their bedroom, while learning JavaEE, but bedroom development is not a particularly lucrative market, and Red Hat are foolish to continue to focus effort there.

Conclusion
Red Hat have released JBoss EAP 6, based on the community JBoss AS 7 project which went GA last year, the changes that it makes are large and sweeping, but were necessary for JBoss to remain competitive in the application server marketplace. The missing features from JBoss 7 have been ironed out, although it still feels a little like the developers are still using standalone mode over domain mode, but overall the product seems to deliver what was needed. Red Hat have made good progress in fixing the issues with the JBoss AS 7 GA release, and have delivered a platform which, with the correct focus, will allow them to not only remain competitive, but push into new market sectors.

On Thursday next week (28/6/12) I will be running a webinar taking a technical look at JBoss EAP 6, from install to application deployment. Please register for this event here, or if it has passed, view the recording on your YouTube channel.

Matt Brasier
@mbrasier

1 June 2012

Elastic SOA in the Cloud - C2B2 is speaking at SOA, Cloud & Service Technology Symposium



Steve Millidge, C2B2 Director, will be speaking at SOA, Cloud & Service Technology Symposium in London


Title: Elastic SOA in the Cloud


Date and Time: September 24, 2012 , 13:15-14:00

Talk Description:

We know service-oriented architectures can deliver huge agility benefits for developing new functionality through repeated service reuse. However, if our shared services become highly used, they may be subjected to massively increased loads from runtime events that we, as service owners, cannot predict. With the significant return on investment gained with the deployment of public and private clouds, virtualization technology is now making it possible to combine SOA infrastructures with monitoring and APM tools to elastically scale out service deployments in response to real-time load increases.
This session will take a technical deep dive into a service-oriented architecture engineered specifically for elasticity. The following questions will be explored:

  • How can I monitor the load on my Services?
  • How can I fire up additional compute capacity as a service becomes loaded?
  • How do I architect my SOA deployment to utilise the power and flexibility of a private or public cloud?
  • How do I deploy UDDI to ensure clients can fully utilise new capacity?
  • How can I see what is happening on my ESB infrastructure?

This talk is aimed at for architects and developers who have moved beyond "playing" with SOA in the cloud, and are looking to deploy SOA into a cloud-based production environment. Learn from someone who has been there and got the T-Shirt.

Speaker Bio:

Steve is the director and founder of C2B2 Consulting Limited and organiser of London JBoss User Group. C2B2 is a specialist JBoss consultancy focusing exclusively on achieving non-functional requirements thereby ensuring JBoss based solutions go live; Fast, Reliable, Manageable and Secure. Steve has used Java extensively since pre1.0 and has been a field based professional service consultant for over 10 years. Through C2B2 he now focuses exclusively on the configuration of JEE and SOA infrastructure for maximum Scalability, Performance, Availability, Recoverability, Manageability and Security. Having worked for and on behalf of Oracle, BEA and Red Hat professional services he has extensive experience of deploying large scale production JBoss systems. Steve has spoken at a number of events including JBoss World, UK Oracle User Group Conference, The Server Side Symposium, Community One and regularly presents brown bag technical sessions for C2B2's customer base. Prior to founding C2B2, Steve was a Principal Consultant in Solution Architecture at Oracle UK where he was an architect of Ordnance Survey’s Master Map project to deliver digital mapping data over the web and also worked on a large integration application for the Foreign Office. Steve has many years experience of building large scale web applications and was an architect for the Tour De France’s web infrastructure.

Find out more about SOA, Cloud and Service Technology Symposium


Data Grids and Web Sockets: Delivering Real Time Push at Scale - C2B2 is speaking at JAX London


Steve Millidge, C2B2 Director, will be speaking at JAX London, 15-17 October 2012

Title: Data Grids and Web Sockets: Delivering Real Time Push at Scale

Talk Description:

Data Grids and Web Sockets: Delivering Real Time Push at Scale - C2B2 is speaking at JAX London
The real time web is coming with Websockets in HTML 5. The big question is how to deliver event driven architectures for websockets at scale. This session delivered by a member of the JSR 347 Data Grids expert group provides an insight on how combining Data Grids with Websockets can deliver enterprise scale push to web devices. The session first provides an introduction to websockets and delves into typical data grid architectures and how they deliver linear scalability and high availability. We then look at the event capabilities inherent in Data Grids that when hooked up to a Web Sockets server can deliver data grid updates in real time to HTML 5 devices. We will then attempt a live demonstration of pushing data from a grid to as many of the client devices in the room to see which devices support web sockets now.

Speaker Bio:

Steve is the director and founder of C2B2 Consulting Limited and organiser of London JBoss User Group. C2B2 is a specialist JBoss consultancy focusing exclusively on achieving non-functional requirements thereby ensuring JBoss based solutions go live; Fast, Reliable, Manageable and Secure. Steve has used Java extensively since pre1.0 and has been a field based professional service consultant for over 10 years. Through C2B2 he now focuses exclusively on the configuration of JEE and SOA infrastructure for maximum Scalability, Performance, Availability, Recoverability, Manageability and Security. Having worked for and on behalf of Oracle, BEA and Red Hat professional services he has extensive experience of deploying large scale production JBoss systems. Steve has spoken at a number of events including JBoss World, UK Oracle User Group Conference, The Server Side Symposium, Community One and regularly presents brown bag technical sessions for C2B2's customer base. Prior to founding C2B2, Steve was a Principal Consultant in Solution Architecture at Oracle UK where he was an architect of Ordnance Survey’s Master Map project to deliver digital mapping data over the web and also worked on a large integration application for the Foreign Office. Steve has many years experience of building large scale web applications and was an architect for the Tour De France’s web infrastructure.