Go back to the bliki index

Choreography

By Fabrizio Montesi. Created on: 18 May 2023. See also: Introduction to Choreographies

In computer science, a choreography is a coordination plan for processes that participate in concurrent and distributed systems [Montesi 2023]. It defines the communications that these processes are expected to perform, usually with the underlying intention that these processes collabolate in order to achieve a joint goal.

Choreographies are typically given in a choreographic language.

buyer.product -> seller.x;
seller.priceOf(x) -> buyer.price;
if buyer.likes(price) then
	buyer -> seller[Accept];
	seller -> shipper[PrepareShipping];
	buyer.address -> shipper.destination;
else
	buyer -> seller[Reject];
	seller -> shipper[NoShipping];

A simple choreography where a buyer requests the price of a product from a seller and then decides whether to go forward with the product's shipping by a third-party shipper, given in Recursive Choreographies. Adapted from [Carbone et al. 2012].

sequenceDiagram
	participant b as buyer
	participant s as seller
	participant sh as shipper
	b->>s: product
	s->>b: price
	alt b.likes(price)
		b->>s: Accept
		s->>sh: PrepareShipping
		b->>sh: address
	else
		b->>s: Reject
		s->>sh: NoShipping
	end

A similar buyer-seller-shipper example, but given as a sequence diagram.

Data Choreographies

Choreographies in computer science are not to be confused with choreographies in other fields. When disambiguation is necessary, the choreographies in computer science can be called 'Data Choreographies' (https://youtu.be/B7MNZk1v37g).

Decentralised nature

By nature, choreographies do not require central control. They are often contrasted with the concept of orchestration, whereby a central coordinator (the orchestrator) invokes and composes the operations offered by the other processes in the system.

However, while choreographies do not need centralised control, this does not mean that all choreographies describe decentralised systems. It is indeed conceivable to write a choreography that describes an orchestrated system.

References

Carbone, M., Honda, K., Yoshida, N. [2012], 'Structured Communication-Centered Programming for Web Services', ACM Trans. Program. Lang. Syst. 34(2): 8:1-8:78. https://doi.org/10.1145/2220365.2220367

Montesi, F. [2023], 'Introduction to Choreographies', Cambridge University Press. https://doi.org/10.1017/9781108981491