Posts

Showing posts from 2016

Hubpress now has RSS support.

The URL for RSS for my blog is http://vanilla-java.github.io/rss/

Goldilocks Microservices

Image
Goldilocks Microservices Peter Lawrey Most answers for Java and JVM on StackOverflow.com (~12K), "Vanilla Java" blog with four million views, founder of the Performance JUG, Java Champion How to structure microservices? When structuring microservices we have to consider; how fine grain should our components be? how distributed should they be? I believe it’s important to treat these as separate concerns, even to the extent of ensuring your business logic components are not dependant on the choice of transport, or even whether you have a transport at all. https://vanilla-java.github.io/2016/06/30/Goldilocks-Microservices.html

Talks on performant microservices, exception handling and documentation driven development.

I have three talks I am giving at the moment. The first I have given a few times, the remaining two are still in beta. Latency sensitive Micro-services What can Trading System and Micro-services learn from each other? What strategies do they have in common? http://www.slideshare.net/PeterLawrey/low-latency-microservices-in-java-qcon-new-york-2016 Modelling interactions between microservices. Describing interactions between micro-services in code, as readable messages and graphically. (Beginner to Intermediate) Exceptional Exception Handling There is many different way to handle exception apart from the typical log/ignore and pretend it didn't matter. What are the alternatives and which might you use them. Documentation Driven Development to make contributions easier. How can documentation driven development make it easier to start using and improve adoption rates for your project/product? How does it make it easier to contribute? Why is it so important for Micro

Distributing Common Java APIs

Image
Distributing Common Java APIs Peter Lawrey Distributing data stores vs Private data stores in Microservices Distributing data containers e.g. Maps, can be a way of avoiding having to think too much about distributing your application. Your business logic is much the same, and it is your data collections which are visible to all your services. Using centralised or even distributed data stores have a number of scalability issues, as it requires every low level data access to be distributed in a generic way which isn’t optimised for particular business requirements. Distributing business components with private data stores is the favoured approach of Microservices and it limits the "surface area" of each service which reduces security issues, performance considerations and gives you more freedom for independant changes to service’s data structures. In this review, I will be focusing on distributed data containers, largely because the interfaces are avai

Modelling Microservice Patterns in Code

Image
Modelling Microservice Patterns in Code Peter Lawrey Service Interactions There is a number of simple interactions a service can support. Which pattern is best for your application can depend on what an existing application expects, and what latency requirements you have. Broadly speaking these interactions fall into client-server and peir-to-peir messaging. For peir-to-peir messaging, one approach to take is  Lambda Architecture  however from supporting GUIs, client - server models can be easier to work with. I feel it is important to design components which could be tested and debugged together, as in a monolith, but can be deployed as multiple  right sized  services to different threads, JVMs, or machines. https://vanilla-java.github.io/2016/05/17/Modelling-Microservice-Patterns-in-Code.html

Simple Asynchronous Microservices using Lambda Architecture

Lambda Architecture Lambda Architecture is a simple, powerful though limited example of a Microservice. As it is so simple, you want to use it as much as possible, to expose the more complex services/component in your system which cannot support this interaction model. Lambda Architecture   depends on a data model with an append-only, immutable data source that serves as a system of record. It is intended for ingesting and processing timestamped events that are appended to existing events rather than overwriting them. State is determined from the natural time-based ordering of the data. To read more  https://vanilla-java.github.io/2016/05/16/Simple-Asynchronous-Microservices-using-Lambda-Architecture.html

Microservices are about applying a group of Best Practices

Microservices Denial A number of times clients have said; they can’t imagine their organisation using Microservices. I found this surprising as I know those people are using many of the principles of Microservices already. I can understand that they feel no need to join the hype around microservices, but the reality is, like it or not, you are most likely using some of the best practices Microservices advocates. Stages of denial It all seems like hype, we don’t go in for that. Perhaps not all hype, but does it really mean anything. It all sounds pretty familiar. It sounds like what we are doing already. Formally or informally, most likely you have been following some best practices already. Adopting Best Practices. Perhaps you don’t like the name Microservices, and perhaps not all the different things people associate with Microservices are right for your team, your projects. Instead lets consider how do you formalise what you are trying to achi

Bad String abuse

In this Java Puzzler, it has some serious abuse of Strings, but what is going on? https://vanilla-java.github.io/2016/04/21/Bad-String.html

An Interveiw on my talk for Low Latency Microservices at QCon New York

Key Takeaways Learn  lessons on developing low latency microservices with Java. Understand  how you can make asynchronous messaging simplier. Gain  practical advice on handling failure from large scale, low latency JVM based microservice implementations. Abstract In this talk we will look at the differences between micro-services and monolith architectures and their relative benefits and disadvantage. We will look at design patterns which will allow us to utilize these different strategies as a deployment concern without significant changes to the business logic. We will look at how micro-service architecture can be implemented under low latency constraints of 10 - 100 micro-second latencies, in Java in particular, and how these strategies reduce the impact of serializing data and logging. https://qconnewyork.com/ny2016/presentation/low-latency-microservices-java

Turning JDBC into a Micro Service

A deep dive into a low latency microservice We look at a microservice which can run in it’s own JVM, can perform JDBC updates and queries via a persistent queue for in bound request and a queue for results. In previous posts I looked at the theory behind there low latency micro-services so lets have a look at a micro-service which can do something useful. I would consider this a Gateway Service as it interacts with a system which is outside the microservice model. https://vanilla-java.github.io/2016/04/12/A-J-D-B-C-Gateway-Microservice.html

Low latency Microservices

Overview In these articles I look at how we can use micro-services are yet have ease of testing, and low latency performance.  In the last of these I look at restarting a service after a failure. Microservices for Performance Microservices is a buzz word at the moment. Is it really something original or based on established best practices. There are some disadvantages to the way micro-services have been implemented, but can these be solved? Microservices in the Chronicle World - Part 1 At a high level, different Microservices strategies have a lot in common. They subscribe to the same ideals. When it comes to the details of how they are actually implemented, they can vary Microservices in the Chronicle world - Part 2 In this part we look at turning a component into a service.

Micro-services for performance

Microservices is a buzz word at the moment. Is it really something original or based on established best practices. There are some disadvantages to the way micro-services have been implemented, but can these be solved? Read more at  https://vanilla-java.github.io/2016/03/22/Micro-services-for-performance.html

Moving to Github and Asciidoc

This blog is moving to  https://vanilla-java.github.io/ Why move to Asciidoc on HubPress on Gighub from Blogger. I am moving my blog to use Asciidoc on Github.com. This is partially to make it easier to embed code and tables, but mostly because I am tired of fighting blogger to not mess with the content when I edit a posting. Please join me on my new source of content, and if you see any mistakes, please fork my blog and issue a Pull Request. EDIT: It has been noted that HubPress.IO doesn't support an RSS feed yet. For this reason I will be posting an abstract and a link on blogger until this feature is added.

Printing arrays by hacking the JVM.

Overview One the most common gotchas in Java, is knowing how to print arrays.   If an answer on how to print an array get more than 1000 upvotes, you have to wonder if there is a simpler way.  Just about every other popular language has that simpler way, so it's not clear to me why Java still does this. Unlike other JDK classes, arrays don't have a particularly sane toString() as it is inherited from Object. It prints the type and address right? Actually, it doesn't print the address, it just looks as cryptic as one. It prints the internal representation of the type, and the hashCode() of the object.  As all arrays are an Object, they have a hashCode() and a type and a synchronized lock, and every thing else an Object has, but no methods specific to an array. This is why the toString() isn't useful for arrays. What does it look like unhacked? If I run the following program. public class ObjectTest {     boolean[] booleans = {true, false};  

Simple Event Driven design

Overview Developers often ask about the performance or efficiency of a system or their code. What does this really mean? My code is so efficient, only a coding god could understand how it works. My code is really clever but unmaintainable. The next developer will re-write it anyway. My code is really efficient for the machine, but inefficient for the developer. My code is really simple to understand which means the developer is more efficient, and the code is more than fast enough and easy to fix if not. So instead of asking yourself how fast you can make the code and how many clever tricks you can put into it, ask yourself; how simple can I make this and still be more than fast enough? Simple Event processing. For me, the simplest event processing is a method call which doesn't return anything. This is simple to translate into an asynchronous messaging transport e.g. public interface EventProcessor {     void event(MyEventData data);          void eve

How do low latency applications differ for regular applications?

Overview A common question we get is; What makes a low latency application different? What is it like to read? There is a number of considerations in designing a low latency application which distinguish it from other applications. Simplicity is key The best way to make something go faster is to get the application to do less work.  This means; create less garbage, transform data less times, make data the application needs readily available. Note: I say you need the option to do this, but this doesn't mean you have to.  You should use a profiler to guide you as to what sections need optimizing. Simplicity is especially important if you want consistent performance. If you are looking at your 99th percentile (worst 1 in 100) or  99.9th percentile (worst 1 in 1000) you are looking at the time when most things are going wrong at once.  The more complex the system, the more there is to go wrong. If throughput is also important to you, you find that one slow outcome ca

StackOverflow Q&A you should read if you program in Java

Overview There are common questions which come up repeatedly in Java.  Even if you know the answer it is worth getting a more thorough understanding of what is happening in these cases. How do I compare Strings? The more general questions is how do I compare the contents of an Object.  What is surprising when you use Java for the first time is that if you have a variable like String str this is a reference to an object, not the object itself.  This means when you use == you are only comparing references. Java has no syntactic sugar to hide this fact so == only compares references, not the contents of references. If you are in any doubt, Java only has primitives and references for data types up to Java 9 (in Java 10 it might value value types) The only other type is void which is only used as a return type. Is Java Pass by Reference or Pass by Value? How do I compare Strings? Why does 128 == 128 return false but 127 == 127 return true? How do I avoid lots of !