What is Pub/Sub Messaging ? Related Terminology
Sub
Publisher —> Input(Channel) —> Output(Channel) —> Sub
Sub
Sub
Here The Publisher is produces the Message , through the help of the Input Channel The Message can be Sends to the Output Channel and the message receives Needed Consumers/ All The Consumers / Different Consumers
There should be a multiple Output Channel for Multiple Consumers
Every Message which is produced by Publisher its not All the Consumers is has to React , Just who else have to React they Can React the Message
There should be an need for Message Broker between Input & Output Channel
Its takes care of the Multiple Responsibilities
One of the Responsibilities is , When The Publisher Publishing the Event(Message) in some format , the format could have to be modified / Its enriched with other data then its passes to the Output Channel
Message Broker can divide the Message into different topics , then consumers listen to particular topic then they can react accordingly
Sub
Publisher —> Input(Channel) —> Message Broker —> Output(Channel) —> Sub
Sub
Sub
Pub/Sub Use Cases
Async Workflow : Business Workflow , If any of the order has been placed the customer will get the Notification Through the Email or Message (Send Notification) and The Communication has to be send to the Warehouse (Process item for packing) , The finance department has to send the Invoice about the Order , Initiating seller workflow for delivery of the product.
Here some responses has to been happen ASAP , like if customer click any of the product in Add to Cart instantly the product could be added in cart here we can’t able to use Asynchronous Communication.
Decoupling : Every users activity to be recorded for analytic purpose , the each activity has to be store in database , so User actions and Data processing at backend cannot be synchronous
Load Balancing : Increased load can be balanced either by increasing the number of subscribers and even if subscribers are limited , then too messages would be retained in the queue.
Deferred Processing : Its similar to Asynchronous workflow Data Streaming
Performance Metrics :
Throughput : Some amount of work done in particular time , in system design Throughput can be considered as Number of API calls served per unit time.
Bandwidth : Its comes into to picture when the data getting delivered / Transferred over the connected networks on multiple location
Ex : Netflix , the streaming can be happing in every different location around the globe so the data can be get it in the real time.
1.Not enough Resources —> High Bandwidth —> Less Throughput(Performance)
2.High Resources —> Less Bandwidth —> Less Throughput(Performance)
3.High Resources —> High Bandwidth —> High Throughput(Performance)
Response Time : When our System will serve 1000 requests per second , and the Response also will be in One second
High Resource —> High Bandwidth —> Time Takes (More Time for an Each Request ) —> Throughput (Performance )
In this above case The Performance will be low ,because the time taken for each request is more.
Performance of Components
Performance Metrics of an Application :
API Response Time —> Throughput of APIs —> Error Occurrences —> Bug / Defect in the Code
Performance Metrics of an Databases :
Time Taken by various database queries —> Number of queries executed per unit time (or throughput)
Performance Metrics of an Cache :
Latency of Writing to Cache —> Number of Cache Eviction and Invalidation —> Memory of Cache Instance
Performance Metrics of an Message Queues :
Rate of Production and Consumption —> Fraction of Stale or Unprocessed Messages —> Number of Consumers affects Bandwidth and Throughput
Performance Metrics of an Workers :
Time taken for Job Completion —> Resources used in Processing
Performance Metrics of an Server Instances :
Every Components would be run on some Hardware Machines/Some Instance in Cloud ex: Application , Databases ,Workers , Message Queues etc.. all of them need some Infrastructure support running on the Instances , on every Component its self would have some requirement , Those requirements are
Memory
CPU
Performance Metrics Tools :
PM Tools – Performance Management Tools
There are different many tools to measure the performance of the Application , Cache , Message Queues , Databases , etc..