๐๐จ๐ฆ๐ฆ๐ฎ๐ง๐ข๐๐๐ญ๐ข๐จ๐ง ๐๐ญ๐ฒ๐ฅ๐๐ฌ
๐๐ฒ๐ง๐๐ก๐ซ๐จ๐ง๐จ๐ฎ๐ฌ vs ๐๐ฌ๐ฒ๐ง๐๐ก๐ซ๐จ๐ง๐จ๐ฎ๐ฌ
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.