Professional Documents
Culture Documents
Rest Vs Soap
Rest Vs Soap
Message filtering/routing Policies: Message filtering Batching Policies: Messages can be processed in batches
has to be implemented in the MessageHandler based on batching policies defined.
component of the consumer service. Does not support Scalability: Not very scalable. Would hit performance
routing of message to multiple services implicitly. Each issues due to lock contention on database read/write
message will have to be sent to every other Service operations and too much disk I/O.
that has to consume the message Availability: Using a dynamic service discovery solution to
Routing message to multiple consumers detect service instances being added or going down,
Message Ordering: Consumers pick up messages from would achieve high availability.
the table based on the timestamp of message. This Operational and Financial Cost: Does not incur any
does not result in strict FIFO due to multiple financial cost except the initial effort to design the
consumers. solution; would incur minimal operational burden.
Cross Platform interoperability:
AMQP (Advanced Message Queuing Protocol) is a The AMQP Model at a high level works like this:
standard binary wire level protocol that enables messages are published to exchanges, which are
conforming client applications to communicate with often compared to post offices or mailboxes.
conforming messaging middleware brokers. AMQP Exchanges then distribute message copies
allows cross platform services/systems between to queues using rules called bindings. Then AMQP
different enterprises or within the enterprise to brokers either deliver messages to consumers
easily exchange messages between each other subscribed to queues, or consumers fetch/pull
regardless of the message broker vendor and messages from queues on demand. Various brokers
platform. that have implemented the AMQP protocol like
RabbitMQ, StormMQ, Apache Qpid, Apache
ActiveMQ
In the pull model, each consumer fetches messages using amqp basic.get method Durability: Durability can be configured at exchange/queue/message level. Messages will
(requests to basic.get are synchronized by the broker be persisted until they are acknowledged (either auto or explicit acknowledgement).
Point-Point vs Publish-Subscribe: Supports Point-Point model as well as publish-
subscribe through different exchange types (direct, fanout, topic etc).
The broker maintains information about the state of the queue and messages in Delivery Policies: Supports different message delivery policies
Erlang’s distributed database Mnesia 1. At-most once Delivery: When using auto-acknowledgement messages are delivered
at most once as a message is deleted as soon as it is delivered to the consumer
2. At-least once Delivery: When using explicit acknowledgement messages may be
delivered more than once if the broker does not receive an acknowledgement from the
Consumer can send message to the same exchange to notify producer of status if consumer either due to network failure or consumer/broker crash. In such scenarios,
required. In case of an External Service, the external service can notify the producer messages will re re-queued resulting in delivery again with a delivered flag set to true.
through a callback url. Consumers can also reject or nack messages which will result in re-queuing of messages for re-
delivery.
Message Acknowledgements: Supports message acknowledgements between broker-
>producer as well as consumer->broker.
Batching Policies: This applies for both the push/pull model. Messages can be
Purging Policies: Messages are removed from the queue once they are acknowledged.
pushed/fetched in batches by setting a Qos prefetch count either on the channel level or
Messages are stored in memory (also on disk for persistent messages) and retaining for long
consumer level. This value should be optimized based on the average round trip time (time
periods of time would exhaust memory resulting in performance issues. Rejected messages
taken for broker to send a message and receive ack) and the processing time of the message
and negative acknowledged messages can be requeued or forwarded to dead letter exchange
on the consumer so that the consumer can consume messages at the maximum possible rate.
which will route to appropriate queue for handling such messages.
Scalability: Highly Scalable in terms of throughput(million messages/sec in some cases;
Message Size/Format: Supports binary messages and message size is limited by the
varies with message size) and latency is in the order of tens or hundreds of millisecs. The
amount of memory/disk space on the broker. When a queue gets too large exhausting
number of queues that can be supported would also be in the order of millions in a clustered
memory, messages published to the queue will be written to disk. Even though there is no
deployment limited only by the number of concurrent socket connections that the broker can
limitation on message size, its not ideal to have messages of very large size.
support.
Message filtering/routing Policies: Supports a variety of filtering/routing techniques
Availability: Supports high availability by replicating entities(Exchanges and Bindings) to all
through the different types of exchanges (direct, fanout, topic, headers etc). No other broker
brokers in the cluster to recover from unexpected failures. Queues have to be mirrored to a
solutions offer such a wide range of routing capabilities. AMQP supports more complex
subset of brokers for making them highly available. Chooses Availability over Consistency in
bindings depending on the requirement of applications.
the event of a network partition (AP model)
Message Ordering: Messages are delivered in FIFO order but message consumption may
Operational and Financial Cost: Involves operational and financial cost to manage
not be in FIFO order due to multiple consumers; unless each queue is associated with an
servers and monitor deployments and health of the system.
exclusive consumer.
APACHE KAFKA KAFKA
Kafka is a distributed, partitioned, replicated commit log service. Scalability: Highly Scalable in terms of throughput(million writes/sec, order of
hundreds of MB/sec depending on message size) and latency is in the order of tens or
It provides the functionality of a messaging system, with a hundreds of millisecs. The number of topics that can be supported will be in the order
unique design. In comparison to most messaging systems Kafka of a few thousands. This is limited due to the fact that the configuration information
has better throughput, built-in partitioning, replication, and of brokers, topic-partitions, consumer offsets, partition-owners is stored in zookeeper
znodes and zookeeper being a in-memory non-sharded data store, we will eventually
fault-tolerance which makes it a good solution for large scale exhaust the memory.
message processing applications Availability: Supports high availability by replicating partitions to other brokers in the
cluster based on a replication factor, rebalancing the partitions to other brokers in
case of broker crashes and by maintain ISR’s for each partition. Chooses Availability
over Consistency in the event of a network partition (AP model) in the latest stable
release; with future releases supporting a configuration for choosing consistency over
availability or availability over consistency.