Zuul and Spring Cloud Gateway – Comparison, Benchmarks, LoadTesting

Spring Cloud Gateway and Zuul are different projects from the Spring community aimed to provide a developer-friendly way of writing Gateway services. While a many of the Spring Cloud users aware of the Zuul project, S-C Gateway is relatively framework which Spring Web Flux (Project Reactor) and the new SpringBoot2. You can refer the question which I asked some time ago in StackOverflow for differences. I have been using Netflix’s Zuul for over two years now and I am so far happy with its performance. I am eagerly waiting to see the much-purported Zuul2 which we can expect anytime. But S-C Gateway intrigued me for two reasons. One, it is coming from the spring community using the latest spring 5, its support for non-blocking APIs, WebSockets, SSEs, etc. Author of S-C Gateway Spencer Gibb has provided a benchmark app if you would like to take a look. Note: The Spring Cloud Gateway used for this test is a pre release version and the post will be updated after the GA. So take results of SC Gateway as a pinch of salt But I wanted to test (stress) the service to its maximum capacity using different embedded web servers and conditions.

Continue reading »

Distributed Tracing using Zipkin and Spring Cloud Sleuth

There is a growing trend in organizations to solve everything with Microservices. For a lot of modern-day applications still, a single node monolith is enough and a better choice. Microservices are not a silver bullet which will solve all our technical problems. It comes with its own baggage which has to be taken into consideration and is neatly explained by Martin Fowler here. Increased operational complexity in using Microservices is certainly an area of concern but it is a solvable problem. In order to handle the operational complexity one of the major concern while doing microservices, we need to get more insights about services, the time taken to complete a request, how they communicate with each other and so on. Importance of tracing in distributed systems have produced a lot of thought process among the development teams and Google’s Dapper paper has influenced one such amazing tracing library called Zipkin. Zipkin library has support for most of the widely used programming languages and is one of the most actively contributed open source projects. I happened to meet Adrian Cole one of the Zipkin’s core contributor who has shed more light on the importance of the tracing even though I have

Continue reading »

Reactive Springboot with Spring Cloud Vault

In the previous post, we saw how we can create reactive Microservices using Spring-boot and Kotlin. I want to write this as a series of articles to address various cross-cutting concerns when we encounter during the implementation of Microservices architecture. In this post, we will see about securing our Microservices using Spring Cloud Security and storing the credentials of the service and MongoDB in the Hashicorp Vault and then retrieve them using Spring Cloud Vault. In addition to providing a secure means of storing the credential and tokens in the vault, it gives us the advantage of dynamically serving them for your Microservices. We will be using the Hashicorp vault for our demo and use the Azure Vault in the next series. To begin with download the vaultproject from here according to you operating system. Create a vault config like below and the additional properties of the vault can be checked here. We are using the in-memory vault so the tokens will be persisted anywhere and disable_mlock prevents the memory being swapped to the disk. It is OK to use it for development/testing. Since I am using a MacOS for development mlock is not supported by the system. backend "inmem"

Continue reading »

Developing reactive microservice using Springboot 2

Reactive Spring is based on the project reactor for building non-blocking applications using the spring platform and spring cloud frameworks. Three important interfaces available in Reactor are Publisher, Subscriber, and Processor. Publisher – source of the data Subscriber – One which receives data asynchronously Processor – nothing but a publisher which is also a subscriber (most of the time we won’t need this) Reactor introduces reactive types which implement the Publisher interface namely Flux and Mono. Flux – represents multiple sequences of a result 0…N (many items) which suggests Flux is a standard publisher Mono – As the name suggests, represents single sequence of a result either an empty result or one result 0…1 which suggests Mono will emit at most one item Starting from Spring 5 and Spring Boot 2 reactive core is completely supported and provides an excellent long-awaited alternative to Akka Streams. If you are coming from a spring background and uses it extensively there is no reason why you shouldn’t try this. However, it is great for people who begin with Spring platform as well. This post is hugely inspired by Josh Long’s webinar on Reactive streams which you can find here. We are going to

Continue reading »

Using Jest for Snapshot testing your React Components

When it comes to testing React components there are plenty of school of thoughts around it. I have been using Airbnb’s Enzyme.js for a while and felt uncomfortable in updating the test specs with ever-changing UI. Then I came across something interesting called Snapshot Testing using Jest. It was also compelling to know that Jest snapshot testing was developed along with the React Developers to make the component testing easier. I do not want to get into a war of words which is better and this post is not intended for it. And the snapshot testing will not replace your unit test, you will still continue to write your unit tests for the business logic. So what Jest does? It creates a serializable react dom tree which can be saved and checked-in along with your code. In later time if you component changes, you can immediately verify whether the change is an intended one or by a mistake. If it is an intended change, you will update the snapshot and check-in the new version otherwise discards the change. Alright, enough theory! Let’s get into some action. I am going to use one the react starter kit library that I have

Continue reading »

How to Dockerize NodeJS web app – part 1

Many teams, companies and companies had a struggle in containerizing their NodeJS web apps. There were many reasons behind it. There are multiple ways to dockerize a NodeJS and we will the some of the efficient ways that worked for me and are running successfully in production. When we were trying to create a docker image for our Node JS based application, we chose to use the official Node docker image (~700MB). On top of that we need to add the node modules, business logic, etc and so on. The final image size was staggering (~1.2GB). It was not what we wanted. Secondly, the average build time to do NPM install and run a grunt task totally took 15 minutes for every build. I am not even talking about the pain of configuring this for different CI/CD pipelines and environments. The initial docker file was looking something like this: #Initial Docker File FROM node:6.10.1-alpine ENV APP_ENV $APP_ENV ENV BINPATH /usr/bin COPY wkhtmltox/bin/wkhtmltopdf /usr/local/bin/ RUN mkdir -p /usr/src/app WORKDIR /usr/src/app/ # Install app dependencies COPY package.json /usr/src/app/ #COPY start.sh /usr/src/app/ RUN npm install –production RUN npm install -g grunt-cli@1.2.0 # Bundle app source COPY . /usr/src/app # Install pm2 so we

Continue reading »