Thursday, November 22, 2018

Microservice Logging: Challenges and Advantages

One of the main developments in software design and delivery in recent years has been a movement of monolithic applications for microservices. One of the critical points that I have seen in several microservice applications is the registry. There are some unique challenges with the microsion log that need to be resolved. In this article, we will see how we can do the registration in a microservice as painless as in a monolith.

What is a microservice?

There are many definitions of microservices out there, but that's the one I like.
Microservices: A high-level software design that favors small and weakly connected services that maintain data autonomy and are independently implantable.
Breaking this up using microinsurance is a high level decision. It is not a standard that applies only to a part of your application, but it must be a global decision. By using microservices, we create several smaller applications with very limited functionality. For example, we can have a service whose responsibility is to act as a container to chat with an external API. 
Services must be weakly connected: there are no direct connections between services or cross-talk between services. Services must have their own data storage solution that is not shared with another service. This means absolutely no integration at the database level! Finally, there should be no dependencies between the services at the time of implementation.Setting limits between services in a microsystem cluster is a difficult problem. There are many ideas around it, but most of them revolve around domain-oriented design.


Different challenges of a monolith

Although there are many advantages in a microservice approach, there are also disadvantages. The monoliths are implemented as a single entity in one or more servers, each of which obtains the same code. This unique implantation is a curse and a blessing. Unique implementations mean that you have fewer moving parts in the creation and deployment pipeline. There are no concerns about data transport between various applications or discovering the limits for these applications. The most important advantage for this article is that the registration in the registry resides in only one location.
The log is a perfect example of a transversal concern: code that needs to cover several modules at different levels of the code base. When we divide our application into silos, the record is also divided into all services.

A single logging technology

 A much discussed benefit of microinsurance is that each service can be written using appropriate technology. A component that does a lot of mathematics may not be as efficient written in JavaScript as in Go. Microservices allow you to select a technology that best suits each component. Generally, each microservice is built by a team specialized in the technology used in that service. Reinforcing a single data logging technology is a challenge to the microservice mentality. However, this is a time when it is justified to go back in academic perfection in favor of pragmatism.

A shared logging implementation for every service

 A single registration technology provides us with a location for the records, regardless of which service originates the registration message. If we are trying to find a network problem, we do not want to have to go through several log files located all over the place to see what services have been affected. Ideally, we want to have a one-stop-shop that allows searching, classifying and designing registration information for several dozens of services. The technologies that allow this, registry aggregators, tend to have connectors for several languages. For example, Stackify Retrace has connectors for Java, .NET, PHP, Ruby and Node.js out of the box, as well as a Restful API that unlocks almost all other languages.
The errors can cover several microservices, so the registry as our best tool to track errors must also cover them.

A logging technology which allows queries

 A single user interaction in a microsystem architecture can encompass many services. Being able to accompany a user interaction is much easier if you have a registration tool that allows you to use an advanced query language to search, design and add. The registration in aggregate can also be very useful. Queries like this one are super-valuable: "what percentage of requests for X service results in errors?", Or "what time of day do we see the biggest load on the system", or even "what is the average time that an application spend? in the X service. "
Naturally, there are many registry aggregators out there, and choosing one that has an advanced query language is a good differential. Another aspect to consider is how easy it is to see the data after writing a query for them. A good chart will give you background information that are difficult to analyze from a record message.
Next, there is an example of a Retrace panel showing several important metrics, some of which are extracted from record searches.

Interested in learning Java? Join now:” java training in chennai “

Use a correlation identifier

When a client contacts you with a problem you had in your application, it is very good to be able to quickly find what has gone wrong. One method to do this in a micro security application is to include a correlation or transaction ID in each message. Fill this field with an ID removed from the initial event. Consider a scenario in which a user creates an account. This can trigger actions in the user's service, in the customer loyalty service and in the billing service.

By having a unique identifier that is disconnected by each of these services while processing a message, it is easy to find the creation flow of the user. All that is needed is to pop the unique identifier in the search engine of the record aggregator and get all the registration messages related to that transaction. You can even present the user with that correlation ID, if something goes wrong, so you have a reference number to quote when talking to your support organization; This is even more useful if you are the support organization.
Interested in learning Java? Join now:” java training in bangalore

Include a lot of information
It is much more common that you want to have more information recorded than less. Obviously, there are some performance and storage considerations in relation to over-registration, but very small registration can lose the main information forever. Including context information in your log messages increases the chances that you can track problems. For example, it usually improves my log messages with information such as:

• service name that generates the registration message
• Correlation ID
• username that triggered the action
• machine name or container id
• date of receipt of the message in UTC
• date of sending the message in UTC
• entire body of the drive message

Carefully consider what information would be useful in debugging problems and you would be wrong to include too much. If you are using a registration structure that supports structured registration (which is excellent), you can place all this information in the properties of the logging message and not overload your actual messages.




No comments:

Post a Comment

From Java 8 to Java 11

Switching from Java 8 to Java 11 is more complicated than most updates. Here are some of my notes on the process. Modules Java 9 i...