Using ZeroMQ with Docker

ZeroMQ, Node.js and Docker

Last time we built three client-server Node.js apps that were talking to each other using ZeroMQ. However, running both client and server on localhost is a little bit lame. Let’s put them into containers! They’ll still be lame, but now with Docker around.

So, here’s the plan: let’s see what we need to do to last week’s fire-and-forget ZeroMQ app, so its client and server can work and communicate from within Docker containers. Continue reading “Using ZeroMQ with Docker”

Inter-service messaging with ZeroMQ and Node.js


ZeroMQ is small, fast and very easy to use messaging library, which works equally well both within the same process and over the network. Despite being written in C++, it has bindings for most of the languages you can come up with. And it’s free. Hurrah!

Working with ZeroMQ resembles working with TCP/UDP sockets. In fact, ZeroMQ endpoints are called sockets. You create one, bind it or connect to certain address, and then magic begins… But let’s see some code first and dive into the details as we go. Continue reading “Inter-service messaging with ZeroMQ and Node.js”

Asynchronous communication with message queue

In previous posts I mentioned ‘microservice communication’ quite often, but never actually explained how exactly that happens.

Because of services isolation, choices of transport are limited and most likely you’ll be using TCP or UDP to talk over the network. But how exactly this will happen depends on what patterns or tools you choose.

Patterns of inter-service communication

There’re two of them: synchronous and asynchronous communication. Continue reading “Asynchronous communication with message queue”

Microservice challenges

learning curvesEverybody talks how good microservices are, but it’s less popular subject what challenges it brings. As any other tool it is good at solving one kind of problems, sucks at others, and comes at a price.

In case you’ve forgotten what microservices are, it’s an application building pattern that sees an application as a set of small independent services, which communicate with each other via some lightweight protocol.

So, Continue reading “Microservice challenges”

Quick intro to docker-compose

What is docker-compose

docker-compose logoLike docker itself allows managing single container, docker-compose makes it easy to control not just one, but all containers that make distributed app. This includes containers, networks, volumes and all related settings.

If you think about it, starting an app that has more than one container is less than trivial task and it gets exponentially harder as you add more or them. Let’s check out simple example: distributed web-application that consists of two containers – one with web content and one with database.

Continue reading “Quick intro to docker-compose”

Communication between Docker containers

Having an app running from within Docker container is fun, that’s for sure. But do you know what would be even more fun? Many apps running from within containers and talking to each other. Imagine that after playing enough with microservices, you finally decided to split some real monolithic web application into:

  1. container, serving static web content, and
  2. container, serving data through some sort of RESTful API.

First container opens 80th port and, while serving html/css/js by himself, talks to the second container when data request comes.

Communicating containers

So idea is simple, but there’s one thing. How exactly those containers will communicate? How do they even find each other?

Continue reading “Communication between Docker containers”

3 ways to dockerize existing Node.js app

Dockerize all the thingsImagine you have Node.js app you would like to run from within Docker container. Maybe you want to check if it still works on ‘another’ machine, or it’s a test run before adopting containers as the way of software delivery. Reasons may vary.

In order to have something tangible, let’s pick hello.js app which prints out ubiquitous ‘Hello World’:

How do we put it into container? Continue reading “3 ways to dockerize existing Node.js app”

Quick intro to Docker

What’s Docker.

dockerOn the surface Docker looks like another virtual machine (VM). Just pick Ubuntu image with hello-world app inside, type docker run ubuntu hello-world  in your terminal of choice, and hello-world will start, thinking it owns a whole machine running Ubuntu.

But Docker is not a VM, manager of VMs, or hypervisor of any kind. Docker is a platform for creating, launching and managing containers. Those looks like VMs, quack like VMs, but are much closer to a fence with a barbwire on top of it. No app can enter, no app can leave. What is bad for humans works great for applications in production environment.

Because Docker doesn’t have to deal with guest operating system and hardware abstraction, it can work with the speed that VMs can only dream of, while doing quite similar job. Continue reading “Quick intro to Docker”

Playing with microservices

Recently I was asked to build a small internal app: dynamic dashboard for one of our projectors, which are hanging all over the office and display some company info onto the walls: customer statistics, server-to-server latency, what tasks are in development, etc. My particular goal was to add release and builds statistics: build duration, failed/unreliable tests and anything else that could motivate us to produce more stable builds.

We store all relevant data in Google BigQuery and the whole task is basically to extract build results from the storage and present it in clear and simple way. Quite trivial. Continue reading “Playing with microservices”