Service Discovery for Modern Distributed Applications

I am starting a new blog series (with no end date) from today. In this series, I will pick a topic and go in-depth so that I don’t just scratch the surface of the topic. The goal is to build a habit of learning each week and share it with the community. For the next few months, I will write on different aspects of building distributed systems. Each Wednesday, you may expect a new post.

I am sure we all have built applications where one application uses another application to do its job. Most of the time, applications communicate with each other using HTTP REST API but it can be other communication mechanisms like gRPC, Thrift, Message Queues as well. For example, if you are building an application that needs Twitter service for fetching tweets. To call Twitter API, you will need the API URL and access keys to make a successful API call. Most often we rely on static configuration either in the form of a configuration file or environment variable to get the API URL. This approach works fine when you are working with third party APIs like Twitter as their API URLs do not change often. The static configuration approach fails when we build a Microservices architecture based application. The definition of Microservices that I like is by Martin Fowler as described in his blog,

Microservice architecture style is an approach to developing a single application as a suite of small services, each running its own process and communicating with lightweight mechanisms, often an HTTP resource API.

Read More »

On writing

Since last couple of years, writing has fascinated me. I became interested in writing as I started spending more time reading books. I have read more books in last couple of years than I have read in my entire life. Good books make you think, question, and become more self-aware.

Stephen King, an American author of horror, supernatural fiction, suspense, science fiction and fantasy once said

If you don’t have time to read, you don’t have time to write. Simple as that.

I think writing is the natural side effect of reading.

Read More »

The fool’s life is empty….

The fool’s life is empty of gratitude and full of fears; its course lies wholly toward the futureEpicurus

Most of us these days are obsessed with our future. In future we want to be our own boss, we want to run our own company, travel the world, become a millionaire, and so on. We are being sold the dream that life will become meaningful if we become our own boss. What this usually leads to is unsatisfied today. Our blind desires stop us from contributing to our current work in the most complete form. We make compromises in terms of quality and focus in our current jobs. This means we loose out on the training for the better future tomorrow. I think this trend is making us incompetent and we will never be better prepared to make a real difference in future. We should show gratitude and contentment in our existing job. This will give us internal peace and help us prepare for better future tomorrow.

Configuring Spring Cache Manager with AWS ElastiCache Redis (cluster mode disabled) and Lettuce

We have Spring Boot 2 application that uses Redis as the cache manager. We deploy our application on Amazon AWS where we use AWS ElastiCache Redis service in cluster mode disabled. Our setup includes a Redis master with two Redis slaves. The default Java client for Redis with spring-boot-starter-data-redis dependency is lettuce-core. When you are working with single Redis node with no slaves, using AWS Elastic Cache Redis is as simple as providing the spring.redis.url with the value of AWS ElastiCache Redis instance URL. This was the set up that we were using till a month back. As the load on the system increased we decided to use ElastiCache Redis in replicated setup to scale our reads. In AWS, Redis implements replication in two ways:

  1. With a single shard that contains all of the cluster’s data in each node – Redis (cluster mode disabled)
  2. With data partitioned across up to 15 shards — Redis (cluster mode enabled)

In our case, cached data is less than 1 GB so it fits in RAM of single node. This made us choose cluster mode disabled setup.

Read More »