Microservice through my lens (Part2)


Have you finally taken a leap of faith and resolved to adopt the microservices architecture? Hopefully, it is for the best. The other out-dated solution architecture might have been compromising the performance, security, and customer satisfaction of your applications, website or mobile app.

However, as you will delve deeper in the microservices world, you will face certain hiccups. Thankfully, a number of design patterns and best practices have been introduced in the software community that can help you to tackle these challenges and move forward with your application.

API Gateway

While using the micro-services architecture, often the client-side has to face a certain issue. The problem stems from the client’s inability to gain access to different services. Through applying the API gateway pattern, client-side is provided with a single access point.

This point acts as a center from which it can interact with other services of the application. Sometimes, the API will send a request from the client to its suitable receiver while other times, more than a single service will receive the request. As a result, the client-side does not need to fall into the complexities about how different microservices have been split up by the application.

Service Registry

Often microservices in an application struggle to locate the free instances of the services. In this case, the service registry can be helpful. Service registry can be basically considered as a DB for all of your services.

It holds the instances of the services which are registered and de-registered on each startup and shutdown. Hence, clients can search for any available or free instance through the service registry. However, there are few problems that are related to the pattern.

One of them is that it needs constant configuration and management. In case a service registry falters, crucial data can be lost. Hence, it has to be ensured that the service registry is always available for use by the application.

Circuit Breaker

In a microservices application, services often have to communicate and execute tasks together. A service can receive a request for which it has to call another service for action. However, the summoned service can sometimes be unavailable due to an issue. In such a predicament, valuable resources can be wasted and the actual service that was called will not be able to process other incoming requests. As a result, one service’s failure incurs a significant loss to the entire application’s resources.

In such events, ‘circuit breaker’ is the need of the hour. It is a remote service that listens to the communication between two services. If a service fails to respond after a certain limit, then the circuit breaker will trip. The summoned service cannot communicate any further during the timeout interval. After the interval, few requests can be accepted by the circuit breaker to see if the service has regained its working. In case the service is working, the communication will be restored. However, a timeout interval will follow if the called service is still unavailable.

DB per Service

Let’s suppose you are working with an e-commerce application. For the order of products, you have an ‘Order’ service while for payment, there is a ‘payment’ service. Since the majority of the services require data to be stored, how will you manage your data storage of services? Since it is a microservices application, you cannot use a single DB. Instead, you can link each microservices’ API with its own DB.

As a result, each service will be able to keep its data confidential. You can also try to use separate tables, schemas and DB servers for your services. With every service having a dedicated DB, one of the primary requirements for microservices architecture, loose coupling, is achieved. Additionally, each service will be able to use a DB according to its needs.

Health Check API

Often, a service instance is running fine but it is unable to process requests. This can happen if the DB connections are not available. For this scenario, a monitoring mechanism is required that can serve as a warning tool. Hence, in order to alert about a running service that is facing difficulty in processing requests, we can use health check API. As the name suggests, it is used to examine and alert about the health of a microservice. The API will examine things like application-specific logic, disk space, connection status etc. However, it must be noted that a service instance can still falter in the middle of a health check and thus the pattern should not be considered to deliver 100% success.

Messaging

For handling and processing the requests from the clients as well as working together with other microservices, a standard communication mechanism is required that can enhance the performance of the application through effective communication. For this purpose, the asynchronous message can be the solution to your problems. It helps in inter-service communication through which microservices are able to pass all types of messages to each other. Kafka and RabbitMQ are one of the most popular messaging tools available. Due to the message broker mechanism, requests are handled better and do not get lost. However, the message broker has to be available 24/7 while the client will also need to know the message broker’s address.

Log Aggregation

While dealing with a large application that is built on microservices architecture, you will have to deal with a number of instances spawning from each service. There would be a continuous stream of requests that have to be handled by all the instances. These instances produce information about their workings to a log file.

The log file will entail debug, warnings, errors and other information. Hence, in order to increase the understanding of an application’s complete behavior, a logging service can be used that is based on the centralized model. The service will help to accumulate the log data from all the instances of services. As a result, IT professionals can find and understand these logs and apply configuration for alerts so any important message can be displayed on a priority basis.

Best Java Web Frameworks


Java is easily the most popular language of the last two decades. Due to its wide range of features, including the cross-platform compatibility, strong community, an extensive list of libraries, and high security, it has been the first and foremost option for the developers in coding business and enterprise systems for both the public and private sector.

However, earlier Java web development used to be too complex as the ecosystem and tools were confusing for many coders. As a result, many developers had to scratch their heads while reading through hundreds of pages of official documentation for the software bugs that can even originate from a single line code in a class. Luckily, today Java’s ecosystem has been bolstered by the arrival of several frameworks that has made programming on the web for Java easier, and Java no longer bears the tag of the most difficult language for the web. Some of these frameworks are the following.

Spring

Spring was and still is one of the most popular web frameworks in Java. Spring is a light-weight framework as Spring uses various technologies like Hibernate, Tapestry, etc.   Thus, it thus can be implemented for a wide segment of web applications. Spring employs a software engineering concept known as dependency injection through the use of either a construction injection or setter injection. Through Spring’s container, the hard coupling of Java objects is reduced. Moreover, another programming framework called the Aspect Oriented Programming is used in Spring. This focuses on the modularization of concerns, making it easier to deal with middleware development.

Spring helps greatly in the elimination of presentation and business logic and minimizes the previously existed complexities that existed with the J2EE frameworks. Spring is flexible and assists coders with the elimination of a framework-specific base class. With the addition of Model View Architecture, it allows data binding and efficient management of data models.

JSF (Java Server Faces)

One of the biggest problems with a web back-end project is not only the design and development. For enterprises, continuous updates and maintenance are a frequent requirement. However, with JSF corporate developers can easily maintain their code with the support of modern software architectures. With a JSF web application, you can map component-specific event handling with HTTP requests while the server can also be used to treat the components as stateful objects. Java Server Faces eases back-end development through the introduction of an approach that centers on components, which helps in the coding of the web UIs. This is made possible due to JSF’s Facelets that help in the design of the views in web projects with the integration of HTML. Moreover, JSF has in-built support for AJAX.

JSF is chosen by developers for enterprise systems as they are handy for corporate development. For beginners, the drag-and-drop feature will facilitate the design of sleek and elegant user interfaces. For senior developers, the JSF API provides high customization.

Play 2

If you desire a speedy framework without any compromise on the scalability, then Play Framework 2 is a good option. This means that you can edit your code and refresh it to see instant results. Moreover, with support for non-blocking I/0, the performance of an application is highly improved through remote calls in parallel.

Unlike the previous Java web frameworks’, Play rescues developers from the complexity of Servlets and provides modern components of web development frameworks including REST, JSON, NoSQL, and ORM. Furthermore, due to its support for JVM, developers who have to transition from Java to Scala find it convenient due to the community and libraries support.  Additionally, with its integration with front-end technology like CoffeeScript and Less, it has received considerable praise for being one of the most promising new Java frameworks in the last few years.

Google Web Toolkit (GWT)

Are you a full stack web developer working with React and Vue JS? Or do you focus solely on the back-end logic?

For full stack developers, Google Web Toolkit provides a great advantage for design and development of both front-end and back-end development. GWT was released in 2006 by Google for its own use. Seven years later, Google made it open source and it gained popularity quickly due to Google’s extensive documentation and support for the framework for a variety of development environments and technologies.

Its platform advantages include generating JavaScript, compatibility with all the popular web browsers, as well as coding advantages like refactoring, syntax highlighting, and a dynamic UI component library. Thus, if you are incorporating front-end controls like a radio button or a checkbox in your project and are linking it with the back-end in Java code, GWT serves as a leading option for full stack development.

Grails

If you are familiar with the JVM ecosystem and write code in Groovy, then Grails can provide an easier learning curve for a shift in Java web development. Grails also has an extensive support for Java libraries and boasts availability of 700+ plugins. Grails also employ the modern day programming ideology of ‘convention over configuration’, limiting the lines of code.

Moreover, if the requirement of CRUD functionalities is a recurrent theme in your development then Grails’ Scaffolding makes it a breeze. Furthermore, if you are also involved in the Search Engine Optimization of your website, then the websites developed on Grails are easy to optimize for better search engine results. Additionally, with Grails’ GORM, developers have an access to a reliable data tool for linking with relational databases and NoSQL, including MongoFB.

With such powerful tools at your disposal, web development in Java has never been easier. If you have a wide range of web projects, then Spring MVC is the go-to option, while JSF can assist in the upgrade and maintenance of enterprise systems. If you require a framework for full stack development for working with both the front-end and back-end and also require sufficient documentation, then Google Web Toolkit is quite powerful, while for a stateless and non-blocking project, Play 2 can be the best solution.

What Is NoSQL? How Is It Different Than the Traditional Databases and What Are the Types of NoSQL Databases?


As the computers progressed through different stages, computer scientists realized that the real-life information of humans could be stored through a digital solution called database. With the rising processing and storage demand, pen and paper were not enough to handle the requirements of mankind. As a result, relational databases made an entry in the 1970s. All the information was saved on the databases through a query language called SQL (Structured Query Language).

Relational databases were a massive hit, and businesses of all scales began designing schemas, relations, and database designs to manage their clients and customer bases. However, data continued increasing at a rapid pace.

As more technologies emerged and the web and mobile platforms accelerated, discussions were held about the feasibility of relational databases in today’s world. Similarly, the ability of DBMS systems to handle a massive number database request was also part of the discussion where real-time interactions like those of social media platforms have increased the data requirements.

What Is NoSQL?

NoSQL stands for ‘Not Only SQL’. NoSQL database is an approach where the traditional concepts of database management systems are not followed. NoSQL databases are required when enterprise systems have issues related to the performance and scalability of their application.

NoSQL has been especially deemed suitable and fit for the requirements of modern day web applications where it is a part of the MEAN (MongoDB Express Angular Node JS) and MERN (MongoDB Express Angular Node JS) technology stacks. These web development stacks have been insanely popular in the recent years where the NoSQL database models are either slowly used as an additional tool or are used to completely replace the RDBMS systems.

Types of NoSQL Databases

There are four key types of NoSQL databases that store information in different ways.

Key-Value Data Store

In key-value DBs, data is stored through a distinct series of key-value pairs, which is similar to the concept of dictionaries. This means that a key can only be linked with a single value of a collection. As a result, the simplicity of the application is increased as a simple query that can generate the required result with a key-value data store.

Additionally, it also negates the need of a query language like SQL. Now the question arises, when should you use the key-value data store? Well, if you have are developing a social media platform, then you can save the profiles of the users through key-value data store.

Similarly, if you are managing a blog, then the comments of your fan following can be stored through a key-value data store. Social media platforms like Twitter and Pinterest are already using key-value data store for their newsfeeds and user profiles.

See the following example where our key is a list of countries that have cities as their values.

Key Value
USA {“New York, San Diego, Seattle”}
India {“Mumbai, Chennai, Delhi“}
Canada {“Toronto, Vancouver, Montreal”}

Example of KeyValue store

These are Key-value store options.

 AerospikeApache IgniteArangoDBBerkeley DBCouchbaseDynamo,  FoundationDBInfinityDBMemcacheDBMUMPSOracle NoSQL DatabaseOrientDBRedisRiakSciDB,  ZooKeeper

Column Store

Traditional DBMS always store and process data horizontally using rows. However, the rows are not stored together in the disk and, thus, accessing different rows can be slow for the database retrieval purposes.

In the case of a column store, the horizontal concept of storing and retrieving data is completely changed. Instead, a new approach has been designed where data can be stored in columns. These columns are combined together into column families. A column family can have countless columns that may either have to be generated at the runtime or at the time of specifying a schema. Column store is useful because the disk saves the column data continuously, which makes searching and accessing data for retrieval purposes easier and faster.

Column DBs is used by Spotify to manage the metadata related information of the music industry. Facebook also uses Column stores for searching mechanisms and personalization.

Example of Column store

These are Column options.

 AccumuloCassandraDruidHBaseVertica.

 

Document Store

In a document store DB, different data formats can be saved. These include the common JSON (JavasScript Object Notation), XML (Extensible Markup Language) or BSON (Binary Encoding of the JSON) data.

Hence, the document store provides a level of flexibility that was previously unimaginable with the relational database approach. It is similar to the key-value store in its storage mechanism of key-value pairs, but here all the values are called ‘documents’.

Additionally, the values also have encoding and structure related information. For example, see the following instance where our values are stored in the form of a document. All of the following instances are related to the address of offices. However, you can see how they can be represented in different formats.

 

{officeName:”ABC 1”,

{Street: “B-329, City:”Mumbai”, Pincode:”806923”}

}

{officeName:”ABC 2”,

{ Block:”A, 2nd Floor”, City: “Chennai”, Pincode: 400452”}

}

{officeName:”ABC 3”,

{Latitude:”60.257314”, Longitude:”-80.495292”}

}

We can also query our searches through the details of the data in the document. For instance, in the above example, we can use the city ‘Mumbai’ for all the data related to the “ABC offices”.

The popular gaming franchise SEGA utilizes the document store approach through MongoDB for its management of more than 10 million gaming accounts. Similarly, the real-time weather functionalities in Android and iOS are provided through the document store model.

Example of Document store

These are document store option

Apache CouchDBArangoDBBaseXClusterpointCouchbaseCosmos DBIBM DominoMarkLogicMongoDBOrientDBQizxRethinkDB

Graph Database

As the name suggests, graph databases use a graphical representation. Like the CS algorithm of the graph, there are nodes, edges, and other related components in graph databases. A graph database is useful to tackle the scalability issues of the applications. In graph databases, entities are represented by the nodes, while the association is linked through relationships. Each node contains records of relationships. For example, suppose a social media network where users know each other.

 

graphdb

Example of Column store

These are Key-value store options.

 AllegroGraphArangoDBInfiniteGraphApache GiraphMarkLogicNeo4JOrientDBVirtuoso

Final Thoughts

With the rising application development needs and demands, NoSQL databases serve as an excellent solution. Whether you are managing an e-commerce store or you are intending to create the next big app, the traditional databases may not always fulfill your needs. With the help of a NoSQL database, you can get an instant performance boost, and your applications will be able to handle requests with enhanced optimization.