Previously I discussed about the Theory of Bloom Filter and implemented a simple version in Java. Let’s find out how we can implement a Bloom Filter for a distributed production environment.

Image for post
Image for post

We will be using Redis with RedisBloom Module to implement it.

Why Redis?

  1. Checking if value exists or not should be fast. So an in-memory data structure should be the better choice here.
  2. Redis has out of box support for many different data structures including Bloom Filter.

Environment Setup

  1. Redis — We can set up Redis using docker check out the docker-compose file here.
  2. Java 8+
  3. Spring Boot

Github Project for reference —

While working on providing transaction support @ Fabhotels by using multiple transaction gateways, I needed to make sure that —

  1. No Single Payment Gateway is overloaded.
  2. We choose a gateway that is alive for each request.
Image for post
Image for post

How can we solve this problem?

  1. We can load balance by simple round-robin — Use the gateways in a cycle (A > B > C >A). But this will not solve the second issue of avoiding failures.
  2. Use a load balancer with intelligent routing.

What is Ribbon?

Netflix Ribbon is an Inter Process Communication (IPC) cloud library. Ribbon primarily provides client-side load balancing algorithms.

Why Ribbon?

  1. If you are in the Spring eco-system then using Ribbon as a load balancer is surprisingly easy and quick. …

Image for post
Image for post
Source : Cloudflare

A while back, I was working on a task that required me to generate a random unique string and use it as an identifier in a database column and I thought to myself, “It’s a trivial task, will be done in 2 minutes!”.

Rakishly, I began to formulate the code.

String id = createRandomString(6) //length 6while(dbRepository.hasId(id)){
id = createRandomString(6)

“This code will work. But at what cost?”

Time complexity is O(N *M* k), where N is the size of the db and k is the length of the random string to be generated and M is the number of collisions in the DB . …

Postman is a fantastic tool to quickly test your API(s). However, working in a microservice environment with end points being secured via a token system makes testing a PITA.

Image for post
Image for post

Adding a new security token every time the previous one expires slows us down, Here’s how to automate it —


  1. Latest version of Postman
  2. A service that is used by your application for authorization.


  1. Create a collection in Postman
Image for post
Image for post

2 . Go to Pre-request Scripts and add the following script —

Pre-request Script
Image for post
Image for post

3. Save the collection.

4. Create any request in this collection and this request will have the header inserted at run time. …

You have finally created the perfect app. Its sleek, beautiful and fast with all the bells and whistles that you had dreamt of.

Image for post
Image for post

But where are the users?

Image for post
Image for post

Any app, no matter how perfect will fade into oblivion if it doesn’t reach its target audience. We must aim for the inflection point where the app’s popularity will kickstart the positive feedback cycle and it becomes self sustaining.

As an individual developer funds can be tight and walking the well worn path of Ad-Marketing doesn’t seem to bring the best bang for the non-existing buck.

Here’s how I did it.

Disclaimer : These are my observations and the consequent actions over them. Take them with a grain of salt. …

When my foray into Spring-Boot backed Microservices gave HTTP Session an existential crisis, I knew it was time that I should dabble with Spring Sessions.

Image for post
Image for post


You have multiple instances of a microservice behind a load balancer and you need the session to be maintained for the user after successful authorization, regardless of which instance is executing the request.

Probable Solutions

  1. Centralized Sessions — Maintain sessions in a common location for all instances to share.
  2. Consistent Hashing — Load balancer decides which instance to send the request to.

We will focus on Centralized Sessions here.

If the number of concurrent users of your application doesn’t run into a few hundred million then an In-memory data store is a good solution. …


Gaurav Sharma

I like building stuff.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store