Showing posts from 2016

How to prove your Ratpack app is non-blocking.

Using the Ratpack framework can be tricky. It's easy to get something working but it's harder to ensure that your code is non-blocking.  This post will detail how to prove your code is non-blocking with automated tests. Background - What's the problem? In order to realise the performance benefits of the Ratpack framework you have to ensure that your code is non-blocking.  This means ensuring that your Java Threads are always busy and not waiting for I/O (i.e. non-blocking).  As soon as your thread kicks off an I/O task (e.g. sending a http request or making a DB call), it should be able to switch to another task.  Once the I/O eventually completes an event is fired which informs that the next step in the code can be performed, typically doing something with the result of the I/O task.  This means that a huge number of tasks which are I/O bound (i.e. spend a significant amount of time waiting for I/O) can be perf

The case for keeping firewalls simple

Internal firewall rules that attempt to analyse anything higher than the network layer can cause huge problems. In this post I'll make the case for keeping your firewall rules simple. The problem we had O ur team recently encountered an error where an internal web application received a socket timeout when trying to call one of its internally hosted dependencies.   Whilst investigating, we found that the application had made successful HTTP calls to the same service, immediately prior to the error.   It was puzzling but I ruled out anything Network related in our investigation given: The application could make some  requests absolutely fine. There was nothing seemingly different about the requests and responses.  They were all GET requests that returned a small amount of JSON. There weren't any connection errors. All signs pointed to the server taking too long to respond, i.e. an application issue. We then found that the system being called had no recor

Ratpack talk - The story so far

I recently gave a talk to developers at Sky where I am currently working with Energized Work  on the subject of our team's experience with Ratpack. Apologies for the technical issue half way through (and also for the huge number of erms and ers).   Slides: Code: Thanks to everyone who came along at Osterley. ...thanks also to the people watching from the Leeds office.

Lesson learned with Ratpack and RxJava

We recently encountered an issue with integrating Ratpack with RxJava's Observables .  This post will detail what the error was, how it was broken and how it was fixed. The code  Essentially, our handler code was as follows (NOTE: see git project for this class  and also a test showing the behaviour of the broken code): @Override public void handle(Context context) throws Exception { Observable<String> contentFromDownstreamSystem = observableOnDifferentThreadService .getContent(); contentFromDownstreamSystem.subscribe(response -> { context.render( "Downstream system returned: " + response); } ); } The code above retrieves an Observable from a service.  As implied by the variable name, the Observable emits items on a different thread when it is subscribed to.  The Obsevable I have used to illustrate this issue is very simple and can be found here .  In our real world example, our Observable represented a Resu

Choosing between Ratpack and Dropwizard.

This post will discuss our team’s approach to evaluating the java based web framework  ratpack  as an alternative to  dropwizard  for creating a new microservice.  This post assumes a basic prior knowledge of both  ratpack  and dropwizard . Background The team I'm on is full of developers all with experience of creating and maintaining applications built with the Dropwizard framework. It’s safe to say that Dropwizard would be the team’s default preference when considering frameworks for web based java apps. However, we have recently been tasked with building a new microservice that is as efficient as possible. Although this non-functional requirement isn’t 100% specified, we do know it will need to be capable of high throughput and low resources (i.e. memory and CPU). High costs from the company’s PAS provider have in no doubt influenced this requirement. Ratpack is said to allow you to create "high pe