Published November 27, 2022 by

Microservices Architecture and Companies getting benefited from Microservices

Nowadays, many companies, such as Netflix, Amazon, and eBay, have migrated their applications and systems to the cloud, because the cloud computing model allows these companies to scale their computing resources as per their usage.

Monolithic vs Microservices

Monolithic architecture is an application with a single code base that includes multiple services. These services communicate with external systems or consumers via different interfaces like Web services, HTML pages, or REST API

Microservices Architecture is an approach to developing a suite of small services working as a single application. The services are communicating through lightweight mechanisms, such as an HTTP resource API and each service is running independently in its own process

Monolithic: Brief

Build an application with a monolithic architecture application with a single code base that includes multiple services.

For example:

  • a single Java WAR file.
  • a single directory hierarchy or NodeJS code




Here, we have designed an e-commerce application with Monolithic Architecture.

We have added the big e-commerce box; those are the components of our e-commerce application: (Modules)

  • Flights
  • Hotels
  • Trains
  • Buses
  • Cabs

As you can see, all modules of this traditional web application are single artifacts in the container.

This monolithic application has a massive codebase that includes all modules that are tightly coupled in a monolith codebase.

→ Simply like, All Program code of modules in one File (.jar).

Once the application becomes huge and the team Clients grow in size, this approach has a number of drawbacks that become increasingly significant



Drawbacks in Monolithic Architecture

  1. Difficult to understand code and Update new features
  2. Slower the Deployment
  3. The scaling of the Application is DIFFICULT.
  4. If any one of the modules (Like Cabs alone, ) gets Clients to hit in massive simultaneously then for scalability, the Entire App needs to be Deployed in the Container
  5. The entire Application needs to develop in the Same programming language for the Whole Application. As it cannot be possible or if any new module needs to create in another Programming language.
  6. Infrastructure development will be difficult
  7. Dependencies cause errors in the entire app if any changes are done in another module. (Fights — —> CoupounCode)
  8. The performance of one module will impact other

Monolithic architecture has many disadvantages, but for building a small application, monolithic architecture is one of the best architectures you can apply to your project.

Microservices

Microservices architecture will ease the Monolith drawbacks processes such as maintainability, reusability, scalability, Dependencies, availability, and automated deployment when it will be utilized, and these are considered the advantages of microservices architecture

So, Now Microservice is like,


Here, It is not a Monolith, as we have Independent services/Modules among them, Some of the Points in Microservices are given below.

Aspects of Microservices

  1. Small in size
  2. Single-responsibility
  3. Loosely coupled
  4. Explicitly published interfaces
  5. Lightweight
  6. Communicating via REST and HTTP
  7. Polyglot set of microservices (written in more than one language)
  8. Better performance in terms of throughput when it is used for a large number of requests
  9. A microservice application that will provide the backend capabilities by exposing the API
  10. The microservices gateway is the frontend of the whole system which will include all the APIs of every microservice application in the system
  11. Microservices governance is decentralized.



General overview of microservices architecture

The main advantages of a microservices architecture are

  1. Microservices can rely on technology heterogeneity, which means each service in one system can use different technology than the other services to achieve the desired goals and performance
  2. If one component of the system fails then it does not affect the whole system.
  3. The process of scaling can be more accessible compared to monolithic application scaling because only the services that need actual scaling are scaled in the microservices architecture, contrary to a monolithic application requires to be scaled as a whole unit which may lead to higher hardware usage
  4. The ease of deployment is because with microservices each service can be deployed independently without affecting the performance of other services.
  5. Microservices architecture helps companies to align their architecture with their organizational structure, which will help them to minimize the number of people that are working on a specific codebase.
  6. Consequently, microservices enable organizational alignment. Further advantages are composability and optimizing for replaceability
  7. Each Module Service is independent of the programming language
  8. In this, the servers can communicate with other module servers.
  9. Distributed Software System.
  10. Fault tolerance.
  11. Communicating via REST and HTTP most widely popularly used, but there are other alternatives to REST, such as RPCs as not many are used currently.
  12. On the other hand, in the monolithic architecture, applications can be created of tens or hundreds of different services that are tightly coupled in a monolith codebase. Here, Each service can be maintained by different Dev teams and can build an efficient APP.



MIcroservice In travel Booking App

Here, we have designed an e-commerce application with Microservice Architecture.

We have added the big e-commerce box; those are the components of our e-commerce application: (Modules)

  • Flights
  • Hotels
  • Trains
  • Buses
  • Cabs

Here, all modules are independent of each other in CodeBase, but they can communicate with each other. (Service to Service Communication)

For Example,

  1. If Flight Module is a more engaging module as a result simultaneous clients will be there, so we can accordingly scale out the containers in that Service/Module alone without creating an entire APP in the new System.
  2. Saves Time, Reliability, Scalability, and Space of the System.
  3. It can communicate with other modules to fetch the data.
  4. Flight Module alone has a Load balancer to manage the simultaneous clients coming to the APP only for that service.

Microservice Trend Over the period




Microservice Trend Over the period

In the mid-2000s, microservices began to appear, and a set of popular frameworks based on microservice architectures were developed, After being used at scale and enhanced for 10 years.

Companies benefited from Microservices

Halodoc: (CaseStudy)



Halodoc, a company, and app allow you to interact with a doctor right from your phone. As there are many people living in rural areas. they have restricted access to healthcare facilities

Halodoc is the No.1 health application in Indonesia

An app that makes it possible for a country of 264 million people,
with 50% internet penetration must have some serious technology behind it. And now I’m going to tell you how it works

As they started launching on new business lines it was obvious to a monolith will not cut it and they had to go the micro-service route as soon as possible.

All services were all these new interactions that your users changed to new microservices in your architecture.

  • Each microservice has a couple of compute instances, backed by assistance, we use the RDS MySQL database.
  • So, one group could be buying medicines online,
  • the second group could be talking to a doctor online.
  • And so on, It has 40 to 50 microservices in production
  • Given that each of these microservices has their own databases
  • The users’ data, As a user, could buy medicines or talk to a doctor, and these belong to different microservices .so used DynamoDB in AWS to save all of the user data.





  • All of these services would use identity quite often having a low latency database, and being able to share that across all these microservices is a big benefit.
  • Also, they use SNS(notification) to alert Dev teams between the microservices call they were having unnecessary tight coupling between our microservices.
  • And more technologies are used behind. to maintain the synchronous
  • They connect 22000+ doctors and 1500 pharmaciesacross 50 cities in Southeast Asia.

Ref: AWS Architecture Blog

eBay



eBay, the world’s biggest online marketplace created a powerful platform for selling goods and services.

Enables trade on a local, national, and international basis with customized sites in markets around the globe, ensuring global e-commerce for an ever-growing online community

They started off with a monolithic Perl application, they had a monolithic C++ application that had up to 3.4 million lines of code in a single DLL.

  • On the large-scale app, they move to a distributed and partitioned system in Java.
  • eBay has quite a lot of Java but also functions on a polyglot set of microservices, that is, they are written in more than one language.
  • The eBay system works with over 1000 microservices. For all types of Devices. (Web, Android, iOS)

Amazon

The Amazon.com website calls about 150 services to fetch the data that makes its webpage.

Netflix

Netflix is doing the same for its applications to be able to scale its services to over 80 million subscribers.

Many Tech Giants make ease of Operations with Microservices as a part of their Design.

FINAL

The Microservice architecture in DevOps practices together with the cloud environment is playing an important role in facilitating the implementation of microservices. We have also identified containerization as an effective method to overcome the hardware limitation besides speeding up the delivery process. Due to their smaller size, they shorten the delivery process and make scaling less challenging On the other hand, to use microservices, a highly automated system with an advanced monitoring capability is required

Microservice should be adopted where APPLICATION in monolithic reaches the point where it becomes hard to maintain or scale it.

The microservice architecture allows to use of different technologies for different services and allows to scale and maintain better, but all this comes with an overhead complexity and requires good expertise

Microservices’ governance is decentralized. and handling millions of requests by designing systems for huge availabilityhigh scalability, and low latency.

THANK YOU !!

Read More
Published October 18, 2022 by

JVM Architecture : Java virtual Machine

A virtual machine is a layer of abstraction that gives a program one simplified interface for interacting with a variety of physical computers and their operating systems.

JVM core

Design Goals of Java

  1. Java must enable the development of secure, high-performance, and highly robust applications on multiple platforms in heterogeneous, distributed networks.
  2. Java must be architecture-neutral, portable, and dynamically adaptable.
  3. Simple, Familiar, Object Oriented, Multithreaded.

Java Environments

A specific environment that comprises all the necessary components, application programming interfaces, and libraries in order to develop, compile, debug and execute its programs.


Java has 2 such environments and everyone working with Java has to start their work after setting up one of these environments on their local development or production environment platforms.

JDK core

  • Local development (For Developers)
    • JDK (Java Development Kit): the complete development environment used for developing and executing Java applications. It includes both JRE and development tools. JDK is meant for programmers
  • Production environment platform. (For Users)
    • JRE (Java Runtime Environment): the minimum environment needed for running a Java application (no support for developing). It includes JVM (Java Virtual Machine) and deployment tools. JRE is meant for users


Why is Java slow?

Dynamic Linking = Unlike C, linking is done at run-time, every time the program is run in Java.

Run-time Interpreter = the conversion of byte code into native machine code is done at run-time in Java which further slows down the speed.

JVM


1. .class file:

Which is Byte Code is converted by the compiler.

Below the example :  . class file for magin number program.


.class file


2. Class Loader Subsystem

It is mainly responsible for three activities


Class Loader Subsystem

Loading:

  • Loads all the Java Libraries, JDK Extensions, and Class Loading from the .class file.

Linking:

  • Does Verification of Is the .class file from the right compiler, file formatted.
  • Do prepare for the memory allocation for variables, class Variables.
  • Does method name calling matching of eight method names , symbolic reference.

Initialization:

  • In this phase, all static variables are assigned with their values defined in the code and static block. class initializing,.


3. RunTime Data Area

MEMORY ALLOCATION for the Complete Program




Method area :In the method area, all class-level information like class name, immediate parent class name, methods and variables information, etc. are stored, including static variables. There is only one method area per JVM, and it is a shared resource.

Heap area : Information of all objects is stored in the heap area. There is also one Heap Area per JVM. It is also a shared resource.

Stack area : For every thread, JVM creates one run-time stack which is stored here. Every block of this stack is called an activation record/stack frame which stores method calls. All local variables of that method are stored in their corresponding frame. After a thread terminates, it’s run-time stack will be destroyed by JVM. It is not a shared resource.

PC Registers: Store address of current execution instruction of a thread. Obviously, each thread has separate PC Registers.

Native method stacks:For every thread, the separate native stack is created. It stores native method information.


4. Execution Engine

Actual Process Execution starts here after all the Verifications, Checks, allocations, and Storage in RAM Temp. are done.

Interpreter: Executes each and every Instruction Line by line in the byte Code.


JIT Compiler: (Just in time) Compile the code fast compilation. As it compiles Unique methods once it could not Compile the same method code again thereby saving TIME. First, it compiles Byte Code to native machine code. The native code is stored in the cache, thus the compiled code can be executed more quicker.

JIT compiler softwares:

  • Oracle Hotspot VMs
  • IBM AOT (Ahead-Of-Time) Compiling

Execution Engine


Garbage Collector: Creates Objects for class by the code and when it is not required it will remove the uncalled objects that remained in the memory.

→ This is done by the Garbage Collector: System.gc()


5. Java Native Interface (JNI)

It Interacts with the Native Library which is required for the execution and loads.This enables JVM to call C/C++ libraries and to be called by C/C++ libraries which may be specific to hardware.

Java Native Interface (JNI)


6. Native Method Libraries

A collection of C/C++ Native Libraries which is required for the Execution Engine and can be accessed through the provided Native Interface.


Native Method Libraries



JVM Pros & Cons

Security: JVM will validate all programming before it is executed, so that not to give any errors from Java code to direct to JVM.

Cross-Platform: JVM allows programs to be written and compiled once, which can be run on wide various systems / OS without modification.

Speed: The Byte Code get from the compiler, as JVM will convert it into Underlying Architecture Machine Code rapidly and executes the instruction. Compared to any other execution time.

Platform-Specific Feature: Java programs usually do not use structures specific to one OS because the Java Virtual Machine must run continuously on a wide variety of computers. In Java Applications “Look & Features” can frequently be different from the operating system that the device comes with, and applications written specifically for that OS.

 

Read More