Micro services Architecture

The software development evolution has seen many best practices and design patterns. To develop software services, easy development and deployments. The processes and patterns have taken twist and turns due to changing technologies which can enable rapid development and deployment of the services to the end customers.

The evolution has brought integration needs. For various technologies to talk to each or various heterogeneous application needs to share data or access data for various processing needs. To have better communication among systems and real time data to the end customers and providing rapid services it's essential that data is shared in unified formats.

Modular programming is a software design technique that emphasizes separating the functionality of a program into independent, interchangeable modules, such that each contains everything necessary to execute only one aspect of the desired functionality.

Contract first approach brought the concept of "Web Services" wrapped around the business services to share data or across various systems.

The term Web service (WS) is either:

(generic) a service offered by an electronic device to another electronic device, communicating with each other via the World Wide Web, or

(specific) a Web service is a server running on a computer device, listening for requests at a particular port over a network, serving web documents (HTML, JSON, XML, Images), and creating web applications services, which serve in solving specific domain problems over the web (www, internet, HTTP)

The traditional web services supported SOAP based headers and body to share data. SOAP ( Simple Object Access Protocol) is a message protocol that allows distributed elements of an application to communicate. SOAP can be carried over a variety of lower-level protocols, including the web-related Hypertext Transfer Protocol (HTTP).  It uses XML Information Set for its message format, and relies on application layer protocols, most often Hypertext Transfer Protocol (HTTP), although some legacy systems communicate over Simple Mail Transfer Protocol (SMTP), for message negotiation and transmission.

SOAP allows developers to invoke processes running on disparate operating systems (such as Windows, macOS, and Linux) to authenticate, authorize, and communicate using Extensible Markup Language (XML). Since Web protocols like HTTP are installed and running on all operating systems, SOAP allows clients to invoke web services and receive responses independent of language and platforms. The contracts are shared via WSDL ( Web Services Definition Language)

Advantages

SOAP can also be used over SMTP, JMS and message queues.SOAP, when combined with HTTP post/response exchanges, tunnels easily through existing firewalls and proxies, and consequently doesn't require modifying the widespread computing and communication infrastructures that exist for processing HTTP post/response exchanges.

Disadvantages

When using standard implementation and the default SOAP/HTTP binding, the XML infoset is serialized as XML. To improve performance for the special case of XML with embedded binary objects, the Message Transmission Optimization Mechanism was introduced.

When relying on HTTP as a transport protocol and not using Web Services Addressing or an Enterprise Service Bus, the roles of the interacting parties are fixed. Only one party (the client) can use the services of the other.

During the course many vendors came up lots of products and various cutting edge technologies to enable the patterns. Almost all vendors like Microsoft, IBM, Oracle and other open source technologies supported their products to enable web services communication.

What went wrong?

The related buzzword service-orientation promotes loose coupling between services. SOA separates functions into distinct units, or services, which developers make accessible over a network in order to allow users to combine and reuse them in the production of applications. These services and their corresponding consumers communicate with each other by passing data in a well-defined, shared format, or by coordinating an activity between two or more services. A manifesto was published for service-oriented architecture in October, 2009

Service-oriented architecture (SOA) is a style of software design where services are provided to the other components by application components, through a communication protocol over a network. The basic principles of service-oriented architecture are independent of vendors, products and technologies.

A service is a discrete unit of functionality that can be accessed remotely and acted upon and updated independently, such as retrieving a credit card statement online or weather information. The organizations were open and wants to share their services and offering without letting end consumer know the business logic behind that.

The services are exposed via the http by the providers to the end consumers. The service can be accesses via ABC [Address, Binding, Contract] to the end consumers. The services are made discover able using the UDDI services. The address is the URL where the services is hosted and binding is the transport like http and contract is the schema definition of the service.

Most implementations do incur these overheads, but SOA can be implemented using technologies (for example, Java Business Integration (JBI), Windows Communication Foundation (WCF) and data distribution service (DDS)) that do not depend on remote procedure calls or translation through XML.

What benefit SOA brings

Service abstraction - The services act as black boxes, that is their inner logic is hidden from the consumers.

Service statelessness - Services are stateless, that is either return the requested value or give an exception hence minimizing resource use.

Standardized service contract - Services adhere to a standard communications agreements, as defined collectively by one or more service-description documents within a given set of services.

Service granularity - A principle to ensure services have an adequate size and scope. The functionality provided by the service to the user must be relevant.

an aspect of loose coupling

Pitfalls of SOA and Issues

Stateful services require both the consumer and the provider to share the same consumer-specific context, which is either included in or referenced by messages exchanged between the provider and the consumer.

This constraint has the drawback that it could reduce the overall scalability of the service provider if the service-provider needs to retain the shared context for each consumer. It also increases the coupling between a service provider and a consumer and makes switching service providers more difficult.Ultimately, some critics feel that SOA services are still too constrained by applications they represent

A primary challenge faced by service-oriented architecture is managing of metadata. Environments based on SOA include many services which communicate among each other to perform tasks. Due to the fact that the design may involve multiple services working in conjunction, an Application may generate millions of messages. Further services may belong to different organizations or even competing firms creating a huge trust issue.

Another major problem faced by SOA is the lack of a uniform testing framework. 

What are other event processing patterns

  • Event-driven programming/ Process Driven Messaging Service /Service-oriented architecture /Event-driven SOA
  • Complex event processing / Event stream processing / Event Processing Technical Society
  • Staged event-driven architecture (SEDA)

Event Channels

This is the second logical layer. An event channel is a mechanism of propagating the information collected from an event generator to the event engine or sink. This could be a TCP/IP connection, or any type of an input file (flat, XML format, e-mail, etc.). Several event channels can be opened at the same time. Usually, because the event processing engine has to process them in near real time, the event channels will be read asynchronously. The events are stored in a queue, waiting to be processed later by the event processing engine.

Micro services Architecture

Fine-grained SOA is arguably the “big bang” of microservices. Micro services inherit many behaviors of SOA and present different style of exposing the data via the approach called as "API first approach"

Microservices are a modern interpretation of service-oriented architectures used to build distributed software systems. Services in a microservice architecture are processes that communicate with each other over the network in order to fulfill a goal. These services use technology agnostic protocols, which aid in encapsulating choice of language and frameworks, making their choice a concern internal to the service. Microservices are a new realisation and implementation approach to SOA, which have become popular since 2014 (and after the introduction of DevOps), and which also emphasize continuous deployment and other agile practices.

Microservices - also known as the microservice architecture - is an architectural style that structures an application as a collection of services that are

  • Loosely coupled
  • Independently deployable
  • Organized around business capabilities
  • Owned by a small team
  • Highly maintainable and testable
  • Lightweight container deployment,

The microservice architecture enables the rapid, frequent and reliable delivery of large, complex applications. It also enables an organization to evolve its technology stack.

To many, Netflix is the origin of this style of architecture, and this was their own articulation of the pattern at the beginning. Fine-grained SOA is somewhat self-explanatory (at least, to SOA practitioners); it reduces the issues experienced with SOA, and applies the same principles, but breaks down the design into smaller, more fine-grained pieces. 

Small services are, in fact, what most people still think of as the only microservices pattern. However, along the way, Netflix and others following this path have experienced a number of basic issues with this pattern. When you make things smaller, and attempt to scale them, some difficulties emerge: Where you used to make a single network call, now you must make tens or even hundreds of calls. This is inefficient. 

Where you used to manage a small number of things, now you manage hundreds or thousands or more. Your management tools therefore no longer work as well for you. When tens, hundreds, or thousands of things all can query or modify the state of your central applications, it becomes almost impossible to trust the consistency of that store as accessed through any one of these micro services. 

The overlooked challenges of truly living with micro services include inefficient inter-process communications, overarching monitoring, management, and governance; and consistent state.

Services communicate using either synchronous protocols such as HTTP/REST or asynchronous protocols such as AMQP. Services can be developed and deployed independently of one another. Each service has its own database in order to be decoupled from other services. Data consistency between services is maintained using the Saga pattern

Support light wight and easy writable languages and conversion using JSON [Java Script Object Notation] and YAML [Yet Another Multicolumn Layout] over http. Makes it lighter on level 7 application communication easy. Technically YAML is a superset of JSON. This means that, in theory at least, a YAML parser can understand JSON, but not necessarily the other way around

  • YAML extra features and concise notation makes it a good choice for configuration files (non-user provided files).
  • JSON limited features, wide support, and faster parsing makes it a great choice for interoperability and user provided data

API Gateways

The Microservice architecture pattern creates the need for this pattern.

The API gateway must use either the Client-side Discovery pattern or Server-side Discovery pattern to route requests to available service instances.

The API Gateway may authenticate the user and pass an Access Token containing information about the user to the services

An API Gateway will use a Circuit Breaker to invoke services

An API gateway often implements the API Composition pattern

要查看或添加评论,请登录

社区洞察

其他会员也浏览了