Continuation Complexity: A Callback Hell for Distributed Systems
Designing and validating large-scale distributed systems is still a complex issue. The asynchronous event-based nature of distributed communications makes these systems complex to implement, debug and test. In this article, we introduce the continuation complexity problem, that arises when synchronous invocations must be converted to asynchronous event code. This problem appears in most Actor libraries where communication is mainly asynchronous, and where a synchronous call to other Actor would block the current Actor, precluding the processing of incoming messages.
We propose here a novel parallel invocation abstraction that considerably simplifies the continuation complexity problem for distributed actor systems requiring non-blocking synchronous invocations. Our parallel abstraction extends the message passing concurrency model to support concurrent interleavings of method executions within a single Actor. We present here two candidate solutions for implementing such parallel calls: one based on threads and locking, and other based on green threads and continuations.
We evaluated the simplicity of our solution implementing a well known distributed algorithm like Chord (ring-based structured overlay). We compare our Actor implementation of Chord with three different simulators (PeerSim, PlanetSim, Macedon). This validation demonstrates that our approach is superior in simplicity (less LoC) and complexity (less McAbe complexity), envisaging its great potential for distributed systems scenarios.
KeywordsActor model Object actors Continuation complexity
Special thanks to Douglas C. Schmidt for his helpful comments about the Active Object pattern.
This work has been partially funded by the EU in the context of the project CloudSpaces (FP7-317555) and by the Spanish Ministerio de Ciencia e Innovación in the project Cloud Services and Community Clouds (TIN2013-47245-C2-2-R)
- 1..NET platform Async and Await abstractions. http://msdn.microsoft.com/en-us/library/hh191443.aspx
- 2.Agha, G.: Actors: a model of concurrent computation. In: Distributed Systems. Artificial Intelligence. The MIT Press, Cambridge (1986)Google Scholar
- 4.Edwards, J.: Coherent reaction. In: Proceedings of the 24th ACM SIGPLAN Conference Companion on Object Oriented Programming Systems Languages and Applications, pp. 925–932. ACM (2009)Google Scholar
- 6.Lin, Y., Radoi, C., Dig, D.: Retrofitting concurrency for android applications through refactoring. In: Proceedings of the 22nd ACM SIGSOFT International Symposium on Foundations of Software Engineering, FSE 2014, pp. 341–352. ACM, New York (2014). http://doi.acm.org/10.1145/2635868.2635903
- 7.Montresor, A., Jelasity, M.: PeerSim: a scalable P2P simulator. In: Proceedings of the 9th International Conference on Peer-to-Peer (P2P 2009), Seattle, WA, pp. 99–100, September 2009Google Scholar
- 8.Okur, S., Hartveld, D.L., Dig, D., van Deursen, A.: A study and toolkit for asynchronous programming in c#. In: Proceedings of the 36th International Conference on Software Engineering, ICSE 2014, pp. 1117–1127. ACM, New York (2014). http://doi.acm.org/10.1145/2568225.2568309
- 9.Reynolds, J.: The discoveries of continuations. Lisp Symbolic Comput. 6(3–4), 233248 (1993). Special Issue on Continuations, Hingham, MA, USAGoogle Scholar
- 10.Rodriguez, A., Killian, C., Bhat, S., Kostic, D., Vahdat, A.: Macedon: methodology for automatically creating, evaluating, and designing overlay networks. In: Proceedings of the 1st Conference on Symposium on Networked Systems Design and Implementation, vol. 1, pp. 267–280 (2004)Google Scholar