3. What are microservices?
Microservice is a software development technique that structures an application as a collection of loosely
coupled services.
● Each Services :
○ is relatively small, easier to understand and loose coupling.
○ serves a single purpose and can be developed independently by different teams.
○ can be deployed and scaled independently.
● Decomposition of Applications.
● Highly Observable
9. Service Mesh
● Why service mesh is required for microservice architecture.
● Service Mesh
○ A service mesh is a dedicated infrastructure layer for handling
service-to-service communication.
● How service mesh works
● Sidecar
● Service mesh features.
○ Routing
○ Load Balancing
○ Fault Injection
○ Circuit Breaker
○ Service Discovery
○ Rate Limiting
○ Transparent mutual TLS
○ Metrics, Tracing
● Benefits of service mesh
● Examples of service mesh.
○ Istio
○ Linkerd
service mesh
10. Sidecar
★ Sidecar is a way to run alongside your service as a second process. The role of the
sidecar is to augment and improve the application container, often without the
application container’s knowledge.
★ sidecar is a pattern of “Single-node, multi container application”.
★ This pattern is particularly useful when using kubernetes as container orchestration
platform. Kubernetes uses pods. A pod is composed of one or more application
containers. A sidecar is a utility container in the pod and its purpose is to support the
main container. It is important to note that standalone sidecar does not serve any
purpose, it must be paired with one or more main containers. Generally, sidecar
container is reusable and can be paired with numerous type of main containers.
11. Istio
Overview
Istio is a kind of service mesh which supports all the features which has been
explained in service mesh without changing the actual service code and this will
be deployed along side with the service.
Architecture
❖ The data plane is composed of a set of intelligent proxies (Envoy)
deployed as sidecars.
❖ These proxies mediate and control all network communication between
microservices along with Mixer, a general-purpose policy and telemetry
hub.
❖ The control plane manages and configures the proxies to route traffic.
Additionally, the control plane configures Mixers to enforce policies and
collect telemetry.
Supported Platform
12. Linkerd
Overview
Linkerd is a service mesh and it makes running your service
easier and safer by giving you runtime debugging,
observability and security without changing your code.
Architecture
Basic components of linkerd are
❖ UI(Command line and web based)
❖ Data Plane
❖ Control Plane
Supported Platform
15. Alibaba Dubbo
Dubbo is a high-performance, light weight, java based RPC framework. Dubbo offers three key
functionalities, which include interface based remote call, fault tolerance & load balancing, and
automatic service registration & discovery.
16. Dubbo: Features
● Transparent interface based RPC
● Intelligent load balancing
● Automatic service registration and discovery
● High extensibility
● Runtime traffic routing
● Visualized service governance
17. Implementation of sample code
dubbo-demo-api: the common
service api
package org.apache.dubbo.demo;
public interface DemoService {
String sayHello(String name);
}
dubbo-demo-provider: the demo provider
codes
package org.apache.dubbo.demo.provider;
import
org.apache.dubbo.demo.DemoService;
public class DemoServiceImpl
implements DemoService {
public String sayHello(String name) {
return "Hello " + name;
}
}
Consumer.java [3]
:
import
org.springframework.context.support.ClassPathXmlApplicationContext;
import org.apache.dubbo.demo.DemoService;
public class Consumer {
public static void main(String[] args) throws Exception {
ClassPathXmlApplicationContext context = new
ClassPathXmlApplicationContext(new String[]
{"META-INF/spring/dubbo-demo-consumer.xml"});
context.start();
// Obtaining a remote service proxy
DemoService demoService =
(DemoService)context.getBean("demoService");
// Executing remote methods
dubbo-demo-Consumer: the
demo Consumer codes
21. Service-Center
● Restful based Service-Registry.
● Service discovery and Management.
● Event driven data management, notify-subscription.
● Fault Tolerance and Resilient.
● Stateless service and scalable by design.
● High performance cache design.
● Out of box support for metrics and tracing.
● Web Portal to manage the microservices.
23. Restful Open API Format
● All the functionalities of Service-Center are API Driven and is properly
documented.
● Anyone can use these api’s to develop their own SDK.
24. Service Registration
Service-Center
Consumer/Client
Provider/Server
Registers the information of self services
and instance to Service-Center
/register
Sends the HeartBeat at regular interval
to Service-Center updating the status of
the Service /heartbeat
"services": [
{
"serviceId": "4c0b4ab68a7011e8a5b50242ac110002",
"appId": "default",
"serviceName": "Consumer",
"instance": [ "endpoints" :["rest://192.168.42.252:9999"]: ]
},
{
"serviceId": "466927088a7011e8a5b50242ac110002",
"appId": "default",
"serviceName": "Provider",
"instance": [“endpoints" :["rest://192.168.42.252:9999"]: ]
}
]
26. High Performance Cache Design and Scalable
● Stateless service, all the state is saved in etcd.
● Provision clusters on any infrastructure.
● Cache is maintained to store all the snapshot of the services and listen to any
data change event.
● Provides api to do self-discovery of all the instances of Service-Center in the
env.
27. Metrics and Tracing
● Support metrics in Prometheus format and Grafana.
● Exposes tracing information to Zipkin.
28. Security
● Different entity management for dynamic and static data and data can be
isolated on all levels.
● It provides Rules for Service Discovery using BlackList and WhiteList.
● It has support for authentication of API’s by IAM
33. Go-Chassis
Microservice framework for Go Developer for developing distributed Go
Application.
Supports complete set of functionality like route management, circuit breaker, load
balancing, monitoring, tracing etc
Go-chassis is flexible
Support istio platform
36. Go-Chassis : Load Balancing
Random
Round Robin
Weighted Response
Session Stickiness
37. Go-Chassis: Rate Limiting
Limit the request frequency of the provider or consumer
1. Provider side can limit the frequency of receiving processing requests
2. Consumer side can limit the frequency of requests sent to the specified micro
service
39. Mesher
Overview
★ Mesher is a service mesh implementation based on go chassis.
★ It is a proxy to connect, manage and secure microservices.
★ Mesher provides an easy way to create a network of deployed services with load
balancing, service-to-service authentication, monitoring, circuit-breaker, rate limit etc..
without any changes in the service code.
★ Add mesher service by deploying a special sidecar proxy throughout your environment
that intercepts all network communication between microservice.
Deployment of mesher
❖ Manual sidecar injector
❖ Automatic sidecar injector
Way of calling to a service which uses mesher as a service mesh
curl http://service_name:port
curl http://service_name
Supported platform
40. Manual Sidecar Injector
★ In manual sidecar injector user has to provide the
information of service mesh while writing the
deployment file for service.
Automatic Sidecar Injector
❖ In Automatic sidecar injector user has no worry to
take care of adding service mesh information
framework itself will do the work.
43. Java Chassis
Apache ServiceComb (incubating) Java Chassis is a Software Development Kit (SDK) for rapid development of
microservices in Java, providing service registration, service discovery, dynamic routing, and service management features
44. Java Chassis: Sample service definition file
A service definition identifies a microservice. It defines the service name, version, and the application that the service
belongs to. The service definition can also contain extended information defining the attribute metadata of a service. This
service should be present each and every microservice.
APPLICATION_ID: helloTest #Application name
service_description: #Service description
name: helloServer #Microservice name
version: 0.0.1 #Service version
properties: #Metadata
allowCrossApp: false
service_description:
name: jaxrs
version: 0.0.2
servicecomb:
service:
registry:
address: http://127.0.0.1:30100
rest:
address: 0.0.0.0:8080
highway:
address: 0.0.0.0:7070
handler:
chain:
Provider:
default: bizkeeper-provider
Consumer:
default: bizkeeper-consumer,loadbalance
46. Saga: Data consistency framework
Data consistency is a critical aspect of many systems, especially in cloud and microservice environment.
Apache ServiceComb (incubating) Saga is an eventually data consistency solution for micro-service applications.
Architecture
Saga Pack is composed of alpha and omega.
● The alpha plays as the coordinator. It is
responsible for the management of
transactions.
● The omega plays as an agent inside the
micro-service. It intercepts
incoming/outgoing requests and reports
transaction events to alpha.
47. Saga: Use case
This demo shows you how to use the Saga solution
provided by ServiceComb to ensure the microservice for
data consistency.
With microservice architecture, each of the services may
have its own database technology and it’s not feasible to
ensure all transactions on these services are either
committed or rolled back with database. In this demo,
we make use of Saga to ensure eventual data consistency
among services, the payment is only executed after car
rental, flight booking, and hotel-reservation are
complete.
54. Java Chassis: Sample application preparation flow
Step 1 Import dependencies into your maven project:
Step 2 Implement the services. Spring MVC is used to describe the development of service code. The implementation of
the Hello service is as follow:
@RestSchema(schemaId = "springmvcHello")
public class SpringmvcHelloImpl {
@RequestMapping(path = "/sayhello", method = RequestMethod.POST)
public String sayHello(@RequestBody Person person) {
return "Hello person " + person.getName();
}
Step 3 Add service definition file:
Add microservice.yaml file into resources folder of your project.
Step 4 Add Main class:
import org.apache.servicecomb.foundation.common.utils.BeanUtils;
import org.apache.servicecomb.foundation.common.utils.Log4jUtils;
public class Application {
public static void main(String[] args) throws Exception {
//initializing log, loading bean(including its parameters), and registering service, more detail can be found here :
http://servicecomb.incubator.apache.org/users/application-boot-process/
Log4jUtils.init();
BeanUtils.init();
59. Integrate Frontend App with Mesher
Step 1 Write a simple HTML body to display items and its price with a checkbox
Step 2 Trigger a GET request to catalog service to get items and it’s price. Then process those input and display using
HTML Code block written above.
60. Integrate Frontend App with Mesher
Step 3 Then trigger a GET request to payment service with total price of selected items and print the response.