AMQP

AMQP means Advanced Message Queuing Protocol. It is a protocol that is used for communication between two systems, which need to be loosely connected and potentially are heterogeneous.

What is a Message Queue?

When a subsystem (consumer) is dependent on some events occurring in some other subsystem (producer), we need to devise a way for communication between these two subsystems. IPC (Inter process communication) could be one such way, but it requires both the processes (subsystems) to run on same system. This is unlikely in distributed architecture and microservices architecture. As a result a mechanism has been devised where producer will post the events/outcome to a queue. This queue is then read by one ore more consumers. This is referred as Message Queue.

AMQP essentially allows two systems to communicate using Message Queues, but doesn’t put any dependency on the implementation of these systems. One system could be written in a C / C++ and other system could be a Java application. Such heterogeneous systems can comfortably communicate using AMQP. AMQP defines how a message should be constructed and sent over the wire, instead of defining how to implement producer and consumer. It is simply a byte stream across the network. Any consumer conforming to the data format can interpret the message. Hence this is also called as wire-level protocol.

Features of AMQP:

  • Message Orientation
  • Queuing
  • Routing
  • Reliability
  • Security

AMQP implementations allow routing such as point-to-point (one producer – one consumer) or publisher-subscriber model (one or more consumers can subscribe to messages from one or more publishers).

It is often easy to compare JMS (Java Messaging Service) with AMQP. The important difference is that JMS is an API, which defines implementation for producer and consumers, and hence it is tied with Java platform.

AMQP ensures the messages are delivered reliably and acknowledgement is obtained. Hence it forms an important aspect of the communication between producer and consumer.

A compelling example use case of Message Queue would be that of Food delivery ordering system. Typically such systems get loaded during meal hours and can’t afford to loose any orders due to errors. Posting the order data to message queue can ensure every order is processed.

Related Links:

Related Keywords

Software Architecture, AWS SQS, RabbitMQ, Apache Kafka

 

Reverse Proxy

Reverse Proxy is a type of Proxy Server that sits in front of the web server and received the request from internet. It passes on the requests to web server and sends back the response from web server to the clients.

In contrast, Forward Proxy Server or Proxy Server sits in front the the several clients and sends requests to various different websites.

Proxy Server:

Proxy Server, as name suggests, is an authority which represents some other server. It is in use since 1990s, even before NAT Gateways were introduced. Forward Proxy servers have been used in intranet to regulate or monitor the traffic and to optionally filter or  block the traffic as per the company policies. This is similar to Firewall function.

Advantages of Reverse Proxy

There are several advantages of this proxy server.

  • Load Balancing: There could be multiple web servers behind the reverse proxy. In such cases the reverse proxy server would decide where to send the request depending on the load on the web servers. Hence it can act as load balancer.
  • Caching: Optionally, Revers Proxy Server could cache the responses from the web servers (e.g. static contents). This results in reducing the load on the web servers. This is also referred as Web Acceleration.
  • Security: Since Reverse Proxy shields the backend web/app servers, it becomes difficult for hackers to know about the vulnerabilities of real web or app servers.
  • SSL offloading: Reverse Proxy can handle the SSL and open plain text connection with backend web/app server. This reduces the load on the backend servers. Additionally, Reverse Proxy Server can use hardware based SSL accelerators.

But wait, isn’t it similar to API Gateway?

You are right. API Gateway could be treated as special implementation of Reverse Proxy.

Related Links:

Related Keywords:

API Gateway, Software Architecture, Firewall, Forward Proxy Server

API Gateway

API Gateway is a server that is a single entry point to your system. As you can imagine, primary function of this server is provide various API endpoints to various clients. It also hides the backend services from the client.

Why should I use API Gateway?

Consider a complex architecture where variety of clients are accessing your system. In this age, monolithic applications are getting outdated whereas microservices based applications are popular because of their efficiency and maintainability. As a result, all of the clients will need to make several calls to get data from various services from your system. So even to render one page, client will end up making several calls. This would be a problem on mobile network, which typically has latency issues. To add to this complexity, each client could have their own requirements. That could also mean client specific code.

All these problems can be solved by implementing an API Gateway. This server provides single point of reference for all the clients. It detects the client and breaks the request into multiple backend requests to fetch the data. This gives additional benefit of consolidating responses from all the backend requests into single response for the client.

API Gateway simplified diagram
API Gateway [Source: https://www.nginx.com/blog/building-microservices-using-an-api-gateway/]

Are there any drawbacks?

Yes, as is the case with almost everything in life! If due care is not taken, API Gateway itself can become bottleneck and heavy. All developers would be required to update API Gateway whenever they make changes to the endpoints or protocol to access their respective services. API Gateway gathers data from multiple webservices. As a result, failure of even one service could lead to unavailability of entire service. Or it could add delays in response to the client.

However, there are already ways to counter these drawbacks. Proper process such as DevOps could lead to removal of API Gateway becoming developer bottleneck. Usage of circuit-breaker libraries such as Netflix Hystrix could avoid overall service breakdown even in case of partial service outage.

Reference Links:

Example Implementations / Providers:

  • AWS API Gateway
  • Azure API Management
  • Vertx
  • JBoss Apiman

Related Keywords

Microservices Architecture, AWS, Azure, Hystrix

REST

Representational State Transfer or REST is a style of architecture in software and has been very popular in recent times. It allows developers to define web services which could accessed using URI (Uniform Resource Identifiers) and some standard verbs such as GET, PUT, DELETE, POST.

This is a stateless implementation of web services where server doesn’t maintain the state of the operations. However, client can retain the state through the session and same could be passed on by the server to other components, if required. The clients request the URL along with the operation and server sends out the response using a standard and well-defined format.

The client requests each resource using URI and represents the action required on the resource using standard verbs. This results in moving the action from URL to HTTP request method. The response could be XML, JSON or any other defined format.

REST
REST – Source – https://www.slideshare.net/david.krmpotic/rest-david-krmpotic

Characteristics of REST:

  • Client – Server Architecture
  • Statelessness
  • Cacheability
  • Layered System
  • Uniform Interface

Another popular choice in this category is SOAP (Simple Object Access Protocol) which is dependent on XML for request and response. Such protocol turns out to be heavy for several applications and in those cases REST is a right choice. SOAP provides built-in error handling, which makes life easy for developers. REST does not have any defined standard and hence there is no well defined way for built-in error handling. SOAP provides clear definitions of the web service using WSDL (Web Services Description Language), whereas there is no such thing in REST architecture. It is pretty much driven by the implementation team.

Since there is no “official” standard for RESTful web APIs, this is referred as architectural style and not “standard” or “protocol”, unlike SOAP.

Related Keywords

SOAP, Software Architecture

Reference Links:

Microservices Architecture

As the name suggests, Microservices Architecture bundles multiple smaller, independent and clearly scoped services together. One can deploy these services independently and they can interact with each other through well defined APIs. This improves the maintainability and scaling of the overall architecture.

While designing a microservice, one should consider end-to-end business capability as criteria and not size of the service. If this breaking of overall functionality into smaller services is not done correctly, it leads to dependent services. It in turn results in loss of inherent advantages of this architecture.

Advantages of Microservices Architecture:

  • Separate teams can maintain each service separately. This brings faster turn around by the teams as they have very clear and well defined scope and gives them full control over deliverable.
  • It is very easy for developers to make changes to one service without affecting other services as long as the intercommunication protocol is maintained. This gives much required independence to the development teams and brings in accountability to maintain their own work.
  • Only a single service or a set of services could be scaled up if business needs. This avoids a single portion of software becoming a bottleneck as is the case with monolithic architecture.
  • Improved fault tolerance. In case any service fails, others can continue providing rest of the services, resulting in higher availability. e.g. If movie recommendation service fails, streaming service or category browsing service can continue.
Microservices Architecture
Microservices Architecture – Source – http://microservices.io/patterns/microservices.html

Drawbacks:

  • If services depend on each other, they could introduce bottlenecks and thus failure of overall architecture. Services need to use other services and fault tolerance needs to be built-in.
  • Since each service is a separate process, they need to communicate with each other over network, adding to the latency. System architects need to consider this aspect while developing services that need very fast response times.

Reference Links:

Related Keywords:

Monolithic Architecture, Cloud