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.

Environment Setup

  1. Redis — We can set up Redis using docker check out the docker-compose file here.

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.
Image for post
Image for post
source: studytonight.com

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.

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 —

Prerequisites

  1. Latest version of Postman

Steps

  1. Create a collection in Postman


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?


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

Problem

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.

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. …

About

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