0 ratings0% found this document useful (0 votes) 71 views16 pages3 Messaging Patterns - To Never Fail Coding Interview
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content,
claim it here.
Available Formats
Download as PDF or read online on Scribd
223106/2028, 02:32 {3 Messaging Patterns — to never fil coding interview | by Toxic Dev | Web3 News & Blogging Website—2023
Openinapp ” Gani) signin
Q
3 Messaging Patterns — to never fail coding
interview
Toxic Dev - Follow
(®_Pubiished in weds News & Blogging Website—2023
Tmin read - Apri9
© tisten () Share
hites/unsplash.com/photos/VSvqWCSgyEU
Cloud applications are distributed, a messaging infrastructure is required to
connect the components and services, ideally in a loosely coupled manner to
optimize scalability. Asynchronous messaging is widely used and has many
advantages, but it also poses problems such as message ordering, poison message
management, idempotency, and others.
hitpsiwebusecase.cof8-messaging-patterns-to-neverfal-coding-intervew-3ad13daef513 ane2310812029, 02:32 3 Messaging Paltems — to never fal coding interview | by Texe Dav| Web3 News & Blogging Website—2023
Introducing you to messaging design patterns that will change the way you
orchestrate your applications. | will try to provide issues, the best use cases for
using such patterns, and scenarios when not to use them.
Asynchronous Request Replay Pattern
Client applications—generally code running in a web-client (browser)—rely on
remote APIs to supply business logic and combine functionality in modern
application development. These APIs may be directly tied to the application or
third-party shared services. These API requests are typically made using the
HTTP(S) protocol and adhere to REST semantics.
(— Gient } (_APlendpoint ) ([Statusendpoint ) — (__ Resource URI
T T T T
I POST ' 1 1
1 ' 1
1 HTTP 202 ' 1 1
——— 1 1
1 1 1
! GET I 1
» '
1 HTTP 200 1 1
1
' 1 1
' GET I 1
> 1
\ HTP 202 1 1
1
! 1
1 GET 1
r ~
1 HTTP 200 1
‘<
HTTP polling is one solution to this problem. Client-side code can benefit from
polling because it can be difficult to provide call-back endpoints or leverage long-
running connections. Even when callbacks are possible, the additional libraries and
services necessary can occasionally add undue complexity.
¢ The client application sends a synchronous request to the API, which initiates a
long-running action on the backend.
* The API reacts as rapidly as feasible in synchronous mode. It returns an HTTP
202 (Accepted) response code, indicating that the request has been received and
is being processed.
hitpsiwebusecase.cof8-messaging-patterns-to-neverfal-coding-intervew-3ad13daef513 ane22702020, 02:92 3 Messaging Paltems — to never fal coding interview | by Texe Dav| Web3 News & Blogging Website—2023
* The response contains a location reference pointing to an endpoint that the
client can poll to see the outcome of the lengthy operation.
* Processing is offloaded to another component, such as a message queue,
through the API.
* Itreturns HTTP 200 for each successful call to the status endpoint. The status
endpoint provides a resource indicating that the task is still in progress while it
is still pending. When the task is finished, the status endpoint can either return
a completion resource or redirect to another resource URL. If the asynchronous
activity, for example, produces a new resource, the status endpoint will redirect
to the URL for that resource.
immot ME ommet P
———__+
cain Enqueue mess8ge goes @ Receive message
Queue
Process message,
© Reply with status endpoint write result to blob
Pica @-
@ all status endpoint @ check for blo
Storage blab
Useful for?
* Client-side code, such as browser apps, where providing call-back endpoints is
problematic because the use of long-running connections adds too much
complexity.
* Service calls where only the HTTP protocol is accessible and the return service
is unable to trigger callbacks due to client-side firewall constraints.
* Service calls that must be integrated with legacy architectures that lack current
callback technologies such as WebSockets or webhooks.
Not so great for?
« Responses must be delivered to the client in real time.
* The client must collect a large number of results, and the received latency of
those results is critical. Instead, consider a service bus pattern.
* Server-side persistent network connections, such as WebSockets or SignalR, can
be used. These services can be used to inform the caller of the outcome,
hitpsiwebSusecase.cof8-messaging-patterns-to-neverfal-coding-intervew-3ad13daef513 ane2310812029, 02:32 {3 Messaging Patems — to never fail coding interview | by Toxic Dev | Web3 News & Blogging Website—2023
* You can use the network design to open ports to receive asynchronous callbacks
or webhooks.
Publisher-Subscriber pattern
httpsi/unsplash.com/photos/27QOmh18KDc
Create an asynchronous messaging subsystem that includes the following
components:
The sender's input messaging channel. The sender packages events into messages
and sends them via the input channel using a specified message format. In this
design, the sender is also known as the publisher.
Each consumer has one output message channel. Customers are referred to as
"subscribers."
hitps:lwesSusecase.cof3-messaging-pattens-to-never-fal-cading-intervew-3ad13daef513 ans2310812029, 02:32 {3 Messaging Patems — to never fail coding interview | by Toxic Dev | Web3 News & Blogging Website—2023
A system for replicating each message from the input channel to all subscribers
who are interested in that message. Typically, an intermediary such as a message
broker or event bus handles this activity.
The logical components of this pattern are depicted in the image below:
PUBLISHER
SUBSCRIBER
Image credits: PubNub
Issues:
+ Subscription handling: Consumers must be able to subscribe to and
unsubscribe from various channels through the messaging infrastructure.
© Securit
'o avoid eavesdropping by unauthorised users or applications,
connecting to any communication channel must be controlled by security
policy
Useful for?
+ An application must broadcast information to a large number of users.
+ An application must interact with one or more independently produced
applications or services, which may use various platforms, programming
languages, and communication protocols.
* An application can convey information to users without forcing them to respond
in real time.
hitpsiwebSusecase.cof8-messaging-patterns-to-neverfal-coding-intervew-3ad13daef513 sre23712028, 02:22 4 Messaging Patams — to never cacng interview | by Toxic Dev | Webs News & Blogging Webste—2023
* The interconnected systems are intended to provide an ultimate consistency
model for their data.
* An application must deliver data to several consumers, each of whom may have
different availability requirements or uptime schedules than the sender.
Not so great for?
* An application has only a few consumers who require information that is
notably different from that required by the producing application.
* An application necessitates near-real-time contact with users.
Competing Consumers pattern
A cloud-based application is anticipated to manage a huge number of requests.
Instead of processing each request synchronously, it is typical for the application to
route them through a message system to another service (a consumer service) that
handles them asynchronously. This method helps to ensure that the application’s
business logic is not slowed down while the requests are being processed.
For a variety of reasons, the quantity of requests can fluctuate dramatically over
time. A surge in user activity or aggregated requests from numerous tenants can
result in unanticipated demand. During peak hours, a system may need to process
hundreds of requests per second, yet at other times, the number may be quite low.
Furthermore, the type of work conducted to respond to these requests may be quite
diverse. You can cause a single instance of the consumer service to become
swamped with requests if you use it. Alternatively, an inflow of messages from the
program could overburden the messaging system.
The system can operate numerous instances of the consumer service to meet the
varying workload. These customers, however, must be coordinated such that each
message is only provided to a single consumer. To avoid one instance from
becoming a bottleneck, the workload must also be distributed among consumers.
Solution:
To implement the communication channel between the application and the
consumer service instances, use a message queue. The application sends messages
containing requests to the queue, and the consumer service instances receive and
hitps:lwebusecase.cof3-messaging-patterns-o-never-fal-cading-intervew-3ad13daef513 ane2310812029, 02:32 3 Messaging Paltems — to never fal coding interview | by Texe Dav| Web3 News & Blogging Website—2023
process the messages. This method allows the same pool of consumer service
instances to handle messages from any application instance. The diagram depicts
the use of a message queue to distribute work to service instances.
Application instances -
generating messages Consumer service
instance poo! -
©) processing messages
© Message queue
\
@)—_ BEE @))
e
@)
* Message Ordering: The order in which messages are received by consumer
Issues:
service instances is not guaranteed and does not always correspond to the order
in which the messages were created.
* Detecting poison messages: A service instance can fail due to a faulty message
or a task that requires access to resources that aren't available.
Useful for?
* An application's workload is separated into jobs that can run asynchronously.
* Tasks are self-contained and can operate in parallel.
* The job volume is very changeable, necessitating a scalable solution.
¢ The solution must be highly available and resilient in the event that task
processing fails.
Not so great for?
* It is difficult to divide the application burden into discrete tasks, or there is a
high degree of dependability between tasks.
* Tasks must be completed in a synchronous manner, and the application logic
must wait for a task to complete before proceeding.
+ Tasks must be completed in a specified order.
hitpsiwebusecase.cof8-messaging-patterns-to-neverfal-coding-intervew-3ad13daef513 m62310572028, 02:32 {3 Messaging Patterns — to never fil coding interview | by Toxic Dev | Web3 News & Blogging Website—2023
One clap, two clap, three clap. Forty?
Thanks for reading. If you get any valuable information from this article, then feel
free to comment and follow for more content. Believe me, no clap or follow, goes
unnoticed.
This is part two of the “Cloud Patterns” series; please read the first blog article, in which I
attempted to describe 7 architectural patterns.
Thave used all of these patterns while working in my company, so I know they will
come in handy not only for interviews but also when you join your dream company.
Are you seeking a new job? Does your resume measure up? Check out my blog post
on the use of AT tools for the entire job search process, from employment search to
salary negotiations.
ZAI tools to land your dream job
Keep Hustling, Keep Dreaming. \m/
Programming Technology —Software Development Cloud Computing Design
© GeO
Written by Toxic Dev
526 Followers « Writer for Web3 News & Blogging Website—2023
Ex-MongoDB Engineer | Ex-Baeldung Writer | Ex- Karat Interviewer | Developer * Daydreamer * Demigod.
More from Toxic Dev and Web3 News & Blogging Website—2023
hitps:lwesSusecase.cof3-messaging-pattens-to-never-fal-cading-intervew-3ad13daef513 ane2310572028, 02:32 {3 Messaging Patterns — to never fil coding interview | by Toxic Dev | Web3 News & Blogging Website—2023
@ Toxic Dev in Webs News & Blogging Website—2023
7 Architecture Design Patterns — You wish you knew before interview
Source: Undraw
‘Tmin read » Apri3
Sr Qe A
© henanjay Gavall in Web3 News & Blogging Website—2023
5 amazing websites for Ul graphics that you can use for free.
hitps:lwebusecase.cof3-messaging-patterns-o-never-fal-cading-intervew-3ad13daef513 one2310572028, 02:32 {3 Messaging Patterns — to never fil coding interview | by Toxic Dev | Web3 News & Blogging Website—2023
Hello readers, in this article | will show you 5 amazing website that will ease your work as a
front-end developer. Here you can find out...
Sminread + May 26
yh
20
HashiCorp
Terrafe
@ Luca Fusaro in Webs News & Blogging Website—2023
Automation Using Terraform: Jenkins Deployment in AWS
timin read - May30
yh
©) 33
hitps:lwebusecase.cof3-messaging-patterns-o-never-fal-cading-intervew-3ad13daef513 10116zarunozs 0222 4 Messgng Patan — to nvr acd ann |by Tne Dov Wb News & logins Wobate—2028
= 7 =
Y
@mongoDB Consisteney Mysat — VERTICA
|
Epsanans — .MeOA)
@
PostgreSQL
HBASE
( Partition-
\ Tolerance
\
@ Toxic dev
CAP Theorem—An impossible choice
“Cheap, Fast, and Good: Pick Two"?
Availability }
Sminread + JunS
Sm Qi ct
( See all from Toxic Dev )
Cc See all from Web News & Blogging Website—2023, )
Recommended from Medium
hitps:lwesSusecase.cof3-messaging-pattens-to-never-fal-cading-intervew-3ad13daef513 m62310572028, 02:32 {3 Messaging Patterns — to never fil coding interview | by Toxic Dev| Web3 News & Blogging Website—2023
B Love sharma in Dev Genius
System Design Blueprint: The Ultimate Guide
Developing a robust, scalable, and efficient system can be daunting. However, understanding
the key concepts and components can make the.
+ - Qminread - Apr20
Sa Qa in
Edward Huang in Better Programming
How To Update Your Status During Standup Like a Senior Engineer
hitps:lwebSusecase.cof3-messaging-pattens-o-never-fal-cading-intervew-3ad13daef513 rane223106/2028, 02:32 {3 Messaging Patterns — to never fil coding interview | by Toxic Dev | Web3 News & Blogging Website—2023
A status update is where you can showcase how well you manage ambiguity and is an
important way to build trust with your team
+ + Qminread - Oct 20,2022
S) 25K OQ 4 int
General Coding Knowledge
20stories + 13saves
It's never too late or early to start something
1Ostories . 6 saves
Stories to Help You Grow as a Designer
Histories + 86saves
Coding & Development
Histories « 4 saves
‘The Secret Developer
The 7 Signs of a Great Programmer fo
Not foolproof
hitpsiwebusecase.cof8-messaging-patterns-to-neverfal-coding-intervew-3ad13daef513 131682310572028, 02:32 {3 Messaging Patterns — to never fil coding interview | by Toxic Dev | Web3 News & Blogging Website—2023
+ - 4minread - Jan24
S27 Qi
& sonn Raines
Be an Engineer, not a Frameworker
Time to level up.
+ - 10min read - Mar8,2022
2K Qs
hitps:lwebusecase.cof3-messaging-patterns-o-never-fal-cading-intervew-3ad13daef513 vans2310572028, 02:32 {3 Messaging Patterns — to never fil coding interview | by Toxic Dev| Web3 News & Blogging Website—2023
Write-around
+ Write-beck
Mesa
Suitable Scenarios:
+ In-memary solution
+ Read heavy system
*+ Data isnot frequently
updated
Key Metrics
+ Cache Hit Ratio
* Latency.
+ Throughput
+ Invalidation Rate
Memory Usage
cPUusage
Network usage
B Love sharma in Dev Genius
A Comprehensive Guide to Distributed Caching
An essential website requires a web server to receive requests and a database to write or read
data. However, this simple setup will only.
+ + 13minread - Febs
4a Qa
@ The coding Diaries in The Coding Diaries
Why Experienced Programmers Fail Coding Interviews
hitps:lwebusecase.co(3-messaging-pattens-o-never-fal-coding-intervew-3ad13daef513 1516223106/2028, 02:32 {3 Messaging Patterns — to never fil coding interview | by Toxic Dev | Web3 News & Blogging Website—2023
A friend of mine recently joined a FAANG company as an engineering manager, and found
themselves in the position of recruiting for...
+ + Sminread » Nov2,2022
&) 4k QQ 87
yh
See more recommendations +)
hitpsiwebSusecase.cof8-messaging-patterns-to-neverfal-coding-intervew-3ad13daef513 1616