Micro services oriented architecture

The idea behind micro services oriented applications is to avoid monolithic apps, deployed in an application server, which is often a single and big file. This piece of software tends to grow in size and it becomes unmanageable, requiring every time more and more hardware to accomplish its tasks. Is attacking the concept of mega application server where all the apps are deployed, in favor of each one instancing its own server when is required. The micro services oriented architecture allows us to create components with a specific purpose and use a message broker or event bus to interconnect them. In this way we can decompose our super applications in self meaning components, allowing them to scale in number of instances, whether they need it, avoiding sharing resources.

monolithic application versus micro services architecture

Vert.x is a tool-kit for building reactive applications on the JVM. Its principal points to be highlighted are:

Vert.x is scalable – Vert.x is event driven and non blocking, this means that your application can handle a lot of concurrency using a few kernel threads.

Vert.x es polyglot – You can code in Java, Javascript, Groovy, Ruby and Ceylon.

Vert.x es lightweight – Vert.x core weights 650kB approximately.

Vert.x es fast – Some benchmarks.

Vert.x is not an application server – There is no single monolithic instance of Vert.x where you deploy applications. Run the apps where you want.

Vert.x is modular – When you need more bits, you add the ones you need and nothing more.

Vert.x is simple but not simplistic – Vert.x allow us to create robust applications in a simple way.

Vert.x is an ideal option to build micro services.

Real time applications

Are those applications that require information updates on real time (or near real time). They are based on the server side push concept and differs on client pull technologies, on that the server sends the updates to the client when they are available. There are several technologies/techniques (like websockets, long polling, etc) to accomplish server side push, they depend on the capabilities of the clients (like browsers) as well as application servers. Today many frameworks make the work for us and abstract the complexity of detecting and implementing the fallbacks options when some of the capabilities are not supported on one of the sides, simulating a full duplex connection independently of the utilized protocol. Atmosphere Framework is a good example.

Meteor is a platform to build real time web applications on top of Node.js. It is a full stack client/server that have an own copy of the application database on each side and maintains them synchronized. Allows the developer to abstract from the inherent problems of building real time apps, like latency between the execution of a call from the client to the server and the result.

Meteor is build on top of Node.js so, as you probably know, JavaScript language is executed on the client and server, permitting Meteor to share code between both environments. As a result we get a really powerful platform, simple, that provides to developers an easy and fast way to build real time web apps.

Getting the best of both worlds

As we highlighted in the previous section, Meteor is a really good candidate for implementing real time applications, because information updates, on the client and server, are performed in an instant fashion, using mechanisms/patterns like publish and subscribe, but when trying to implement a micro services oriented system it is not clear how to accomplish it, like how to scale, being flexible in component instantiation, etc. Moreover, many of our services can be components that process and return data without a user interface, just consuming and producing messages. Because of that, here comes Vert.x to rescue us and provide all the mechanisms and tools to create a micro services oriented architecture. To accomplish a full integration between both platforms we can install and use jmusacchio:vertxbus package from Meteor repository. This package permits the use of Vert.x event bus to send and receive messages from a Meteor application (client or server) to applications/components implemented with Vert.x. On the package wiki there are examples of this integration and possible uses.