๐‚๐จ๐ฆ๐ฆ๐ฎ๐ง๐ข๐œ๐š๐ญ๐ข๐จ๐ง ๐’๐ญ๐ฒ๐ฅ๐ž๐ฌ

๐’๐ฒ๐ง๐œ๐ก๐ซ๐จ๐ง๐จ๐ฎ๐ฌ vs ๐€๐ฌ๐ฒ๐ง๐œ๐ก๐ซ๐จ๐ง๐จ๐ฎ๐ฌ

ยท

2 min read

One of the fundamental decisions to make when determining the architecture of a system is to determine if communications will be synchronous or asynchronous.

Each communication style offers a set of trade-offs, however, synchronous communication does not present as many challenges as asynchronous communication, making it the preferred default communication mode.

โ€œ๐˜œ๐˜ด๐˜ฆ ๐˜ด๐˜บ๐˜ฏ๐˜ค๐˜ฉ๐˜ณ๐˜ฐ๐˜ฏ๐˜ฐ๐˜ถ๐˜ด ๐˜ฃ๐˜บ ๐˜ฅ๐˜ฆ๐˜ง๐˜ข๐˜ถ๐˜ญ๐˜ต, ๐˜ข๐˜ด๐˜บ๐˜ฏ๐˜ค๐˜ฉ๐˜ณ๐˜ฐ๐˜ฏ๐˜ฐ๐˜ถ๐˜ด ๐˜ธ๐˜ฉ๐˜ฆ๐˜ฏ ๐˜ฏ๐˜ฆ๐˜ค๐˜ฆ๐˜ด๐˜ด๐˜ข๐˜ณ๐˜บ.โ€ โ€“ Michael Richards & Neal Ford

๐’๐ฒ๐ง๐œ๐ก๐ซ๐จ๐ง๐จ๐ฎ๐ฌ ๐‚๐จ๐ฆ๐ฆ๐ฎ๐ง๐ข๐œ๐š๐ญ๐ข๐จ๐ง:

Simplicity is of greater strength within synchronous communications as it does not present many of the challenges brought about by asynchronous communications.

Scalability is more challenging to achieve when synchronous communication is utilized, as different components may not be able to manifest different characteristics, for example, if one component is much more scalable than another it interacts with then this may create a performance bottleneck on the lesser scalable component leading to timeouts, this in turn compromises reliability.

๐€๐ฌ๐ฒ๐ง๐œ๐ก๐ซ๐จ๐ง๐จ๐ฎ๐ฌ ๐œ๐จ๐ฆ๐ฆ๐ฎ๐ง๐ข๐œ๐š๐ญ๐ข๐จ๐ง:

Responsiveness is a positive side effect of the fire-and-forget nature of asynchronous calls, one component may submit information to another without relying on an immediate outcome of an operation, for example, an end user may submit a comment on a social media platform and not have to wait for it to pass through multiple processors rather they may simply be presented with an acknowledgment of their submission.

Error handling complexity is increased as fire-and-forget calls do not immediately return the outcome of an invoked operation, making it more challenging to feedback failure to users, fortunately, error handling techniques such as the Workflow Event pattern can be leveraged to mitigate error handling shortcomings.

Data loss risk is heightened, data may flow from one component to another prior to reaching its final destination, and problems may occur during the processing of data by a component or within transmission via a communication channel, this risk can be mitigated by utilizing techniques such as the Client Acknowledge Mode and Last Participant Support techniques.

It can be possible to achieve synchronous-like communication in an asynchronous system by leveraging request-reply or pseudo-synchronous messaging.

Certain architectural choices can enforce a messaging requirement, for example, only asynchronous messaging can be supported in event-driven architectures.

ย